Skip to content

Commit

Permalink
deploy: 7429f3f
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jul 4, 2024
1 parent 51c2a80 commit e985049
Show file tree
Hide file tree
Showing 14 changed files with 1,021 additions and 10 deletions.
Binary file not shown.
Binary file modified .doctrees/apis/components/components.agent.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
920 changes: 920 additions & 0 deletions _modules/components/agent/react.html

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion _modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@
<article class="bd-article">

<h1>All modules for which code is available</h1>
<ul><li><a href="components/data_process/data_components.html">components.data_process.data_components</a></li>
<ul><li><a href="components/agent/react.html">components.agent.react</a></li>
<li><a href="components/data_process/data_components.html">components.data_process.data_components</a></li>
<li><a href="components/data_process/text_splitter.html">components.data_process.text_splitter</a></li>
<li><a href="components/memory/memory.html">components.memory.memory</a></li>
<li><a href="components/model_client/anthropic_client.html">components.model_client.anthropic_client</a></li>
Expand Down
71 changes: 69 additions & 2 deletions apis/components/_autosummary/components.agent.react.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@



<button class="pst-navbar-icon sidebar-toggle secondary-toggle" aria-label="On this page">
<span class="fa-solid fa-outdent"></span>
</button>

</div>

</header>
Expand Down Expand Up @@ -534,8 +538,50 @@
<div id="searchbox"></div>
<article class="bd-article">

<section id="react">
<span id="components-agent-react"></span><h1>react<a class="headerlink" href="#react" title="Link to this heading">#</a></h1>
<section id="module-components.agent.react">
<span id="react"></span><span id="components-agent-react"></span><h1>react<a class="headerlink" href="#module-components.agent.react" title="Link to this heading">#</a></h1>
<p>Implementation of ReAct.</p>
<p class="rubric">Classes</p>
<div class="pst-scrollable-table-container"><table class="autosummary longtable table autosummary">
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#components.agent.react.ReActAgent" title="components.agent.react.ReActAgent"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ReActAgent</span></code></a>([tools, max_steps, ...])</p></td>
<td><p>ReActAgent uses generator as a planner that runs multiple and sequential functional call steps to generate the final response.</p></td>
</tr>
</tbody>
</table>
</div>
<dl class="py class">
<dt class="sig sig-object py" id="components.agent.react.ReActAgent">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">ReActAgent</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">tools</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><span class="pre">Callable</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">...</span></span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Awaitable</span><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">FunctionTool</span><span class="p"><span class="pre">]</span></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">[]</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_steps</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</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">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">add_llm_as_fallback</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>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">model_client</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">ModelClient</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">model_kwargs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Dict</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">{}</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../../../_modules/components/agent/react.html#ReActAgent"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#components.agent.react.ReActAgent" title="Link to this definition">#</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">Component</span></code></p>
<p>ReActAgent uses generator as a planner that runs multiple and sequential functional call steps to generate the final response.</p>
<p>Users need to set up:
- tools: a list of tools to use to complete the task. Each tool is a function or a function tool.
- max_steps: the maximum number of steps the agent can take to complete the task.
- use_llm_as_fallback: a boolean to decide whether to use an additional LLM model as a fallback tool to answer the query.
- model_client: the model client to use to generate the response.
- model_kwargs: the model kwargs to use to generate the response.</p>
<p>For the generator, the default arguments are:
(1) default prompt: DEFAULT_REACT_AGENT_SYSTEM_PROMPT
(2) default output_processors: JsonParser</p>
<p>There are <cite>examples</cite> which is optional, a list of string examples in the prompt.</p>
<p>Example:</p>
<p>Reference:
[1] <a class="reference external" href="https://arxiv.org/abs/2210.03629">https://arxiv.org/abs/2210.03629</a>, published in Mar, 2023.</p>
<dl class="py method">
<dt class="sig sig-object py" id="components.agent.react.ReActAgent.reset">
<span class="sig-name descname"><span class="pre">reset</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../../_modules/components/agent/react.html#ReActAgent.reset"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#components.agent.react.ReActAgent.reset" title="Link to this definition">#</a></dt>
<dd><p>Reset the agent to start a new query.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="components.agent.react.ReActAgent.call">
<span class="sig-name descname"><span class="pre">call</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">input</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">promt_kwargs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Dict</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</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">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">model_kwargs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Dict</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</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">{}</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">Any</span></span></span><a class="reference internal" href="../../../_modules/components/agent/react.html#ReActAgent.call"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#components.agent.react.ReActAgent.call" title="Link to this definition">#</a></dt>
<dd><p>prompt_kwargs: additional prompt kwargs to either replace or add to the preset prompt kwargs.</p>
</dd></dl>

