Skip to content

Commit

Permalink
deploy: 3560d8e
Browse files Browse the repository at this point in the history
  • Loading branch information
DavdGao committed Jun 9, 2024
1 parent 4cbb224 commit db2018b
Show file tree
Hide file tree
Showing 136 changed files with 3,440 additions and 1,246 deletions.
Binary file modified en/.doctrees/agentscope.agents.agent.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.agents.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.agents.user_agent.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.exception.doctree
Binary file not shown.
Binary file not shown.
Binary file modified en/.doctrees/agentscope.message.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.server.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.server.launcher.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.server.servicer.doctree
Binary file not shown.
Binary file added en/.doctrees/agentscope.studio.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.utils.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.utils.tools.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.web.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified en/.doctrees/agentscope.web.workstation.workflow_dag.doctree
Binary file not shown.
Binary file modified en/.doctrees/environment.pickle
Binary file not shown.
Binary file modified en/.doctrees/index.doctree
Binary file not shown.
30 changes: 27 additions & 3 deletions en/_modules/agentscope/_init.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ <h1>Source code for agentscope._init</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">.agents</span> <span class="kn">import</span> <span class="n">AgentBase</span>
<span class="kn">from</span> <span class="nn">._runtime</span> <span class="kn">import</span> <span class="n">_runtime</span>
<span class="kn">from</span> <span class="nn">.file_manager</span> <span class="kn">import</span> <span class="n">file_manager</span>
<span class="kn">from</span> <span class="nn">.utils.logging_utils</span> <span class="kn">import</span> <span class="n">LOG_LEVEL</span><span class="p">,</span> <span class="n">setup_logger</span>
<span class="kn">from</span> <span class="nn">.logging</span> <span class="kn">import</span> <span class="n">LOG_LEVEL</span><span class="p">,</span> <span class="n">setup_logger</span>
<span class="kn">from</span> <span class="nn">.utils.monitor</span> <span class="kn">import</span> <span class="n">MonitorFactory</span>
<span class="kn">from</span> <span class="nn">.models</span> <span class="kn">import</span> <span class="n">read_model_configs</span>
<span class="kn">from</span> <span class="nn">.constants</span> <span class="kn">import</span> <span class="n">_DEFAULT_DIR</span>
<span class="kn">from</span> <span class="nn">.constants</span> <span class="kn">import</span> <span class="n">_DEFAULT_LOG_LEVEL</span>
<span class="kn">from</span> <span class="nn">.studio._client</span> <span class="kn">import</span> <span class="n">_studio_client</span>

<span class="c1"># init setting</span>
<span class="n">_INIT_SETTINGS</span> <span class="o">=</span> <span class="p">{}</span>
Expand All @@ -132,6 +133,7 @@ <h1>Source code for agentscope._init</h1><div class="highlight"><pre>
<span class="n">logger_level</span><span class="p">:</span> <span class="n">LOG_LEVEL</span> <span class="o">=</span> <span class="n">_DEFAULT_LOG_LEVEL</span><span class="p">,</span>
<span class="n">runtime_id</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">agent_configs</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">list</span><span class="p">,</span> <span class="nb">dict</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">studio_url</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">AgentBase</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;A unified entry to initialize the package, including model configs,</span>
<span class="sd"> runtime names, saving directories and logging settings.</span>
Expand Down Expand Up @@ -167,6 +169,8 @@ <h1>Source code for agentscope._init</h1><div class="highlight"><pre>
<span class="sd"> which can be loaded by json.loads(). One agent config should</span>
<span class="sd"> cover the required arguments to initialize a specific agent</span>
<span class="sd"> object, otherwise the default values will be used.</span>
<span class="sd"> studio_url (`Optional[str]`, defaults to `None`):</span>
<span class="sd"> The url of the agentscope studio.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">init_process</span><span class="p">(</span>
<span class="n">model_configs</span><span class="o">=</span><span class="n">model_configs</span><span class="p">,</span>
Expand All @@ -178,17 +182,19 @@ <h1>Source code for agentscope._init</h1><div class="highlight"><pre>
<span class="n">save_log</span><span class="o">=</span><span class="n">save_log</span><span class="p">,</span>
<span class="n">use_monitor</span><span class="o">=</span><span class="n">use_monitor</span><span class="p">,</span>
<span class="n">logger_level</span><span class="o">=</span><span class="n">logger_level</span><span class="p">,</span>
<span class="n">studio_url</span><span class="o">=</span><span class="n">studio_url</span><span class="p">,</span>
<span class="p">)</span>

