Skip to content

Commit

Permalink
deploy: 4b15630
Browse files Browse the repository at this point in the history
  • Loading branch information
DavdGao committed May 15, 2024
1 parent 925b74b commit aec240a
Show file tree
Hide file tree
Showing 84 changed files with 4,006 additions and 536 deletions.
Binary file modified en/.doctrees/agentscope.agents.dict_dialog_agent.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.agents.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.message.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.parsers.code_block_parser.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.parsers.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.parsers.json_object_parser.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.parsers.parser_base.doctree
Binary file not shown.
Binary file modified en/.doctrees/agentscope.parsers.tagged_content_parser.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.
Binary file added en/.doctrees/tutorial/203-parser.doctree
Binary file not shown.
Binary file modified en/.doctrees/tutorial/advance.doctree
Binary file not shown.
143 changes: 36 additions & 107 deletions en/_modules/agentscope/agents/dict_dialog_agent.html

Large diffs are not rendered by default.

31 changes: 18 additions & 13 deletions en/_modules/agentscope/agents/react_agent.html
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ <h1>Source code for agentscope.agents.react_agent</h1><div class="highlight"><pr
<span class="s2">&quot;function&quot;</span><span class="p">:</span> <span class="n">service_toolkit</span><span class="o">.</span><span class="n">tools_calling_format</span><span class="p">,</span>
<span class="p">},</span>
<span class="n">required_keys</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;thought&quot;</span><span class="p">,</span> <span class="s2">&quot;speak&quot;</span><span class="p">,</span> <span class="s2">&quot;function&quot;</span><span class="p">],</span>
<span class="c1"># Only print the speak field when verbose is False</span>
<span class="n">keys_to_content</span><span class="o">=</span><span class="kc">True</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">verbose</span> <span class="k">else</span> <span class="s2">&quot;speak&quot;</span><span class="p">,</span>
<span class="p">)</span></div>


Expand All @@ -261,9 +263,8 @@ <h1>Source code for agentscope.agents.react_agent</h1><div class="highlight"><pr
<span class="s2">&quot;system&quot;</span><span class="p">,</span>
<span class="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">format_instruction</span><span class="p">,</span>
<span class="n">role</span><span class="o">=</span><span class="s2">&quot;system&quot;</span><span class="p">,</span>
<span class="n">echo</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">verbose</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">verbose</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">speak</span><span class="p">(</span><span class="n">hint_msg</span><span class="p">)</span>

<span class="c1"># Prepare prompt for the model</span>
<span class="n">prompt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">model</span><span class="o">.</span><span class="n">format</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">get_memory</span><span class="p">(),</span> <span class="n">hint_msg</span><span class="p">)</span>
Expand All @@ -277,16 +278,21 @@ <h1>Source code for agentscope.agents.react_agent</h1><div class="highlight"><pr
<span class="p">)</span>

<span class="c1"># Record the response in memory</span>
<span class="n">msg_response</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">res</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="s2">&quot;assistant&quot;</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">add</span><span class="p">(</span><span class="n">msg_response</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">add</span><span class="p">(</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="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">to_memory</span><span class="p">(</span><span class="n">res</span><span class="o">.</span><span class="n">parsed</span><span class="p">),</span>
<span class="s2">&quot;assistant&quot;</span><span class="p">,</span>
<span class="p">),</span>
<span class="p">)</span>

<span class="c1"># Print out the response</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">verbose</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">speak</span><span class="p">(</span><span class="n">msg_response</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">speak</span><span class="p">(</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">res</span><span class="o">.</span><span class="n">parsed</span><span class="p">[</span><span class="s2">&quot;speak&quot;</span><span class="p">],</span> <span class="s2">&quot;assistant&quot;</span><span class="p">),</span>
<span class="p">)</span>
<span class="n">msg_returned</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="bp">self</span><span class="o">.</span><span class="n">parser</span><span class="o">.</span><span class="n">to_content</span><span class="p">(</span><span class="n">res</span><span class="o">.</span><span class="n">parsed</span><span class="p">),</span>
<span class="s2">&quot;assistant&quot;</span><span class="p">,</span>
<span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">speak</span><span class="p">(</span><span class="n">msg_returned</span><span class="p">)</span>

<span class="c1"># Skip the next steps if no need to call tools</span>
<span class="c1"># The parsed field is a dictionary</span>
Expand All @@ -298,7 +304,7 @@ <h1>Source code for agentscope.agents.react_agent</h1><div class="highlight"><pr
<span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">arg_function</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span>
<span class="p">):</span>
<span class="c1"># Only the speak field is exposed to users or other agents</span>
<span class="k">return</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">res</span><span class="o">.</span><span class="n">parsed</span><span class="p">[</span><span class="s2">&quot;speak&quot;</span><span class="p">],</span> <span class="s2">&quot;assistant&quot;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">msg_returned</span>

