generated from langchain-ai/react-agent
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
629 additions
and
2,471 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
ANTHROPIC_API_KEY=.... | ||
FIREWORKS_API_KEY=... | ||
OPENAI_API_KEY=... | ||
TAVILY_API_KEY=... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# This workflow will run integration tests for the current project once per day | ||
|
||
name: Integration Tests | ||
|
||
on: | ||
schedule: | ||
- cron: "37 14 * * *" # Run at 7:37 AM Pacific Time (14:37 UTC) every day | ||
workflow_dispatch: # Allows triggering the workflow manually in GitHub UI | ||
|
||
# If another scheduled run starts while this workflow is still running, | ||
# cancel the earlier run in favor of the next run. | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
integration-tests: | ||
name: Integration Tests | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
python-version: ["3.11", "3.12"] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
curl -LsSf https://astral.sh/uv/install.sh | sh | ||
uv venv | ||
uv pip install -r pyproject.toml | ||
- name: Run integration tests | ||
env: | ||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | ||
TAVILY_API_KEY: ${{ secrets.TAVILY_API_KEY }} | ||
run: | | ||
uv pip install pytest | ||
uv run pytest tests/integration_tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# This workflow will run unit tests for the current project | ||
|
||
name: CI | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
workflow_dispatch: # Allows triggering the workflow manually in GitHub UI | ||
|
||
# If another push to the same PR or branch happens while this workflow is still running, | ||
# cancel the earlier run in favor of the next run. | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
unit-tests: | ||
name: Unit Tests | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
python-version: ["3.11", "3.12"] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
curl -LsSf https://astral.sh/uv/install.sh | sh | ||
uv venv | ||
uv pip install -r pyproject.toml | ||
- name: Lint with ruff | ||
run: | | ||
uv pip install ruff | ||
uv run ruff check . | ||
- name: Lint with mypy | ||
run: | | ||
uv pip install mypy | ||
uv run mypy --strict src/ | ||
- name: Check README spelling | ||
uses: codespell-project/actions-codespell@v2 | ||
with: | ||
ignore_words_file: .codespellignore | ||
path: README.md | ||
- name: Check code spelling | ||
uses: codespell-project/actions-codespell@v2 | ||
with: | ||
ignore_words_file: .codespellignore | ||
path: src/ | ||
- name: Run tests with pytest | ||
run: | | ||
uv pip install pytest | ||
uv run pytest tests/unit_tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,81 @@ | ||
# LangGraph ReAct Agent Template | ||
# LangGraph Data Enrichment Template | ||
|
||
This LangGraph template implements a simple, extensible ReAct agent. | ||
[![CI](https://github.com/langchain-ai/data-enrichment/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/langchain-ai/data-enrichment/actions/workflows/unit-tests.yml) | ||
[![Integration Tests](https://github.com/langchain-ai/data-enrichment/actions/workflows/integration-tests.yml/badge.svg)](https://github.com/langchain-ai/data-enrichment/actions/workflows/integration-tests.yml) | ||
|
||
![Graph view in LangGraph studio UI](./static/studio_ui.png) | ||
This is a starter project to help you get started with developing a data enrichment agent using [LangGraph](https://github.com/langchain-ai/langgraph) in [LangGraph Studio](https://github.com/langchain-ai/langgraph-studio). | ||
|
||
![](/static/studio.png) | ||
|
||
It contains an example graph exported from `src/enrichment_agent/graph.py` that implements a research assistant capable of automatically gathering information on various topics from the web. | ||
|
||
## What it does | ||
|
||
The enrichment agent: | ||
|
||
1. Takes a research topic as input | ||
2. Searches the web for relevant information | ||
3. Reads and extracts key details from websites | ||
4. Organizes the findings into a structured format | ||
5. Validates the gathered information for completeness and accuracy | ||
|
||
By default, it's set up to gather information based on the user-provided schema passed through the `template_schema` key in the state. | ||
|
||
|
||
## Getting Started | ||
|
||
This template was designed for [LangGraph Studio](https://github.com/langchain-ai/langgraph-studio). To use, clone this repo locally and open the folder in LangGraph Studio. | ||
|
||
Note that the `Deploy` button is currently not supported, but will be soon! | ||
|
||
You will need the latest versions of `langgraph` and `langchain`. See these instructions for help upgrading an [existing project](https://github.com/langchain-ai/langgraph#installation). | ||
|
||
You can also [click here](https://www.loom.com/share/81cafa32d57f4933bd5d9b08c70f460c?sid=4ebcb366-f27a-4c49-854d-169106b4f6fe) to see a (rough) video tour of Studio. | ||
|
||
To set up: | ||
|
||
1. Set up your API keys for the LLM (Claude) and search tool (Tavily) in the `.env` file. | ||
2. Install the required dependencies (`poetry install`) | ||
3. Customize whatever you'd like in the code. | ||
4. Run the script with your research topic as input. | ||
|
||
## Repo Structure | ||
|
||
```txt | ||
├── LICENSE | ||
├── README.md | ||
├── langgraph.json | ||
├── poetry.lock | ||
├── pyproject.toml | ||
├── react_agent | ||
│ ├── __init__.py | ||
│ ├── graph.py | ||
│ └── utils | ||
│ ├── __init__.py | ||
│ ├── configuration.py # Define the configurable variables | ||
│ ├── state.py # Define state variables and how they're updated | ||
│ ├── tools.py # Define the tools your agent can access | ||
│ └── utils.py # Other sundry utilities | ||
└── tests # Add whatever tests you'd like here | ||
├── src | ||
│ └── enrichment_agent | ||
│ ├── __init__.py | ||
│ ├── configuration.py | ||
│ ├── graph.py | ||
│ ├── state.py | ||
│ ├── tools.py | ||
│ └── utils.py | ||
├── static | ||
│ └── studio_ui.png | ||
└── tests | ||
├── integration_tests | ||
│ └── __init__.py | ||
│ ├── __init__.py | ||
│ └── test_graph.py | ||
└── unit_tests | ||
└── __init__.py | ||
``` | ||
r | ||
|
||
## Development | ||
|
||
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/enrichment_agent/utils.py` to take on a persona, or adding additional nodes and edges! | ||
|
||
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. | ||
|
||
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. | ||
|
||
LangGraph Studio also integrates with [LangSmith](https://smith.langchain.com/) for more in-depth tracing and collaboration with teammates. | ||
|
||
## How to extend it | ||
|
||
1. **Customize research targets**: Modify the `InfoSchema` to gather different types of information. | ||
2. **Enhance data sources and validation**: Add new tools, APIs, or implement more rigorous fact-checking. | ||
3. **Improve output and interactivity**: Develop custom formatting and user feedback mechanisms. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"dependencies": ["."], | ||
"graphs": { | ||
"agent": "./react_agent/graph.py:graph" | ||
"agent": "./src/enrichment_agent/graph.py:graph" | ||
}, | ||
"env": ".env" | ||
} |
Oops, something went wrong.