You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This template showcases a [ReAct agent](https://arxiv.org/abs/2210.03629) implemented using [LangGraph](https://github.com/langchain-ai/langgraph), designed for [LangGraph Studio](https://github.com/langchain-ai/langgraph-studio). ReAct agents are uncomplicated, prototypical agents that can be flexibly extended to many tools.
6
+
This template demonstrates a simple chatbot implemented using [LangGraph](https://github.com/langchain-ai/langgraph), designed for [LangGraph Studio](https://github.com/langchain-ai/langgraph-studio). The chatbot maintains persistent chat memory, allowing for coherent conversations across multiple interactions.
7
7
8
8

9
9
10
-
The core logic, defined in `src/react_agent/graph.py`, demonstrates a flexible ReAct agent that iteratively reasons about user queries and executes actions, showcasing the power of this approach for complex problem-solving tasks.
10
+
The core logic, defined in `src/agent/graph.py`, showcases a straightforward chatbot that responds to user queries while maintaining context from previous messages.
11
11
12
12
## What it does
13
13
14
-
The ReAct agent:
14
+
The simple chatbot:
15
15
16
-
1. Takes a user **query** as input
17
-
2. Reasons about the query and decides on an action
18
-
3. Executes the chosen action using available tools
19
-
4. Observes the result of the action
20
-
5. Repeats steps 2-4 until it can provide a final answer
16
+
1. Takes a user **message** as input
17
+
2. Maintains a history of the conversation
18
+
3. Generates a response based on the current message and conversation history
19
+
4. Updates the conversation history with the new interaction
21
20
22
-
By default, it's set up with a basic set of tools, but can be easily extended with custom tools to suit various use cases.
21
+
This template provides a foundation that can be easily customized and extended to create more complex conversational agents.
23
22
24
23
## Getting Started
25
24
@@ -33,8 +32,6 @@ cp .env.example .env
33
32
34
33
2. Define required API keys in your `.env` file.
35
34
36
-
The primary [search tool](./src/react_agent/tools.py)[^1] used is [Tavily](https://tavily.com/). Create an API key [here](https://app.tavily.com/sign-in).
37
-
38
35
<!--
39
36
Setup instruction auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
40
37
-->
@@ -45,29 +42,34 @@ Set up your LLM API keys. This repo defaults to using [Claude](https://console.a
45
42
End setup instructions
46
43
-->
47
44
48
-
3. Customize whatever you'd like in the code.
49
-
4. Open the folder LangGraph Studio!
45
+
3. Customize the code as needed.
46
+
4. Open the folder in LangGraph Studio!
50
47
51
48
## How to customize
52
49
53
-
1.**Add new tools**: Extend the agent's capabilities by adding new tools in [tools.py](./src/react_agent/tools.py). These can be any Python functions that perform specific tasks.
50
+
1.**Modify the system prompt**: The default system prompt is defined in [configuration.py](./src/agent/configuration.py). You can easily update this via configuration in the studio to change the chatbot's personality or behavior.
54
51
2.**Select a different model**: We default to Anthropic's Claude 3 Sonnet. You can select a compatible chat model using `provider/model-name` via configuration. Example: `openai/gpt-4-turbo-preview`.
55
-
3.**Customize the prompt**: We provide a default system prompt in [configuration.py](./src/react_agent/configuration.py). You can easily update this via configuration in the studio.
52
+
3.**Extend the graph**: The core logic of the chatbot is defined in [graph.py](./src/agent/graph.py). You can modify this file to add new nodes, edges, or change the flow of the conversation.
56
53
57
54
You can also quickly extend this template by:
58
55
59
-
- Modifying the agent's reasoning process in [graph.py](./src/react_agent/graph.py).
60
-
- Adjusting the ReAct loop or adding additional steps to the agent's decision-making process.
56
+
- Adding custom tools or functions to enhance the chatbot's capabilities.
57
+
- Implementing additional logic for handling specific types of user queries or tasks.
58
+
- Integrating external APIs or databases to provide more dynamic responses.
61
59
62
60
## Development
63
61
64
-
While iterating on your graph, you can edit past state and rerun your app from past states to debug specific nodes. Local changes will be automatically applied via hot reload. Try adding an interrupt before the agent calls tools, updating the default system message in `src/react_agent/configuration.py` to take on a persona, or adding additional nodes and edges!
62
+
While iterating on your graph, you can edit past state and rerun your app from previous states to debug specific nodes. Local changes will be automatically applied via hot reload. Try experimenting with:
63
+
64
+
- Modifying the system prompt to give your chatbot a unique personality.
65
+
- Adding new nodes to the graph for more complex conversation flows.
66
+
- Implementing conditional logic to handle different types of user inputs.
65
67
66
-
Followup requests will be appended to the same thread. You can create an entirely new thread, clearing previous history, using the `+` button in the top right.
68
+
Follow-up requests will be appended to the same thread. You can create an entirely new thread, clearing previous history, using the `+` button in the top right.
67
69
68
-
You can find the latest (under construction) docs on[LangGraph](https://github.com/langchain-ai/langgraph) here, including examples and other references. Using those guides can help you pick the right patterns to adapt here for your use case.
70
+
For more advanced features and examples, refer to the[LangGraph documentation](https://github.com/langchain-ai/langgraph). These resources can help you adapt this template for your specific use case and build more sophisticated conversational agents.
69
71
70
-
LangGraph Studio also integrates with [LangSmith](https://smith.langchain.com/) for more in-depth tracing and collaboration with teammates.
72
+
LangGraph Studio also integrates with [LangSmith](https://smith.langchain.com/) for more in-depth tracing and collaboration with teammates, allowing you to analyze and optimize your chatbot's performance.
71
73
72
74
<!--
73
75
Configuration auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
@@ -78,7 +80,7 @@ Configuration auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
78
80
"properties": {
79
81
"system_prompt": {
80
82
"type": "string",
81
-
"default": "You are a helpful AI assistant.\n\nSystem time: {system_time}"
83
+
"default": "You are a helpful (if not sassy) personal assistant.\n\nSystem time: {system_time}"
82
84
},
83
85
"model_name": {
84
86
"type": "string",
@@ -265,199 +267,9 @@ Configuration auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
0 commit comments