Skip to content

Commit

Permalink
deploy: 981ae7c
Browse files Browse the repository at this point in the history
  • Loading branch information
DavdGao committed Feb 19, 2024
1 parent 5ef6bfb commit 0ece848
Show file tree
Hide file tree
Showing 92 changed files with 1,058 additions and 1,091 deletions.
27 changes: 8 additions & 19 deletions _modules/agentscope/agents/agent.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
<p class="caption" role="heading"><span class="caption-text">AgentScope API Reference</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../agentscope.agents.html">Agents package</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../agentscope.configs.html">Configs package</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../agentscope.memory.html">Memory package</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../agentscope.models.html">Models package</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../agentscope.pipelines.html">Pipelines package</a></li>
Expand Down Expand Up @@ -97,11 +96,10 @@ <h1>Source code for agentscope.agents.agent</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Sequence</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Union</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Any</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Callable</span>
<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.models</span> <span class="kn">import</span> <span class="n">load_model_by_name</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 All @@ -128,9 +126,8 @@ <h1>Source code for agentscope.agents.agent</h1><div class="highlight"><pre>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">config</span><span class="p">:</span> <span class="n">Optional</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">sys_prompt</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">model</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="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="n">Any</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">model_config_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">use_memory</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">memory_config</span><span class="p">:</span> <span class="n">Optional</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="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
Expand All @@ -139,35 +136,27 @@ <h1>Source code for agentscope.agents.agent</h1><div class="highlight"><pre>
<span class="sd"> Args:</span>
<span class="sd"> name (`str`):</span>
<span class="sd"> The name of the agent.</span>
<span class="sd"> config (`Optional[dict]`):</span>
<span class="sd"> The configuration of the agent, if provided, the agent will</span>
<span class="sd"> be initialized from the config rather than the other</span>
<span class="sd"> parameters.</span>
<span class="sd"> sys_prompt (`Optional[str]`):</span>
<span class="sd"> The system prompt of the agent, which can be passed by args</span>
<span class="sd"> or hard-coded in the agent.</span>
<span class="sd"> model (`Optional[Union[Callable[..., Any], str]]`, defaults to</span>
<span class="sd"> None):</span>
<span class="sd"> The callable model object or the model name, which is used to</span>
<span class="sd"> load model from configuration.</span>
<span class="sd"> model_config_name (`str`, defaults to None):</span>
<span class="sd"> The name of the model config, which is used to load model from</span>
<span class="sd"> configuration.</span>
<span class="sd"> use_memory (`bool`, defaults to `True`):</span>
<span class="sd"> Whether the agent has memory.</span>
<span class="sd"> memory_config (`Optional[dict]`):</span>
<span class="sd"> The config of memory.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">name</span>
<span class="bp">self</span><span class="o">.</span><span class="n">config</span> <span class="o">=</span> <span class="n">config</span>
<span class="bp">self</span><span class="o">.</span><span class="n">memory_config</span> <span class="o">=</span> <span class="n">memory_config</span>

<span class="k">if</span> <span class="n">sys_prompt</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">sys_prompt</span> <span class="o">=</span> <span class="n">sys_prompt</span>

