2025-03-31 22:20:29 +08:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
from langchain_openai import ChatOpenAI
|
|
|
|
|
|
2025-04-05 17:27:52 +08:00
|
|
|
from src import graph_base
|
|
|
|
|
|
2025-03-31 22:20:29 +08:00
|
|
|
model = ChatOpenAI(model="glm-4-plus",
|
|
|
|
|
api_key=os.getenv("ZHIPUAI_API_KEY"),
|
|
|
|
|
base_url="https://open.bigmodel.cn/api/paas/v4/",
|
|
|
|
|
temperature=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# For this tutorial we will use custom tool that returns pre-defined values for weather in two cities (NYC & SF)
|
|
|
|
|
|
2025-04-05 17:27:52 +08:00
|
|
|
from typing import Literal, Annotated
|
2025-03-31 22:20:29 +08:00
|
|
|
|
2025-04-05 17:27:52 +08:00
|
|
|
from langchain_core.tools import tool, StructuredTool
|
2025-03-31 22:20:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-05 17:27:52 +08:00
|
|
|
tools = []
|
2025-03-31 22:20:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
from langgraph.prebuilt import create_react_agent
|
|
|
|
|
|
|
|
|
|
graph = create_react_agent(model, tools=tools)
|