</dd></dl>

</section>


Expand Down Expand Up @@ -573,6 +619,27 @@



<div class="bd-sidebar-secondary bd-toc"><div class="sidebar-secondary-items sidebar-secondary__inner">


<div class="sidebar-secondary-item">
<div
id="pst-page-navigation-heading-2"
class="page-toc tocsection onthispage">
<i class="fa-solid fa-list"></i> On this page
</div>
<nav class="bd-toc-nav page-toc" aria-labelledby="pst-page-navigation-heading-2">
<ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#components.agent.react.ReActAgent"><code class="docutils literal notranslate"><span class="pre">ReActAgent</span></code></a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#components.agent.react.ReActAgent.reset"><code class="docutils literal notranslate"><span class="pre">ReActAgent.reset()</span></code></a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#components.agent.react.ReActAgent.call"><code class="docutils literal notranslate"><span class="pre">ReActAgent.call()</span></code></a></li>
</ul>
</li>
</ul>
</nav></div>

</div></div>


</div>
<footer class="bd-footer-content">
Expand Down
5 changes: 4 additions & 1 deletion apis/components/components.agent.html
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@
<h2>Overview<a class="headerlink" href="#overview" title="Link to this heading">#</a></h2>
<div class="pst-scrollable-table-container"><table class="autosummary longtable table autosummary">
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">components.agent.react</span></code></p></td>
<tr class="row-odd"><td><p><a class="reference internal" href="_autosummary/components.agent.react.html#module-components.agent.react" title="components.agent.react"><code class="xref py py-obj docutils literal notranslate"><span class="pre">components.agent.react</span></code></a></p></td>
<td><p>Implementation of ReAct.</p></td>
</tr>
</tbody>
Expand All @@ -548,6 +548,9 @@ <h2>Overview<a class="headerlink" href="#overview" title="Link to this heading">
<hr class="docutils" />
<div class="pst-scrollable-table-container"><table class="autosummary longtable table autosummary">
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">components.agent</span></code></p></td>
<td><p></p></td>
</tr>
</tbody>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apis/components/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ <h2>Output Parsers<a class="headerlink" href="#output-parsers" title="Link to th
<h2>Agent<a class="headerlink" href="#agent" title="Link to this heading">#</a></h2>
<div class="pst-scrollable-table-container"><table class="autosummary longtable table autosummary">
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">components.agent.react</span></code></p></td>
<tr class="row-odd"><td><p><a class="reference internal" href="_autosummary/components.agent.react.html#module-components.agent.react" title="components.agent.react"><code class="xref py py-obj docutils literal notranslate"><span class="pre">components.agent.react</span></code></a></p></td>
<td><p>Implementation of ReAct.</p></td>
</tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion apis/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ <h2>Components<a class="headerlink" href="#components" title="Link to this headi
<p>Functional components like model client, retriever, agent, local data processing, and output parsers are here.</p>
<div class="pst-scrollable-table-container"><table class="autosummary longtable table autosummary">
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">components.agent.react</span></code></p></td>
<tr class="row-odd"><td><p><a class="reference internal" href="components/_autosummary/components.agent.react.html#module-components.agent.react" title="components.agent.react"><code class="xref py py-obj docutils literal notranslate"><span class="pre">components.agent.react</span></code></a></p></td>
<td><p>Implementation of ReAct.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="components/_autosummary/components.model_client.anthropic_client.html#module-components.model_client.anthropic_client" title="components.model_client.anthropic_client"><code class="xref py py-obj docutils literal notranslate"><span class="pre">components.model_client.anthropic_client</span></code></a></p></td>
Expand Down
2 changes: 1 addition & 1 deletion developer_notes/react_agent_xy.html
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ <h2>LightRAG’s Implementation<a class="headerlink" href="#lightrag-s-implement
</pre></div>
</div>
<p>The agent will then call these external functions based on the function descriptions.
In addition to user-defined tools, the <code class="xref py py-class docutils literal notranslate"><span class="pre">ReActAgent</span></code> built-in <code class="docutils literal notranslate"><span class="pre">llm_tool</span></code>
In addition to user-defined tools, the <a class="reference internal" href="../apis/components/_autosummary/components.agent.react.html#components.agent.react.ReActAgent" title="components.agent.react.ReActAgent"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReActAgent</span></code></a> built-in <code class="docutils literal notranslate"><span class="pre">llm_tool</span></code>
for leveraging LLM’s internal knowledge, and <code class="docutils literal notranslate"><span class="pre">finish</span></code> for completing processes. <code class="docutils literal notranslate"><span class="pre">llm_tool</span></code> uses the same model with the agent. Developers have the flexibility to enable or disable these as needed.</p>
<ol class="arabic simple" start="3">
<li><p><strong>Output Parser:</strong> <code class="docutils literal notranslate"><span class="pre">LightRAG</span></code> requests the model to output intermediate Thought and Action as JSON, which facilitates better error handling and easier data manipulation than strings. For example,</p></li>
Expand Down
19 changes: 17 additions & 2 deletions genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ <h2 id="C">C</h2>
<li><a href="apis/core/core.prompt_builder.html#core.prompt_builder.Prompt.call">(Prompt method)</a>
</li>
<li><a href="apis/optim/optim.sampler.html#optim.sampler.RandomSampler.call">(RandomSampler method)</a>
</li>
<li><a href="apis/components/_autosummary/components.agent.react.html#components.agent.react.ReActAgent.call">(ReActAgent method)</a>
</li>
<li><a href="apis/components/_autosummary/components.retriever.reranker_retriever.html#components.retriever.reranker_retriever.RerankerRetriever.call">(RerankerRetriever method)</a>
</li>
Expand Down Expand Up @@ -602,6 +604,13 @@ <h2 id="C">C</h2>
<li><a href="apis/core/core.component.html#core.component.Component.components">components() (Component method)</a>
</li>
<li>
components.agent.react