<span class="k">if</span> <span class="n">model</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">model</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">model</span> <span class="o">=</span> <span class="n">load_model_by_name</span><span class="p">(</span><span class="n">model</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">model</span> <span class="o">=</span> <span class="n">model</span>
<span class="c1"># TODO: support to receive a ModelWrapper instance</span>
<span class="k">if</span> <span class="n">model_config_name</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">model</span> <span class="o">=</span> <span class="n">load_model_by_config_name</span><span class="p">(</span><span class="n">model_config_name</span><span class="p">)</span>

<span class="k">if</span> <span class="n">use_memory</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">memory</span> <span class="o">=</span> <span class="n">TemporaryMemory</span><span class="p">(</span><span class="n">memory_config</span><span class="p">)</span>
Expand Down
30 changes: 11 additions & 19 deletions _modules/agentscope/agents/dialog_agent.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
<p class="caption" role="heading"><span class="caption-text">AgentScope API Reference</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../agentscope.agents.html">Agents package</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../agentscope.configs.html">Configs package</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../agentscope.memory.html">Memory package</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../agentscope.models.html">Models package</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../agentscope.pipelines.html">Pipelines package</a></li>
Expand Down Expand Up @@ -90,7 +89,7 @@
<h1>Source code for agentscope.agents.dialog_agent</h1><div class="highlight"><pre>
<span></span><span class="c1"># -*- coding: utf-8 -*-</span>
<span class="sd">&quot;&quot;&quot;A general dialog agent.&quot;&quot;&quot;</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Any</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="n">Callable</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Optional</span>

<span class="kn">from</span> <span class="nn">..message</span> <span class="kn">import</span> <span class="n">Msg</span>
<span class="kn">from</span> <span class="nn">.agent</span> <span class="kn">import</span> <span class="n">AgentBase</span>
Expand All @@ -107,9 +106,8 @@ <h1>Source code for agentscope.agents.dialog_agent</h1><div class="highlight"><p
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">config</span><span class="p">:</span> <span class="n">Optional</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">sys_prompt</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">model</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="n">Callable</span><span class="p">[</span><span class="o">...</span><span class="p">,</span> <span class="n">Any</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">model_config_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">use_memory</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">memory_config</span><span class="p">:</span> <span class="n">Optional</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">prompt_type</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">PromptType</span><span class="p">]</span> <span class="o">=</span> <span class="n">PromptType</span><span class="o">.</span><span class="n">LIST</span><span class="p">,</span>
Expand All @@ -119,17 +117,12 @@ <h1>Source code for agentscope.agents.dialog_agent</h1><div class="highlight"><p
<span class="sd"> Arguments:</span>
<span class="sd"> name (`str`):</span>
<span class="sd"> The name of the agent.</span>
<span class="sd"> config (`Optional[dict]`):</span>
<span class="sd"> The configuration of the agent, if provided, the agent will</span>
<span class="sd"> be initialized from the config rather than the other</span>
<span class="sd"> parameters.</span>
<span class="sd"> sys_prompt (`Optional[str]`):</span>
<span class="sd"> The system prompt of the agent, which can be passed by args</span>
<span class="sd"> or hard-coded in the agent.</span>
<span class="sd"> model (`Optional[Union[Callable[..., Any], str]]`, defaults to</span>
<span class="sd"> None):</span>
<span class="sd"> The callable model object or the model name, which is used to</span>
<span class="sd"> load model from configuration.</span>
<span class="sd"> model_config_name (`str`, defaults to None):</span>
<span class="sd"> The name of the model config, which is used to load model from</span>
<span class="sd"> configuration.</span>
<span class="sd"> use_memory (`bool`, defaults to `True`):</span>
<span class="sd"> Whether the agent has memory.</span>
<span class="sd"> memory_config (`Optional[dict]`):</span>
Expand All @@ -140,12 +133,11 @@ <h1>Source code for agentscope.agents.dialog_agent</h1><div class="highlight"><p
<span class="sd"> `PromptType.LIST` or `PromptType.STRING`.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
<span class="n">name</span><span class="p">,</span>
<span class="n">config</span><span class="p">,</span>
<span class="n">sys_prompt</span><span class="p">,</span>
<span class="n">model</span><span class="p">,</span>
<span class="n">use_memory</span><span class="p">,</span>
<span class="n">memory_config</span><span class="p">,</span>
<span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span>
<span class="n">sys_prompt</span><span class="o">=</span><span class="n">sys_prompt</span><span class="p">,</span>
<span class="n">model_config_name</span><span class="o">=</span><span class="n">model_config_name</span><span class="p">,</span>
<span class="n">use_memory</span><span class="o">=</span><span class="n">use_memory</span><span class="p">,</span>
<span class="n">memory_config</span><span class="o">=</span><span class="n">memory_config</span><span class="p">,</span>
<span class="p">)</span>

<span class="c1"># init prompt engine</span>
Expand Down Expand Up @@ -179,7 +171,7 @@ <h1>Source code for agentscope.agents.dialog_agent</h1><div class="highlight"><p
<span class="p">)</span>

<span class="c1"># call llm and generate response</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">model</span><span class="p">(</span><span class="n">prompt</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">model</span><span class="p">(</span><span class="n">prompt</span><span class="p">)</span><span class="o">.</span><span class="n">text</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">Msg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">response</span><span class="p">)</span>

<span class="c1"># Print/speak the message in this agent&#39;s voice</span>
Expand Down
Loading

0 comments on commit 0ece848

Please sign in to comment.