<span class="c1"># Only catch the response parsing error and expose runtime</span>
<span class="c1"># errors to developers for debugging</span>
Expand Down Expand Up @@ -350,9 +356,8 @@ <h1>Source code for agentscope.agents.react_agent</h1><div class="highlight"><pr
<span class="s2">&quot;iterations. Now generate a reply by summarizing the current &quot;</span>
<span class="s2">&quot;situation.&quot;</span><span class="p">,</span>
<span class="n">role</span><span class="o">=</span><span class="s2">&quot;system&quot;</span><span class="p">,</span>
<span class="n">echo</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">verbose</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">verbose</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">speak</span><span class="p">(</span><span class="n">hint_msg</span><span class="p">)</span>

<span class="c1"># Generate a reply by summarizing the current situation</span>
<span class="n">prompt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">model</span><span class="o">.</span><span class="n">format</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">get_memory</span><span class="p">(),</span> <span class="n">hint_msg</span><span class="p">)</span>
Expand Down
29 changes: 29 additions & 0 deletions en/_modules/agentscope/message.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,28 @@ <h1>Source code for agentscope.message</h1><div class="highlight"><pre>
<span class="k">class</span> <span class="nc">Msg</span><span class="p">(</span><span class="n">MessageBase</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;The Message class.&quot;&quot;&quot;</span>

<span class="nb">id</span><span class="p">:</span> <span class="nb">str</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;The id of the message.&quot;&quot;&quot;</span>

<span class="n">name</span><span class="p">:</span> <span class="nb">str</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;The name of who send the message.&quot;&quot;&quot;</span>

<span class="n">content</span><span class="p">:</span> <span class="n">Any</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;The content of the message.&quot;&quot;&quot;</span>

<span class="n">role</span><span class="p">:</span> <span class="n">Literal</span><span class="p">[</span><span class="s2">&quot;system&quot;</span><span class="p">,</span> <span class="s2">&quot;user&quot;</span><span class="p">,</span> <span class="s2">&quot;assistant&quot;</span><span class="p">]</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;The role of the message sender.&quot;&quot;&quot;</span>

<span class="n">metadata</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="w"> </span><span class="sd">&quot;&quot;&quot;Save the information for application&#39;s control flow, or other</span>
<span class="sd"> purposes.&quot;&quot;&quot;</span>

<span class="n">url</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">Sequence</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span> <span class="nb">str</span><span class="p">]]</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;A url to file, image, video, audio or website.&quot;&quot;&quot;</span>

<span class="n">timestamp</span><span class="p">:</span> <span class="nb">str</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;The timestamp of the message.&quot;&quot;&quot;</span>

<div class="viewcode-block" id="Msg.__init__">
<a class="viewcode-back" href="../../agentscope.message.html#agentscope.message.Msg.__init__">[docs]</a>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
Expand All @@ -214,6 +236,7 @@ <h1>Source code for agentscope.message</h1><div class="highlight"><pre>
<span class="n">url</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">Sequence</span><span class="p">[</span><span class="nb">str</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">timestamp</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">echo</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">metadata</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">dict</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="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="n">Any</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;Initialize the message object</span>
Expand All @@ -232,6 +255,11 @@ <h1>Source code for agentscope.message</h1><div class="highlight"><pre>
<span class="sd"> timestamp (`Optional[str]`, defaults to `None`):</span>
<span class="sd"> The timestamp of the message, if None, it will be set to</span>
<span class="sd"> current time.</span>
<span class="sd"> echo (`bool`, defaults to `False`):</span>
<span class="sd"> Whether to print the message to the console.</span>
<span class="sd"> metadata (`Optional[Union[dict, str]]`, defaults to `None`):</span>
<span class="sd"> Save the information for application&#39;s control flow, or other</span>
<span class="sd"> purposes.</span>
<span class="sd"> **kwargs (`Any`):</span>
<span class="sd"> Other attributes of the message.</span>
<span class="sd"> &quot;&quot;&quot;</span>
Expand All @@ -249,6 +277,7 @@ <h1>Source code for agentscope.message</h1><div class="highlight"><pre>
<span class="n">role</span><span class="o">=</span><span class="n">role</span> <span class="ow">or</span> <span class="s2">&quot;assistant&quot;</span><span class="p">,</span>
<span class="n">url</span><span class="o">=</span><span class="n">url</span><span class="p">,</span>
<span class="n">timestamp</span><span class="o">=</span><span class="n">timestamp</span><span class="p">,</span>
<span class="n">metadata</span><span class="o">=</span><span class="n">metadata</span><span class="p">,</span>
<span class="o">**</span><span class="n">kwargs</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">if</span> <span class="n">echo</span><span class="p">:</span>
Expand Down
Loading

0 comments on commit aec240a

Please sign in to comment.