Skip to content

Commit

Permalink
Fix dependencies, imports, and README
Browse files Browse the repository at this point in the history
Removed linters and formatters from pyproject.toml
Created a requirements.txt file
Updated the README file
Ran isort to fix import spacing and order
  • Loading branch information
martin-martin committed Feb 3, 2025
1 parent c16660d commit 50baeb8
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 878 deletions.
20 changes: 4 additions & 16 deletions python-langgraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,10 @@ This repo contains the source code for [LangGraph: Build Stateful AI Agents in P

## Setup

LangGraph is available on [PyPI](https://pypi.org/), and you can install it with [pip](https://realpython.com/what-is-pip/). Open a terminal or command prompt, create a new virtual environment, and then run the following command to install LangGraph:
Create a new virtual environment, and run the following command to install LangGraph and the additional requirements for this project:

```console
(venv) $ python -m pip install langgraph
```

This command will install the latest version of LangGraph from PyPI onto your machine. To verify that the installation was successful, start a [Python REPL](https://realpython.com/python-repl/) and import LangGraph:

```pycon
>>> import langgraph
```

If the import runs without error, then you've successfully installed LangGraph. You'll also need a few more libraries for this tutorial:

```console
(venv) $ python -m pip install langchain-openai pydantic[email]
(venv) $ python -m pip install -r requirements.txt
```

You'll use `langchain-openai` to interact with OpenAI LLMs, but keep in mind you can use any LLM provider you like with LangGraph and LangChain. You'll use [`pydantic`](https://realpython.com/python-pydantic/) to validate the information your agent parses from emails.
Expand All @@ -30,6 +18,6 @@ Before moving forward, if you choose to use OpenAI, make sure you're signed up f
OPENAI_API_KEY=<YOUR-OPENAI-API-KEY>
```

Note that while LangGraph was made by the creators of LangChain, and the two libraries are highly compatible, it is possible to use LangGraph without LangChain. However, it's more common to use LangChain and LangGraph together, and you'll see throughout this tutorial how they compliment each other.
## Usage

With that, you've installed all the dependencies you'll need for this tutorial, and you're ready to create your LangGraph email processor. You'll start by going through an overview of LangChain chains and exploring LangGraph's core concept - the state graph.
TODO: A short note on how to run the project. You can tell them to go to the tutorial for more information.
5 changes: 3 additions & 2 deletions python-langgraph/graphs/email_agent.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import logging
import time

from chains.notice_extraction import NoticeEmailExtract
from graphs.notice_extraction import NOTICE_EXTRACTION_GRAPH
from langchain_core.messages import AIMessage
from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
from langgraph.graph import END, START, MessagesState, StateGraph
from langgraph.prebuilt import ToolNode

from chains.notice_extraction import NoticeEmailExtract
from graphs.notice_extraction import NOTICE_EXTRACTION_GRAPH

logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
)
Expand Down
5 changes: 3 additions & 2 deletions python-langgraph/graphs/notice_extraction.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import logging
from typing import TypedDict

from langgraph.graph import END, START, StateGraph
from pydantic import EmailStr

from chains.binary_questions import BINARY_QUESTION_CHAIN
from chains.escalation_check import ESCALATION_CHECK_CHAIN
from chains.notice_extraction import NOTICE_PARSER_CHAIN, NoticeEmailExtract
from langgraph.graph import END, START, StateGraph
from pydantic import EmailStr
from utils.graph_utils import create_legal_ticket, send_escalation_email

logging.basicConfig(
Expand Down
3 changes: 0 additions & 3 deletions python-langgraph/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"black>=24.10.0",
"flake8>=7.1.1",
"langchain-openai>=0.3.2",
"langgraph>=0.2.67",
"pydantic[email]>=2.10.6",
"ruff>=0.9.3",
]
106 changes: 106 additions & 0 deletions python-langgraph/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# This file was autogenerated by uv via the following command:
# uv pip compile --output-file requirements.txt pyproject.toml
annotated-types==0.7.0
# via pydantic
anyio==4.8.0
# via
# httpx
# openai
certifi==2025.1.31
# via
# httpcore
# httpx
# requests
charset-normalizer==3.4.1
# via requests
distro==1.9.0
# via openai
dnspython==2.7.0
# via email-validator
email-validator==2.2.0
# via pydantic
h11==0.14.0
# via httpcore
httpcore==1.0.7
# via httpx
httpx==0.28.1
# via
# langgraph-sdk
# langsmith
# openai
idna==3.10
# via
# anyio
# email-validator
# httpx
# requests
jiter==0.8.2
# via openai
jsonpatch==1.33
# via langchain-core
jsonpointer==3.0.0
# via jsonpatch
langchain-core==0.3.33
# via
# langchain-openai
# langgraph
# langgraph-checkpoint
langchain-openai==0.3.3
# via python-langgraph (pyproject.toml)
langgraph==0.2.69
# via python-langgraph (pyproject.toml)
langgraph-checkpoint==2.0.10
# via langgraph
langgraph-sdk==0.1.51
# via langgraph
langsmith==0.3.4
# via langchain-core
msgpack==1.1.0
# via langgraph-checkpoint
openai==1.61.0
# via langchain-openai
orjson==3.10.15
# via
# langgraph-sdk
# langsmith
packaging==24.2
# via langchain-core
pydantic==2.10.6
# via
# python-langgraph (pyproject.toml)
# langchain-core
# langsmith
# openai
pydantic-core==2.27.2
# via pydantic
pyyaml==6.0.2
# via langchain-core
regex==2024.11.6
# via tiktoken
requests==2.32.3
# via
# langsmith
# requests-toolbelt
# tiktoken
requests-toolbelt==1.0.0
# via langsmith
sniffio==1.3.1
# via
# anyio
# openai
tenacity==9.0.0
# via langchain-core
tiktoken==0.8.0
# via langchain-openai
tqdm==4.67.1
# via openai
typing-extensions==4.12.2
# via
# langchain-core
# openai
# pydantic
# pydantic-core
urllib3==2.3.0
# via requests
zstandard==0.23.0
# via langsmith
3 changes: 2 additions & 1 deletion python-langgraph/utils/graph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import random
import time

from chains.notice_extraction import NoticeEmailExtract
from pydantic import EmailStr

from chains.notice_extraction import NoticeEmailExtract

logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
)
Expand Down
Loading

0 comments on commit 50baeb8

Please sign in to comment.