Skip to content

Commit

Permalink
deploy: 473d6c6
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-x-c committed Mar 11, 2024
1 parent ad66272 commit 8a16cee
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 17 deletions.
54 changes: 43 additions & 11 deletions _modules/agentscope/agents/rpc_agent.html
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,12 @@ <h1>Source code for agentscope.agents.rpc_agent</h1><div class="highlight"><pre>
<span class="sa">f</span><span class="s2">&quot;rpc server [</span><span class="si">{</span><span class="n">agent_class</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">] at port [</span><span class="si">{</span><span class="n">port</span><span class="si">}</span><span class="s2">] started &quot;</span>
<span class="s2">&quot;successfully&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">pipe</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">port</span><span class="p">)</span>
<span class="n">start_event</span><span class="o">.</span><span class="n">set</span><span class="p">()</span>
<span class="n">stop_event</span><span class="o">.</span><span class="n">wait</span><span class="p">()</span>
<span class="k">if</span> <span class="n">start_event</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">pipe</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">port</span><span class="p">)</span>
<span class="n">start_event</span><span class="o">.</span><span class="n">set</span><span class="p">()</span>
<span class="n">stop_event</span><span class="o">.</span><span class="n">wait</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">server</span><span class="o">.</span><span class="n">wait_for_termination</span><span class="p">()</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Stopping rpc server [</span><span class="si">{</span><span class="n">agent_class</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">] at port [</span><span class="si">{</span><span class="n">port</span><span class="si">}</span><span class="s2">]&quot;</span><span class="p">,</span>
<span class="p">)</span>
Expand Down Expand Up @@ -450,15 +453,35 @@ <h1>Source code for agentscope.agents.rpc_agent</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">port</span> <span class="o">=</span> <span class="n">check_port</span><span class="p">(</span><span class="n">port</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">max_pool_size</span> <span class="o">=</span> <span class="n">max_pool_size</span>
<span class="bp">self</span><span class="o">.</span><span class="n">max_timeout_seconds</span> <span class="o">=</span> <span class="n">max_timeout_seconds</span>
<span class="bp">self</span><span class="o">.</span><span class="n">local_model</span> <span class="o">=</span> <span class="n">local_mode</span>
<span class="bp">self</span><span class="o">.</span><span class="n">local_mode</span> <span class="o">=</span> <span class="n">local_mode</span>
<span class="bp">self</span><span class="o">.</span><span class="n">server</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">stop_event</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">parent_con</span> <span class="o">=</span> <span class="kc">None</span>

<div class="viewcode-block" id="RpcAgentServerLauncher.launch">
<a class="viewcode-back" href="../../../agentscope.agents.html#agentscope.agents.rpc_agent.RpcAgentServerLauncher.launch">[docs]</a>
<span class="k">def</span> <span class="nf">launch</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;launch a local rpc agent server.&quot;&quot;&quot;</span>
<span class="k">def</span> <span class="nf">_launch_in_main</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Launch gRPC server in main-process&quot;&quot;&quot;</span>
<span class="n">server_thread</span> <span class="o">=</span> <span class="n">threading</span><span class="o">.</span><span class="n">Thread</span><span class="p">(</span>
<span class="n">target</span><span class="o">=</span><span class="n">setup_rcp_agent_server</span><span class="p">,</span>
<span class="n">kwargs</span><span class="o">=</span><span class="p">{</span>
<span class="s2">&quot;agent_class&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">agent_class</span><span class="p">,</span>
<span class="s2">&quot;agent_args&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">agent_args</span><span class="p">,</span>
<span class="s2">&quot;agent_kwargs&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">agent_kwargs</span><span class="p">,</span>
<span class="s2">&quot;host&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">host</span><span class="p">,</span>
<span class="s2">&quot;port&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">port</span><span class="p">,</span>
<span class="s2">&quot;max_pool_size&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_pool_size</span><span class="p">,</span>
<span class="s2">&quot;max_timeout_seconds&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_timeout_seconds</span><span class="p">,</span>
<span class="s2">&quot;local_mode&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">local_mode</span><span class="p">,</span>
<span class="p">},</span>
<span class="p">)</span>
<span class="n">server_thread</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Launch [</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">agent_class</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">] server at &quot;</span>
<span class="sa">f</span><span class="s2">&quot;[</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">host</span><span class="si">}</span><span class="s2">:</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">port</span><span class="si">}</span><span class="s2">] success&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">server_thread</span><span class="o">.</span><span class="n">join</span><span class="p">()</span>