<ul>
<li><a href="apis/components/_autosummary/components.agent.react.html#module-components.agent.react">module</a>
</li>
</ul></li>
<li>
components.data_process.data_components

<ul>
Expand Down Expand Up @@ -664,15 +673,15 @@ <h2 id="C">C</h2>
<li><a href="apis/components/_autosummary/components.model_client.utils.html#module-components.model_client.utils">module</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li>
components.output_parsers.outputs

<ul>
<li><a href="apis/components/_autosummary/components.output_parsers.outputs.html#module-components.output_parsers.outputs">module</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li>
components.reasoning.chain_of_thought

Expand Down Expand Up @@ -1447,6 +1456,8 @@ <h2 id="M">M</h2>
module

<ul>
<li><a href="apis/components/_autosummary/components.agent.react.html#module-components.agent.react">components.agent.react</a>
</li>
<li><a href="apis/components/_autosummary/components.data_process.data_components.html#module-components.data_process.data_components">components.data_process.data_components</a>
</li>
<li><a href="apis/components/_autosummary/components.data_process.text_splitter.html#module-components.data_process.text_splitter">components.data_process.text_splitter</a>
Expand Down Expand Up @@ -1771,6 +1782,8 @@ <h2 id="R">R</h2>
<li><a href="apis/core/core.types.html#core.types.GeneratorOutput.raw_response">(GeneratorOutput attribute)</a>
</li>
</ul></li>
<li><a href="apis/components/_autosummary/components.agent.react.html#components.agent.react.ReActAgent">ReActAgent (class in components.agent.react)</a>
</li>
<li><a href="apis/utils/utils.registry.html#utils.registry.EntityMapping.register">register() (EntityMapping class method)</a>
</li>
<li><a href="apis/core/core.component.html#core.component.Component.register_component">register_component() (Component method)</a>
Expand All @@ -1797,6 +1810,8 @@ <h2 id="R">R</h2>
<li><a href="apis/optim/optim.llm_optimizer.html#optim.llm_optimizer.LLMOptimizer.reset">(LLMOptimizer method)</a>
</li>
<li><a href="apis/core/core.db.html#core.db.LocalDB.reset">(LocalDB method)</a>
</li>
<li><a href="apis/components/_autosummary/components.agent.react.html#components.agent.react.ReActAgent.reset">(ReActAgent method)</a>
</li>
</ul></li>
<li><a href="apis/components/_autosummary/components.retriever.bm25_retriever.html#components.retriever.bm25_retriever.BM25Retriever.reset_index">reset_index() (BM25Retriever method)</a>
Expand Down
Binary file modified objects.inv
Binary file not shown.
5 changes: 5 additions & 0 deletions py-modindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ <h1>Python Module Index</h1>
<td>
<code class="xref">components</code></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&#160;&#160;&#160;
<a href="apis/components/_autosummary/components.agent.react.html#module-components.agent.react"><code class="xref">components.agent.react</code></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&#160;&#160;&#160;
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit e985049

Please sign in to comment.