Skip to content

Commit 467365a

Browse files
committed
Setup New Project template
(Remove react agent code)
2 parents 523dc46 + 609708e commit 467365a

File tree

20 files changed

+226
-580
lines changed

20 files changed

+226
-580
lines changed

.env.example

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
TAVILY_API_KEY=...
2-
31
# To separate your traces from other application
4-
LANGSMITH_PROJECT=retrieval-agent
2+
LANGSMITH_PROJECT=new-agent
53

64
# The following depend on your selected configuration
75

.github/workflows/integration-tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ jobs:
3636
- name: Run integration tests
3737
env:
3838
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
39-
TAVILY_API_KEY: ${{ secrets.TAVILY_API_KEY }}
4039
LANGSMITH_API_KEY: ${{ secrets.LANGSMITH_API_KEY }}
4140
LANGSMITH_TRACING: true
4241
run: |

README.md

Lines changed: 72 additions & 217 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
# LangGraph ReAct Agent Template
1+
# LangGraph Simple Chatbot Template
22

3-
[![CI](https://github.com/langchain-ai/react-agent/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/langchain-ai/react-agent/actions/workflows/unit-tests.yml)
4-
[![Integration Tests](https://github.com/langchain-ai/react-agent/actions/workflows/integration-tests.yml/badge.svg)](https://github.com/langchain-ai/react-agent/actions/workflows/integration-tests.yml)
3+
[![CI](https://github.com/langchain-ai/new-langgraph-project/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/langchain-ai/new-langgraph-project/actions/workflows/unit-tests.yml)
4+
[![Integration Tests](https://github.com/langchain-ai/new-langgraph-project/actions/workflows/integration-tests.yml/badge.svg)](https://github.com/langchain-ai/new-langgraph-project/actions/workflows/integration-tests.yml)
55

6-
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.
77

88
![Graph view in LangGraph studio UI](./static/studio_ui.png)
99

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.
1111

1212
## What it does
1313

14-
The ReAct agent:
14+
The simple chatbot:
1515

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
2120

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.
2322

2423
## Getting Started
2524

@@ -33,41 +32,87 @@ cp .env.example .env
3332

3433
2. Define required API keys in your `.env` file.
3534

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-
3835
<!--
3936
Setup instruction auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
4037
-->
4138

42-
Set up your LLM API keys. This repo defaults to using [Claude](https://console.anthropic.com/login).
39+
<details>
40+
<summary>Setup for `model_name`</summary>
41+
The `llm` configuration defaults are shown below:
42+
43+
```yaml
44+
model_name: anthropic/claude-3-5-sonnet-20240620
45+
```
46+
47+
Follow the instructions below to get set up, or pick one of the additional options.
48+
49+
### Anthropic Chat Models
50+
51+
To use Anthropic's chat models:
52+
53+
1. Sign up for an [Anthropic API key](https://console.anthropic.com/) if you haven't already.
54+
2. Once you have your API key, add it to your `.env` file:
55+
56+
```
57+
ANTHROPIC_API_KEY=your-api-key
58+
```
59+
### Fireworks Chat Models
60+
61+
To use Fireworks AI's chat models:
62+
63+
1. Sign up for a [Fireworks AI account](https://app.fireworks.ai/signup) and obtain an API key.
64+
2. Add your Fireworks AI API key to your `.env` file:
65+
66+
```
67+
FIREWORKS_API_KEY=your-api-key
68+
```
69+
#### OpenAI Chat Models
70+
71+
To use OpenAI's chat models:
72+
73+
1. Sign up for an [OpenAI API key](https://platform.openai.com/signup).
74+
2. Once you have your API key, add it to your `.env` file:
75+
```
76+
OPENAI_API_KEY=your-api-key
77+
```
78+
79+
</details>
80+
81+
4382
4483
<!--
4584
End setup instructions
4685
-->
4786
48-
3. Customize whatever you'd like in the code.
49-
4. Open the folder LangGraph Studio!
87+
88+
3. Customize the code as needed.
89+
4. Open the folder in LangGraph Studio!
5090
5191
## How to customize
5292
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.
93+
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.
5494
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.
95+
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.
5696
5797
You can also quickly extend this template by:
5898
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.
99+
- Adding custom tools or functions to enhance the chatbot's capabilities.
100+
- Implementing additional logic for handling specific types of user queries or tasks.
101+
- Integrating external APIs or databases to provide more dynamic responses.
61102
62103
## Development
63104
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!
105+
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:
106+
107+
- Modifying the system prompt to give your chatbot a unique personality.
108+
- Adding new nodes to the graph for more complex conversation flows.
109+
- Implementing conditional logic to handle different types of user inputs.
65110
66-
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.
111+
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.
67112
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.
113+
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.
69114
70-
LangGraph Studio also integrates with [LangSmith](https://smith.langchain.com/) for more in-depth tracing and collaboration with teammates.
115+
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.
71116
72117
<!--
73118
Configuration auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
@@ -78,7 +123,7 @@ Configuration auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
78123
"properties": {
79124
"system_prompt": {
80125
"type": "string",
81-
"default": "You are a helpful AI assistant.\n\nSystem time: {system_time}"
126+
"default": "You are a helpful (if not sassy) personal assistant.\n\nSystem time: {system_time}"
82127
},
83128
"model_name": {
84129
"type": "string",
@@ -265,199 +310,9 @@ Configuration auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
265310
"variables": "OPENAI_API_KEY"
266311
}
267312
]
268-
},
269-
"scraper_tool_model_name": {
270-
"type": "string",
271-
"default": "accounts/fireworks/models/firefunction-v2",
272-
"environment": [
273-
{
274-
"value": "anthropic/claude-1.2",
275-
"variables": "ANTHROPIC_API_KEY"
276-
},
277-
{
278-
"value": "anthropic/claude-2.0",
279-
"variables": "ANTHROPIC_API_KEY"
280-
},
281-
{
282-
"value": "anthropic/claude-2.1",
283-
"variables": "ANTHROPIC_API_KEY"
284-
},
285-
{
286-
"value": "anthropic/claude-3-5-sonnet-20240620",
287-
"variables": "ANTHROPIC_API_KEY"
288-
},
289-
{
290-
"value": "anthropic/claude-3-haiku-20240307",
291-
"variables": "ANTHROPIC_API_KEY"
292-
},
293-
{
294-
"value": "anthropic/claude-3-opus-20240229",
295-
"variables": "ANTHROPIC_API_KEY"
296-
},
297-
{
298-
"value": "anthropic/claude-3-sonnet-20240229",
299-
"variables": "ANTHROPIC_API_KEY"
300-
},
301-
{
302-
"value": "anthropic/claude-instant-1.2",
303-
"variables": "ANTHROPIC_API_KEY"
304-
},
305-
{
306-
"value": "fireworks/gemma2-9b-it",
307-
"variables": "FIREWORKS_API_KEY"
308-
},
309-
{
310-
"value": "fireworks/llama-v3-70b-instruct",
311-
"variables": "FIREWORKS_API_KEY"
312-
},
313-
{
314-
"value": "fireworks/llama-v3-70b-instruct-hf",
315-
"variables": "FIREWORKS_API_KEY"
316-
},
317-
{
318-
"value": "fireworks/llama-v3-8b-instruct",
319-
"variables": "FIREWORKS_API_KEY"
320-
},
321-
{
322-
"value": "fireworks/llama-v3-8b-instruct-hf",
323-
"variables": "FIREWORKS_API_KEY"
324-
},
325-
{
326-
"value": "fireworks/llama-v3p1-405b-instruct",
327-
"variables": "FIREWORKS_API_KEY"
328-
},
329-
{
330-
"value": "fireworks/llama-v3p1-405b-instruct-long",
331-
"variables": "FIREWORKS_API_KEY"
332-
},
333-
{
334-
"value": "fireworks/llama-v3p1-70b-instruct",
335-
"variables": "FIREWORKS_API_KEY"
336-
},
337-
{
338-
"value": "fireworks/llama-v3p1-8b-instruct",
339-
"variables": "FIREWORKS_API_KEY"
340-
},
341-
{
342-
"value": "fireworks/mixtral-8x22b-instruct",
343-
"variables": "FIREWORKS_API_KEY"
344-
},
345-
{
346-
"value": "fireworks/mixtral-8x7b-instruct",
347-
"variables": "FIREWORKS_API_KEY"
348-
},
349-
{
350-
"value": "fireworks/mixtral-8x7b-instruct-hf",
351-
"variables": "FIREWORKS_API_KEY"
352-
},
353-
{
354-
"value": "fireworks/mythomax-l2-13b",
355-
"variables": "FIREWORKS_API_KEY"
356-
},
357-
{
358-
"value": "fireworks/phi-3-vision-128k-instruct",
359-
"variables": "FIREWORKS_API_KEY"
360-
},
361-
{
362-
"value": "fireworks/phi-3p5-vision-instruct",
363-
"variables": "FIREWORKS_API_KEY"
364-
},
365-
{
366-
"value": "fireworks/starcoder-16b",
367-
"variables": "FIREWORKS_API_KEY"
368-
},
369-
{
370-
"value": "fireworks/yi-large",
371-
"variables": "FIREWORKS_API_KEY"
372-
},
373-
{
374-
"value": "openai/gpt-3.5-turbo",
375-
"variables": "OPENAI_API_KEY"
376-
},
377-
{
378-
"value": "openai/gpt-3.5-turbo-0125",
379-
"variables": "OPENAI_API_KEY"
380-
},
381-
{
382-
"value": "openai/gpt-3.5-turbo-0301",
383-
"variables": "OPENAI_API_KEY"
384-
},
385-
{
386-
"value": "openai/gpt-3.5-turbo-0613",
387-
"variables": "OPENAI_API_KEY"
388-
},
389-
{
390-
"value": "openai/gpt-3.5-turbo-1106",
391-
"variables": "OPENAI_API_KEY"
392-
},
393-
{
394-
"value": "openai/gpt-3.5-turbo-16k",
395-
"variables": "OPENAI_API_KEY"
396-
},
397-
{
398-
"value": "openai/gpt-3.5-turbo-16k-0613",
399-
"variables": "OPENAI_API_KEY"
400-
},
401-
{
402-
"value": "openai/gpt-4",
403-
"variables": "OPENAI_API_KEY"
404-
},
405-
{
406-
"value": "openai/gpt-4-0125-preview",
407-
"variables": "OPENAI_API_KEY"
408-
},
409-
{
410-
"value": "openai/gpt-4-0314",
411-
"variables": "OPENAI_API_KEY"
412-
},
413-
{
414-
"value": "openai/gpt-4-0613",
415-
"variables": "OPENAI_API_KEY"
416-
},
417-
{
418-
"value": "openai/gpt-4-1106-preview",
419-
"variables": "OPENAI_API_KEY"
420-
},
421-
{
422-
"value": "openai/gpt-4-32k",
423-
"variables": "OPENAI_API_KEY"
424-
},
425-
{
426-
"value": "openai/gpt-4-32k-0314",
427-
"variables": "OPENAI_API_KEY"
428-
},
429-
{
430-
"value": "openai/gpt-4-32k-0613",
431-
"variables": "OPENAI_API_KEY"
432-
},
433-
{
434-
"value": "openai/gpt-4-turbo",
435-
"variables": "OPENAI_API_KEY"
436-
},
437-
{
438-
"value": "openai/gpt-4-turbo-preview",
439-
"variables": "OPENAI_API_KEY"
440-
},
441-
{
442-
"value": "openai/gpt-4-vision-preview",
443-
"variables": "OPENAI_API_KEY"
444-
},
445-
{
446-
"value": "openai/gpt-4o",
447-
"variables": "OPENAI_API_KEY"
448-
},
449-
{
450-
"value": "openai/gpt-4o-mini",
451-
"variables": "OPENAI_API_KEY"
452-
}
453-
]
454-
},
455-
"max_search_results": {
456-
"type": "integer",
457-
"default": 10
458313
}
459314
}
460315
}
461316
}
462317
}
463-
-->
318+
-->

langgraph.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"dependencies": ["."],
33
"graphs": {
4-
"agent": "./src/react_agent/graph.py:graph"
4+
"agent": "./src/agent/graph.py:graph"
55
},
66
"env": ".env"
77
}

0 commit comments

Comments
 (0)