<span class="c1"># save init settings for subprocess</span>
<span class="n">_INIT_SETTINGS</span><span class="p">[</span><span class="s2">&quot;model_configs&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">model_configs</span>
<span class="n">_INIT_SETTINGS</span><span class="p">[</span><span class="s2">&quot;project&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">project</span>
<span class="n">_INIT_SETTINGS</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">name</span>
<span class="n">_INIT_SETTINGS</span><span class="p">[</span><span class="s2">&quot;project&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">_runtime</span><span class="o">.</span><span class="n">project</span>
<span class="n">_INIT_SETTINGS</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">_runtime</span><span class="o">.</span><span class="n">name</span>
<span class="n">_INIT_SETTINGS</span><span class="p">[</span><span class="s2">&quot;runtime_id&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">_runtime</span><span class="o">.</span><span class="n">runtime_id</span>
<span class="n">_INIT_SETTINGS</span><span class="p">[</span><span class="s2">&quot;save_dir&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">save_dir</span>
<span class="n">_INIT_SETTINGS</span><span class="p">[</span><span class="s2">&quot;save_api_invoke&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">save_api_invoke</span>
<span class="n">_INIT_SETTINGS</span><span class="p">[</span><span class="s2">&quot;save_log&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">save_log</span>
<span class="n">_INIT_SETTINGS</span><span class="p">[</span><span class="s2">&quot;logger_level&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">logger_level</span>
<span class="n">_INIT_SETTINGS</span><span class="p">[</span><span class="s2">&quot;use_monitor&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">use_monitor</span>

<span class="c1"># Save code if needed</span>
<span class="k">if</span> <span class="n">save_code</span><span class="p">:</span>
Expand Down Expand Up @@ -231,6 +237,7 @@ <h1>Source code for agentscope._init</h1><div class="highlight"><pre>
<span class="n">save_log</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
<span class="n">use_monitor</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="n">logger_level</span><span class="p">:</span> <span class="n">LOG_LEVEL</span> <span class="o">=</span> <span class="n">_DEFAULT_LOG_LEVEL</span><span class="p">,</span>
<span class="n">studio_url</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</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;An entry to initialize the package in a process.</span>

Expand All @@ -256,12 +263,16 @@ <h1>Source code for agentscope._init</h1><div class="highlight"><pre>
<span class="sd"> Whether to activate the monitor.</span>
<span class="sd"> logger_level (`LOG_LEVEL`, defaults to `&quot;INFO&quot;`):</span>
<span class="sd"> The logging level of logger.</span>
<span class="sd"> studio_url (`Optional[str]`, defaults to `None`):</span>
<span class="sd"> The url of the agentscope studio.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># Init the runtime</span>
<span class="k">if</span> <span class="n">project</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">_runtime</span><span class="o">.</span><span class="n">project</span> <span class="o">=</span> <span class="n">project</span>

<span class="k">if</span> <span class="n">name</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">_runtime</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">name</span>

<span class="k">if</span> <span class="n">runtime_id</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">_runtime</span><span class="o">.</span><span class="n">runtime_id</span> <span class="o">=</span> <span class="n">runtime_id</span>

Expand All @@ -281,6 +292,19 @@ <h1>Source code for agentscope._init</h1><div class="highlight"><pre>
<span class="n">db_path</span><span class="o">=</span><span class="n">file_manager</span><span class="o">.</span><span class="n">path_db</span><span class="p">,</span>
<span class="n">impl_type</span><span class="o">=</span><span class="s2">&quot;sqlite&quot;</span> <span class="k">if</span> <span class="n">use_monitor</span> <span class="k">else</span> <span class="s2">&quot;dummy&quot;</span><span class="p">,</span>
<span class="p">)</span>

<span class="c1"># Init studio client, which will push messages to web ui and fetch user</span>
<span class="c1"># inputs from web ui</span>
<span class="k">if</span> <span class="n">studio_url</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">_studio_client</span><span class="o">.</span><span class="n">initialize</span><span class="p">(</span><span class="n">_runtime</span><span class="o">.</span><span class="n">runtime_id</span><span class="p">,</span> <span class="n">studio_url</span><span class="p">)</span>
<span class="c1"># Register in AgentScope Studio</span>
<span class="n">_studio_client</span><span class="o">.</span><span class="n">register_running_instance</span><span class="p">(</span>
<span class="n">project</span><span class="o">=</span><span class="n">_runtime</span><span class="o">.</span><span class="n">project</span><span class="p">,</span>
<span class="n">name</span><span class="o">=</span><span class="n">_runtime</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
<span class="n">timestamp</span><span class="o">=</span><span class="n">_runtime</span><span class="o">.</span><span class="n">timestamp</span><span class="p">,</span>
<span class="n">run_dir</span><span class="o">=</span><span class="n">file_manager</span><span class="o">.</span><span class="n">dir_root</span><span class="p">,</span>
<span class="n">pid</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">getpid</span><span class="p">(),</span>
<span class="p">)</span>
</pre></div>

</div>
Expand Down
30 changes: 27 additions & 3 deletions en/_modules/agentscope/agents/agent.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ <h1>Source code for agentscope.agents.agent</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">loguru</span> <span class="kn">import</span> <span class="n">logger</span>

<span class="kn">from</span> <span class="nn">agentscope.agents.operator</span> <span class="kn">import</span> <span class="n">Operator</span>
<span class="kn">from</span> <span class="nn">agentscope.message</span> <span class="kn">import</span> <span class="n">Msg</span>
<span class="kn">from</span> <span class="nn">agentscope.models</span> <span class="kn">import</span> <span class="n">load_model_by_config_name</span>
<span class="kn">from</span> <span class="nn">agentscope.memory</span> <span class="kn">import</span> <span class="n">TemporaryMemory</span>

Expand Down Expand Up @@ -435,10 +436,33 @@ <h1>Source code for agentscope.agents.agent</h1><div class="highlight"><pre>
<a class="viewcode-back" href="../../../agentscope.agents.agent.html#agentscope.agents.AgentBase.speak">[docs]</a>
<span class="k">def</span> <span class="nf">speak</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">content</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">dict</span><span class="p">],</span>
<span class="n">content</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Msg</span><span class="p">],</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;Speak out the content generated by the agent.&quot;&quot;&quot;</span>
<span class="n">logger</span><span class="o">.</span><span class="n">chat</span><span class="p">(</span><span class="n">content</span><span class="p">)</span></div>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Speak out the message generated by the agent. If a string is given,</span>
<span class="sd"> a Msg object will be created with the string as the content.</span>

<span class="sd"> Args:</span>
<span class="sd"> content (`Union[str, Msg]`):</span>
<span class="sd"> The content of the message to be spoken out. If a string is</span>
<span class="sd"> given, a Msg object will be created with the agent&#39;s name, role</span>
<span class="sd"> as &quot;assistant&quot;, and the given string as the content.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">content</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">Msg</span><span class="p">(</span>
<span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
<span class="n">content</span><span class="o">=</span><span class="n">content</span><span class="p">,</span>
<span class="n">role</span><span class="o">=</span><span class="s2">&quot;assistant&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">content</span><span class="p">,</span> <span class="n">Msg</span><span class="p">):</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">content</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
<span class="s2">&quot;From version 0.0.5, the speak method only accepts str or Msg &quot;</span>
<span class="sa">f</span><span class="s2">&quot;object, got </span><span class="si">{</span><span class="nb">type</span><span class="p">(</span><span class="n">content</span><span class="p">)</span><span class="si">}</span><span class="s2"> instead.&quot;</span><span class="p">,</span>
<span class="p">)</span>

<span class="n">logger</span><span class="o">.</span><span class="n">chat</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span></div>


<div class="viewcode-block" id="AgentBase.observe">
Expand Down
5 changes: 5 additions & 0 deletions en/_modules/agentscope/agents/rpc_agent.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ <h1>Source code for agentscope.agents.rpc_agent</h1><div class="highlight"><pre>
<span class="p">)</span>
<span class="kn">from</span> <span class="nn">agentscope.rpc</span> <span class="kn">import</span> <span class="n">RpcAgentClient</span>
<span class="kn">from</span> <span class="nn">agentscope.server.launcher</span> <span class="kn">import</span> <span class="n">RpcAgentServerLauncher</span>
<span class="kn">from</span> <span class="nn">agentscope.studio._client</span> <span class="kn">import</span> <span class="n">_studio_client</span>


<div class="viewcode-block" id="RpcAgent">
Expand Down Expand Up @@ -174,13 +175,17 @@ <h1>Source code for agentscope.agents.rpc_agent</h1><div class="highlight"><pre>
<span class="n">launch_server</span> <span class="o">=</span> <span class="n">port</span> <span class="ow">is</span> <span class="kc">None</span>
<span class="k">if</span> <span class="n">launch_server</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="s2">&quot;localhost&quot;</span>
<span class="n">studio_url</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">if</span> <span class="n">_studio_client</span><span class="o">.</span><span class="n">active</span><span class="p">:</span>
<span class="n">studio_url</span> <span class="o">=</span> <span class="n">_studio_client</span><span class="o">.</span><span class="n">studio_url</span>
<span class="bp">self</span><span class="o">.</span><span class="n">server_launcher</span> <span class="o">=</span> <span class="n">RpcAgentServerLauncher</span><span class="p">(</span>
<span class="n">host</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">host</span><span class="p">,</span>
<span class="n">port</span><span class="o">=</span><span class="n">port</span><span class="p">,</span>
<span class="n">max_pool_size</span><span class="o">=</span><span class="n">max_pool_size</span><span class="p">,</span>
<span class="n">max_timeout_seconds</span><span class="o">=</span><span class="n">max_timeout_seconds</span><span class="p">,</span>
<span class="n">local_mode</span><span class="o">=</span><span class="n">local_mode</span><span class="p">,</span>
<span class="n">custom_agents</span><span class="o">=</span><span class="p">[</span><span class="n">agent_class</span><span class="p">],</span>
<span class="n">studio_url</span><span class="o">=</span><span class="n">studio_url</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">lazy_launch</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_launch_server</span><span class="p">()</span>
Expand Down
Loading

0 comments on commit db2018b

Please sign in to comment.