<span class="k">def</span> <span class="nf">_launch_in_sub</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Launch gRPC server in sub-process.&quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">stop_event</span> <span class="o">=</span> <span class="n">Event</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">parent_con</span><span class="p">,</span> <span class="n">child_con</span> <span class="o">=</span> <span class="n">Pipe</span><span class="p">()</span>
<span class="n">start_event</span> <span class="o">=</span> <span class="n">Event</span><span class="p">()</span>
Expand All @@ -476,7 +499,7 @@ <h1>Source code for agentscope.agents.rpc_agent</h1><div class="highlight"><pre>
<span class="s2">&quot;pipe&quot;</span><span class="p">:</span> <span class="n">child_con</span><span class="p">,</span>
<span class="s2">&quot;max_pool_size&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_pool_size</span><span class="p">,</span>
<span class="s2">&quot;max_timeout_seconds&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_timeout_seconds</span><span class="p">,</span>
<span class="s2">&quot;local_mode&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">local_model</span><span class="p">,</span>
<span class="s2">&quot;local_mode&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">local_mode</span><span class="p">,</span>
<span class="p">},</span>
<span class="p">)</span>
<span class="n">server_process</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
Expand All @@ -486,7 +509,16 @@ <h1>Source code for agentscope.agents.rpc_agent</h1><div class="highlight"><pre>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Launch [</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">agent_class</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">] server at &quot;</span>
<span class="sa">f</span><span class="s2">&quot;[</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">host</span><span class="si">}</span><span class="s2">:</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">port</span><span class="si">}</span><span class="s2">] success&quot;</span><span class="p">,</span>
<span class="p">)</span></div>
<span class="p">)</span>

<div class="viewcode-block" id="RpcAgentServerLauncher.launch">
<a class="viewcode-back" href="../../../agentscope.agents.html#agentscope.agents.rpc_agent.RpcAgentServerLauncher.launch">[docs]</a>
<span class="k">def</span> <span class="nf">launch</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">in_subprocess</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;launch a local rpc agent server.&quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">in_subprocess</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_launch_in_sub</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_launch_in_main</span><span class="p">()</span></div>


<div class="viewcode-block" id="RpcAgentServerLauncher.wait_until_terminate">
Expand All @@ -505,8 +537,8 @@ <h1>Source code for agentscope.agents.rpc_agent</h1><div class="highlight"><pre>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">stop_event</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">stop_event</span><span class="o">.</span><span class="n">set</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">stop_event</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">terminate</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">timeout</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">terminate</span><span class="p">()</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">is_alive</span><span class="p">():</span>
<span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">kill</span><span class="p">()</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span>
Expand Down
6 changes: 2 additions & 4 deletions _modules/agentscope/models/model.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,8 @@ <h1>Source code for agentscope.models.model</h1><div class="highlight"><pre>
<span class="sd"> from the config file.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">config_name</span> <span class="o">=</span> <span class="n">config_name</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Initialize model [</span><span class="si">{</span><span class="n">config_name</span><span class="si">}</span><span class="s2">] with config:</span><span class="se">\n</span><span class="s2">&quot;</span>
<span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">kwargs</span><span class="p">,</span><span class="w"> </span><span class="n">indent</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Initialize model [</span><span class="si">{</span><span class="n">config_name</span><span class="si">}</span><span class="s2">]&quot;</span><span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;[</span><span class="si">{</span><span class="n">config_name</span><span class="si">}</span><span class="s2">]:</span><span class="se">\n</span><span class="s2"> </span><span class="si">{</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">kwargs</span><span class="p">,</span><span class="w"> </span><span class="n">indent</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>

<span class="k">def</span> <span class="fm">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">:</span> <span class="n">Any</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="n">Any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">ModelResponse</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Processing input with the model.&quot;&quot;&quot;</span>
Expand Down
2 changes: 1 addition & 1 deletion agentscope.agents.html
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ <h1>Agents package<a class="headerlink" href="#agents-package" title="Link to th
<p>Launcher of rpc agent server.</p>
<dl class="py method">
<dt class="sig sig-object py" id="agentscope.agents.rpc_agent.RpcAgentServerLauncher.launch">
<span class="sig-name descname"><span class="pre">launch</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="_modules/agentscope/agents/rpc_agent.html#RpcAgentServerLauncher.launch"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#agentscope.agents.rpc_agent.RpcAgentServerLauncher.launch" title="Link to this definition"></a></dt>
<span class="sig-name descname"><span class="pre">launch</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">in_subprocess</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="_modules/agentscope/agents/rpc_agent.html#RpcAgentServerLauncher.launch"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#agentscope.agents.rpc_agent.RpcAgentServerLauncher.launch" title="Link to this definition"></a></dt>
<dd><p>launch a local rpc agent server.</p>
</dd></dl>

Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit 8a16cee

Please sign in to comment.