mirror of
https://github.com/langchain-ai/langgraph-example-monorepo.git
synced 2026-07-01 14:03:32 -04:00
reformat
This commit is contained in:
@@ -8,4 +8,12 @@ This is an example monorepo with multiple agents to deploy with LangGraph Cloud.
|
||||
|
||||
LangGraph shortens the time-to-market for developers using LangGraph, with a one-liner command to start a production-ready HTTP microservice for your LangGraph applications, with built-in persistence. This lets you focus on the logic of your LangGraph graph, and leave the scaling and API design to us. The API is inspired by the OpenAI assistants API, and is designed to fit in alongside your existing services.
|
||||
|
||||
In order to deploy this agent to LangGraph Cloud you will want to first fork this repo. After that, you can follow the instructions [here](https://langchain-ai.github.io/langgraph/cloud/) to deploy to LangGraph Cloud.
|
||||
In order to deploy this agent to LangGraph Cloud you will want to first fork this repo. After that, you can follow the instructions [here](https://langchain-ai.github.io/langgraph/cloud/) to deploy to LangGraph Cloud.
|
||||
|
||||
# Explanation
|
||||
|
||||
## File Structure
|
||||
|
||||
This repository shows a few potential file structures all in one monorepo. To start with, all of the projects we build are inside of the subdirectory `all_projects`. Inside of this subdirectory we have two more subdirectories. The first is called `my_project`, which could contain multiple projects, but in our case just contains one called `project_one`. Inside of `project_one` we setup a Python package using
|
||||
|
||||
## Configuration file
|
||||
@@ -2,7 +2,6 @@ from typing import TypedDict, Annotated, Sequence, Literal
|
||||
|
||||
from functools import lru_cache
|
||||
from langchain_core.messages import BaseMessage
|
||||
from langchain_anthropic import ChatAnthropic
|
||||
from langchain_openai import ChatOpenAI
|
||||
from langchain_community.tools.tavily_search import TavilySearchResults
|
||||
from langgraph.prebuilt import ToolNode
|
||||
@@ -12,10 +11,12 @@ tools = [TavilySearchResults(max_results=1)]
|
||||
|
||||
@lru_cache(maxsize=4)
|
||||
def _get_model(model_name: str):
|
||||
if model_name == "openai":
|
||||
if model_name == "gpt-4o":
|
||||
model = ChatOpenAI(temperature=0, model_name="gpt-4o")
|
||||
elif model_name == "anthropic":
|
||||
model = ChatAnthropic(temperature=0, model_name="claude-3-sonnet-20240229")
|
||||
elif model_name == "gpt-4o-mini":
|
||||
model = ChatOpenAI(temperature=0, model_name="gpt-4o-mini")
|
||||
elif model_name == "gpt-3.5-turbo":
|
||||
model = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo-0125")
|
||||
else:
|
||||
raise ValueError(f"Unsupported model type: {model_name}")
|
||||
|
||||
@@ -57,7 +58,7 @@ tool_node = ToolNode(tools)
|
||||
|
||||
# Define the config
|
||||
class GraphConfig(TypedDict):
|
||||
model_name: Literal["anthropic", "openai"]
|
||||
model_name: Literal["gpt-4o", "gpt-4o-mini","gpt-3.5-turbo"]
|
||||
|
||||
|
||||
# Define a new graph
|
||||
|
||||
@@ -7,9 +7,8 @@ license = "MIT"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.9.0,<3.13"
|
||||
langgraph = "^0.1.7"
|
||||
langgraph = "^0.2.0"
|
||||
langchain-openai = ">=0.1.17"
|
||||
langchain-anthropic = ">=0.1.20"
|
||||
langchain-community = ">=0.2.11"
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ from typing import TypedDict, Annotated, Sequence, Literal
|
||||
from functools import lru_cache
|
||||
from langchain_core.messages import BaseMessage
|
||||
from langchain_anthropic import ChatAnthropic
|
||||
from langchain_openai import ChatOpenAI
|
||||
from langchain_community.tools.tavily_search import TavilySearchResults
|
||||
from langgraph.prebuilt import ToolNode
|
||||
from langgraph.graph import StateGraph, END, add_messages
|
||||
@@ -12,10 +11,12 @@ tools = [TavilySearchResults(max_results=1)]
|
||||
|
||||
@lru_cache(maxsize=4)
|
||||
def _get_model(model_name: str):
|
||||
if model_name == "openai":
|
||||
model = ChatOpenAI(temperature=0, model_name="gpt-4o")
|
||||
elif model_name == "anthropic":
|
||||
if model_name == "haiku":
|
||||
model = ChatAnthropic(temperature=0, model_name="claude-3-haiku-20240307")
|
||||
elif model_name == "sonnet":
|
||||
model = ChatAnthropic(temperature=0, model_name="claude-3-sonnet-20240229")
|
||||
elif model_name == "opus":
|
||||
model = ChatAnthropic(temperature=0, model_name="claude-3-opus-20240229")
|
||||
else:
|
||||
raise ValueError(f"Unsupported model type: {model_name}")
|
||||
|
||||
@@ -57,7 +58,7 @@ tool_node = ToolNode(tools)
|
||||
|
||||
# Define the config
|
||||
class GraphConfig(TypedDict):
|
||||
model_name: Literal["anthropic", "openai"]
|
||||
model_name: Literal["sonnet", "opus","haiku"]
|
||||
|
||||
|
||||
# Define a new graph
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "my-other-agent"
|
||||
version = "0.0.1"
|
||||
description = "An excellent agent build for LangGraph cloud."
|
||||
authors = ["Polly the parrot <1223+polly@users.noreply.github.com>"]
|
||||
license = "MIT"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.9.0,<3.13"
|
||||
langgraph = "^0.1.7"
|
||||
langchain-openai = ">=0.1.17"
|
||||
langchain-anthropic = ">=0.1.20"
|
||||
langchain-community = ">=0.2.11"
|
||||
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
@@ -0,0 +1,3 @@
|
||||
langgraph>=0.2.0
|
||||
langchain-anthropic>=0.1.20
|
||||
langchain-community>=0.2.11
|
||||
Reference in New Issue
Block a user