Skip to content

Commit

Permalink
docs: ReAct reference (#22830)
Browse files Browse the repository at this point in the history
The `ReAct` is used all across LangChain but it is not referenced
properly.
Added references to the original paper.
  • Loading branch information
leo-gan authored and hinthornw committed Jun 20, 2024
1 parent aae831f commit b8d3050
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 12 deletions.
52 changes: 44 additions & 8 deletions docs/docs/additional_resources/arxiv_references.mdx

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion docs/docs/integrations/chat/huggingface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@
"source": [
"## 4. Take it for a spin as an agent!\n",
"\n",
"Here we'll test out `Zephyr-7B-beta` as a zero-shot `ReAct` Agent. The example below is taken from [here](https://python.langchain.com/v0.1/docs/modules/agents/agent_types/react/#using-chat-models).\n",
"Here we'll test out `Zephyr-7B-beta` as a zero-shot `ReAct` Agent. \n",
"\n",
"The agent is based on the paper [ReAct: Synergizing Reasoning and Acting in Language Models](https://arxiv.org/abs/2210.03629)\n",
"\n",
"The example below is taken from [here](https://python.langchain.com/v0.1/docs/modules/agents/agent_types/react/#using-chat-models).\n",
"\n",
"> Note: To run this section, you'll need to have a [SerpAPI Token](https://serpapi.com/) saved as an environment variable: `SERPAPI_API_KEY`"
]
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/integrations/providers/cohere.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ print(llm.invoke("Come up with a pet name"))
Usage of the Cohere (legacy) [LLM model](/docs/integrations/llms/cohere)
### ReAct Agent

The agent is based on the paper
[ReAct: Synergizing Reasoning and Acting in Language Models](https://arxiv.org/abs/2210.03629).

```python
from langchain_community.tools.tavily_search import TavilySearchResults
from langchain_cohere import ChatCohere, create_cohere_react_agent
Expand Down
16 changes: 13 additions & 3 deletions docs/docs/integrations/tools/ionic_shopping.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"\n",
"# Based on ReAct Agent\n",
"# https://python.langchain.com/docs/modules/agents/agent_types/react\n",
"# See the paper \"ReAct: Synergizing Reasoning and Acting in Language Models\" (https://arxiv.org/abs/2210.03629)\n",
"# Please reach out to [email protected] for help with add'l agent types.\n",
"\n",
"open_ai_key = \"YOUR KEY HERE\"\n",
Expand Down Expand Up @@ -168,14 +169,23 @@
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"version": "3.11.4"
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 4
}
3 changes: 3 additions & 0 deletions libs/langchain/langchain/agents/react/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def create_react_agent(
) -> Runnable:
"""Create an agent that uses ReAct prompting.
Based on paper "ReAct: Synergizing Reasoning and Acting in Language Models"
(https://arxiv.org/abs/2210.03629)
Args:
llm: LLM to use as the agent.
tools: Tools this agent has access to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class TrajectoryEvalChain(AgentTrajectoryEvaluator, LLMEvalChain):
This chain is used to evaluate ReAct style agents by reasoning about
the sequence of actions taken and their outcomes.
Based on the paper "ReAct: Synergizing Reasoning and Acting in Language Models"
(https://arxiv.org/abs/2210.03629)
Example:
Expand Down

0 comments on commit b8d3050

Please sign in to comment.