Skip to content

Commit e1e44e1

Browse files
authored
Update REAADME
2 parents 6627a2a + f196468 commit e1e44e1

File tree

7 files changed

+56
-52
lines changed

7 files changed

+56
-52
lines changed

.env.example

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
# To separate your traces from other application
22
LANGSMITH_PROJECT=new-agent
33

4-
# The following depend on your selected configuration
5-
6-
## LLM choice:
7-
ANTHROPIC_API_KEY=....
8-
FIREWORKS_API_KEY=...
9-
OPENAI_API_KEY=...
4+
# Add API keys for connecting to LLM providers, data sources, and other integrations here

README.md

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,73 +2,68 @@
22

33
[![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)
44
[![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)
5-
[![Open in - LangGraph Studio](https://img.shields.io/badge/Open_in-LangGraph_Studio-00324d.svg?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4NS4zMzMiIGhlaWdodD0iODUuMzMzIiB2ZXJzaW9uPSIxLjAiIHZpZXdCb3g9IjAgMCA2NCA2NCI+PHBhdGggZD0iTTEzIDcuOGMtNi4zIDMuMS03LjEgNi4zLTYuOCAyNS43LjQgMjQuNi4zIDI0LjUgMjUuOSAyNC41QzU3LjUgNTggNTggNTcuNSA1OCAzMi4zIDU4IDcuMyA1Ni43IDYgMzIgNmMtMTIuOCAwLTE2LjEuMy0xOSAxLjhtMzcuNiAxNi42YzIuOCAyLjggMy40IDQuMiAzLjQgNy42cy0uNiA0LjgtMy40IDcuNkw0Ny4yIDQzSDE2LjhsLTMuNC0zLjRjLTQuOC00LjgtNC44LTEwLjQgMC0xNS4ybDMuNC0zLjRoMzAuNHoiLz48cGF0aCBkPSJNMTguOSAyNS42Yy0xLjEgMS4zLTEgMS43LjQgMi41LjkuNiAxLjcgMS44IDEuNyAyLjcgMCAxIC43IDIuOCAxLjYgNC4xIDEuNCAxLjkgMS40IDIuNS4zIDMuMi0xIC42LS42LjkgMS40LjkgMS41IDAgMi43LS41IDIuNy0xIDAtLjYgMS4xLS44IDIuNi0uNGwyLjYuNy0xLjgtMi45Yy01LjktOS4zLTkuNC0xMi4zLTExLjUtOS44TTM5IDI2YzAgMS4xLS45IDIuNS0yIDMuMi0yLjQgMS41LTIuNiAzLjQtLjUgNC4yLjguMyAyIDEuNyAyLjUgMy4xLjYgMS41IDEuNCAyLjMgMiAyIDEuNS0uOSAxLjItMy41LS40LTMuNS0yLjEgMC0yLjgtMi44LS44LTMuMyAxLjYtLjQgMS42LS41IDAtLjYtMS4xLS4xLTEuNS0uNi0xLjItMS42LjctMS43IDMuMy0yLjEgMy41LS41LjEuNS4yIDEuNi4zIDIuMiAwIC43LjkgMS40IDEuOSAxLjYgMi4xLjQgMi4zLTIuMy4yLTMuMi0uOC0uMy0yLTEuNy0yLjUtMy4xLTEuMS0zLTMtMy4zLTMtLjUiLz48L3N2Zz4=)](https://langgraph-studio.vercel.app/templates/open?githubUrl=https://github.com/langchain-ai/new-langgraph-project)
65

7-
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.
6+
This template demonstrates a simple application implemented using [LangGraph](https://github.com/langchain-ai/langgraph), designed for showing how to get started with [LangGraph Server](https://langchain-ai.github.io/langgraph/concepts/langgraph_server/#langgraph-server) and using [LangGraph Studio](https://langchain-ai.github.io/langgraph/concepts/langgraph_studio/), a visual debugging IDE.
87

9-
![Graph view in LangGraph studio UI](./static/studio_ui.png)
8+
<div align="center">
9+
<img src="./static/studio_ui.png" alt="Graph view in LangGraph studio UI" width="75%" />
10+
</div>
1011

11-
The core logic, defined in `src/agent/graph.py`, showcases a straightforward chatbot that responds to user queries while maintaining context from previous messages.
12+
The core logic defined in `src/agent/graph.py`, showcases an single-step application that responds with a fixed string and the configuration provided.
1213

13-
## What it does
14+
You can extend this graph to orchestrate more complex agentic workflows that can be visualized and debugged in LangGraph Studio.
1415

15-
The simple chatbot:
16+
## Getting Started
1617

17-
1. Takes a user **message** as input
18-
2. Maintains a history of the conversation
19-
3. Generates a response based on the current message and conversation history
20-
4. Updates the conversation history with the new interaction
18+
<!--
19+
Setup instruction auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
20+
-->
2121

22-
This template provides a foundation that can be easily customized and extended to create more complex conversational agents.
22+
<!--
23+
End setup instructions
24+
-->
2325

24-
## Getting Started
26+
1. Install dependencies, along with the [LangGraph CLI](https://langchain-ai.github.io/langgraph/concepts/langgraph_cli/), which will be used to run the server.
2527

26-
Assuming you have already [installed LangGraph Studio](https://github.com/langchain-ai/langgraph-studio?tab=readme-ov-file#download), to set up:
28+
```bash
29+
cd path/to/your/app
30+
pip install -e . "langgraph-cli[inmem]"
31+
```
2732

28-
1. Create a `.env` file.
33+
2. (Optional) Customize the code and project as needed. Create a `.env` file if you need to use secrets.
2934

3035
```bash
3136
cp .env.example .env
3237
```
3338

34-
2. Define required API keys in your `.env` file.
35-
36-
<!--
37-
Setup instruction auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
38-
-->
39+
If you want to enable LangSmith tracing, add your LangSmith API key to the `.env` file.
3940

41+
```text
42+
# .env
43+
LANGSMITH_API_KEY=lsv2...
44+
```
4045

46+
3. Start the LangGraph Server.
4147

42-
<!--
43-
End setup instructions
44-
-->
48+
```shell
49+
langgraph dev
50+
```
4551

46-
3. Customize the code as needed.
47-
4. Open the folder in LangGraph Studio!
52+
For more information on getting started with LangGraph Server, [see here](https://langchain-ai.github.io/langgraph/tutorials/langgraph-platform/local-server/).
4853

4954
## How to customize
5055

51-
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.
52-
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`.
53-
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.
54-
55-
You can also quickly extend this template by:
56+
1. **Define configurable parameters**: Modify the `Configuration` class in the `graph.py` file to expose the arguments you want to configure. For example, in a chatbot application you may want to define a dynamic system prompt or LLM to use. For more information on configurations in LangGraph, [see here](https://langchain-ai.github.io/langgraph/concepts/low_level/?h=configuration#configuration).
5657

57-
- Adding custom tools or functions to enhance the chatbot's capabilities.
58-
- Implementing additional logic for handling specific types of user queries or tasks.
59-
- Integrating external APIs or databases to provide more dynamic responses.
58+
2. **Extend the graph**: The core logic of the application is defined in [graph.py](./src/agent/graph.py). You can modify this file to add new nodes, edges, or change the flow of information.
6059

6160
## Development
6261

63-
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:
62+
While iterating on your graph in LangGraph Studio, 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.
6463

65-
- Modifying the system prompt to give your chatbot a unique personality.
66-
- Adding new nodes to the graph for more complex conversation flows.
67-
- Implementing conditional logic to handle different types of user inputs.
64+
Follow-up requests extend the same thread. You can create an entirely new thread, clearing previous history, using the `+` button in the top right.
6865

69-
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.
70-
71-
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.
66+
For more advanced features and examples, refer to the [LangGraph documentation](https://langchain-ai.github.io/langgraph/). These resources can help you adapt this template for your specific use case and build more sophisticated conversational agents.
7267

7368
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.
7469

@@ -82,4 +77,4 @@ Configuration auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
8277
}
8378
}
8479
}
85-
-->
80+
-->

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,7 @@ convention = "google"
5959
dev = [
6060
"anyio>=4.7.0",
6161
"langgraph-cli[inmem]>=0.2.8",
62+
"mypy>=1.13.0",
63+
"pytest>=8.3.5",
64+
"ruff>=0.8.2",
6265
]

src/agent/graph.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Configuration(TypedDict):
1818
Set these when creating assistants OR when invoking the graph.
1919
See: https://langchain-ai.github.io/langgraph/cloud/how-tos/configuration_cloud/
2020
"""
21+
2122
my_configurable_param: str
2223

2324

@@ -28,25 +29,26 @@ class State:
2829
Defines the initial structure of incoming data.
2930
See: https://langchain-ai.github.io/langgraph/concepts/low_level/#state
3031
"""
32+
3133
changeme: str = "example"
3234

3335

34-
async def my_node(state: State, config: RunnableConfig) -> Dict[str, Any]:
35-
"""Example node: processes input and returns output.
36+
async def call_model(state: State, config: RunnableConfig) -> Dict[str, Any]:
37+
"""Process input and returns output.
3638
3739
Can use runtime configuration to alter behavior.
3840
"""
3941
configuration = config["configurable"]
4042
return {
41-
"changeme": "output from my_node. "
43+
"changeme": "output from call_model. "
4244
f'Configured with {configuration.get("my_configurable_param")}'
4345
}
4446

4547

4648
# Define the graph
4749
graph = (
4850
StateGraph(State, config_schema=Configuration)
49-
.add_node(my_node)
50-
.add_edge("__start__", "my_node")
51+
.add_node(call_model)
52+
.add_edge("__start__", "call_model")
5153
.compile(name="New Graph")
5254
)

static/studio_ui.png

-811 KB
Loading

tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import pytest
2+
3+
4+
@pytest.fixture(scope="session")
5+
def anyio_backend():
6+
return "asyncio"

tests/integration_tests/test_graph.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
from agent import graph
44

5+
pytestmark = pytest.mark.anyio
6+
57

68
@pytest.mark.langsmith
79
async def test_agent_simple_passthrough() -> None:
8-
res = await graph.ainvoke({"changeme": "some_val"})
10+
inputs = {"changeme": "some_val"}
11+
res = await graph.ainvoke(inputs)
912
assert res is not None

0 commit comments

Comments
 (0)