Skip to content

Commit 23c3707

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

File tree

20 files changed

+182
-579
lines changed

20 files changed

+182
-579
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: 28 additions & 216 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,8 +32,6 @@ 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
-->
@@ -45,29 +42,34 @@ Set up your LLM API keys. This repo defaults to using [Claude](https://console.a
4542
End setup instructions
4643
-->
4744

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!
5047

5148
## How to customize
5249

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.
5451
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.
5653

5754
You can also quickly extend this template by:
5855

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

6260
## Development
6361

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

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

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

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

7274
<!--
7375
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.
7880
"properties": {
7981
"system_prompt": {
8082
"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}"
8284
},
8385
"model_name": {
8486
"type": "string",
@@ -265,199 +267,9 @@ Configuration auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
265267
"variables": "OPENAI_API_KEY"
266268
}
267269
]
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
458270
}
459271
}
460272
}
461273
}
462274
}
463-
-->
275+
-->

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
}

pyproject.toml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
[project]
2-
name = "react-agent"
2+
name = "agent"
33
version = "0.0.1"
4-
description = "Starter template for making a custom Reasoning and Action agent (using tool calling) in LangGraph."
4+
description = "Starter template for making a new agent LangGraph."
55
authors = [
66
{ name = "William Fu-Hinthorn", email = "[email protected]" },
77
]
88
readme = "README.md"
99
license = { text = "MIT" }
1010
requires-python = ">=3.9"
1111
dependencies = [
12+
"langchain>=0.3.0",
13+
"langchain-anthropic>=0.2.0",
1214
"langgraph>=0.2.6",
13-
"langchain-openai>=0.1.22",
14-
"langchain-anthropic>=0.1.23",
15-
"langchain>=0.2.14",
16-
"langchain-fireworks>=0.1.7",
1715
"python-dotenv>=1.0.1",
18-
"langchain-community>=0.2.17",
19-
"tavily-python>=0.4.0",
2016
]
2117

2218

@@ -28,10 +24,10 @@ requires = ["setuptools>=73.0.0", "wheel"]
2824
build-backend = "setuptools.build_meta"
2925

3026
[tool.setuptools]
31-
packages = ["langgraph.templates.react_agent", "react_agent"]
27+
packages = ["langgraph.templates.agent", "agent"]
3228
[tool.setuptools.package-dir]
33-
"langgraph.templates.react_agent" = "src/react_agent"
34-
"react_agent" = "src/react_agent"
29+
"langgraph.templates.agent" = "src/agent"
30+
"agent" = "src/agent"
3531

3632

3733
[tool.setuptools.package-data]

src/agent/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""New LangGraph Agent.
2+
3+
This module defines a custom graph.
4+
"""
5+
6+
from agent.graph import graph
7+
8+
__all__ = ["graph"]

0 commit comments

Comments
 (0)