Skip to content

Commit d4d92e3

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

File tree

21 files changed

+134
-784
lines changed

21 files changed

+134
-784
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: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,4 @@ cython_debug/
160160
# and can be added to the global gitignore or merged into this file. For a more nuclear
161161
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162162
#.idea/
163+
uv.lock

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ TEST_FILE ?= tests/unit_tests/
99
test:
1010
python -m pytest $(TEST_FILE)
1111

12+
integration_tests:
13+
python -m pytest tests/integration_tests
14+
1215
test_watch:
1316
python -m ptw --snapshot-update --now . -- -vv tests/unit_tests
1417

README.md

Lines changed: 30 additions & 408 deletions
Large diffs are not rendered by default.

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: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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
]
@@ -10,13 +10,7 @@ license = { text = "MIT" }
1010
requires-python = ">=3.9"
1111
dependencies = [
1212
"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",
1713
"python-dotenv>=1.0.1",
18-
"langchain-community>=0.2.17",
19-
"tavily-python>=0.4.0",
2014
]
2115

2216

@@ -28,10 +22,10 @@ requires = ["setuptools>=73.0.0", "wheel"]
2822
build-backend = "setuptools.build_meta"
2923

3024
[tool.setuptools]
31-
packages = ["langgraph.templates.react_agent", "react_agent"]
25+
packages = ["langgraph.templates.agent", "agent"]
3226
[tool.setuptools.package-dir]
33-
"langgraph.templates.react_agent" = "src/react_agent"
34-
"react_agent" = "src/react_agent"
27+
"langgraph.templates.agent" = "src/agent"
28+
"agent" = "src/agent"
3529

3630

3731
[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"]

src/agent/configuration.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Define the configurable parameters for the agent."""
2+
3+
from __future__ import annotations
4+
5+
from dataclasses import dataclass, fields
6+
from typing import Optional
7+
8+
from langchain_core.runnables import RunnableConfig
9+
10+
11+
@dataclass(kw_only=True)
12+
class Configuration:
13+
"""The configuration for the agent."""
14+
15+
# Changeme: Add configurable values here!
16+
# these values can be pre-set when you
17+
# create assistants (https://langchain-ai.github.io/langgraph/cloud/how-tos/configuration_cloud/)
18+
# and when you invoke the graph
19+
model: str = "changeme"
20+
21+
@classmethod
22+
def from_runnable_config(
23+
cls, config: Optional[RunnableConfig] = None
24+
) -> Configuration:
25+
"""Create a Configuration instance from a RunnableConfig object."""
26+
configurable = (config.get("configurable") or {}) if config else {}
27+
_fields = {f.name for f in fields(cls) if f.init}
28+
return cls(**{k: v for k, v in configurable.items() if k in _fields})

src/agent/graph.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Define a simple chatbot agent.
2+
3+
This agent returns a predefined response without using an actual LLM.
4+
"""
5+
6+
from typing import Any, Dict
7+
8+
from langchain_core.runnables import RunnableConfig
9+
from langgraph.graph import StateGraph
10+
11+
from agent.configuration import Configuration
12+
from agent.state import State
13+
14+
15+
async def my_node(state: State, config: RunnableConfig) -> Dict[str, Any]:
16+
"""Each node does work."""
17+
# configuration = Configuration.from_runnable_config(config)
18+
# You can use runtime configuration to alter the behavior of your
19+
# graph.
20+
return {"changeme": "output from my_node"}
21+
22+
23+
# Define a new graph
24+
workflow = StateGraph(State, config_schema=Configuration)
25+
26+
# Add the node to the graph
27+
workflow.add_node("my_node", my_node)
28+
29+
# Set the entrypoint as `call_model`
30+
workflow.add_edge("__start__", "my_node")
31+
32+
# Compile the workflow into an executable graph
33+
graph = workflow.compile()
34+
graph.name = "New Graph" # This defines the custom name in LangSmith

0 commit comments

Comments
 (0)