Spaces:
Runtime error
Runtime error
Update LG_agent.py
Browse files- LG_agent.py +9 -8
LG_agent.py
CHANGED
|
@@ -3,20 +3,21 @@ from langgraph.graph.message import add_messages
|
|
| 3 |
from langchain_core.messages import HumanMessage, AIMessage, AnyMessage
|
| 4 |
from langgraph.prebuilt import ToolNode, tools_condition
|
| 5 |
from langgraph.graph import START, StateGraph
|
| 6 |
-
from
|
| 7 |
from tools import all_tools
|
| 8 |
import os
|
| 9 |
|
| 10 |
# 1. Setup once
|
| 11 |
-
|
| 12 |
-
if not
|
| 13 |
-
raise ValueError("Missing
|
| 14 |
|
| 15 |
-
chat =
|
| 16 |
-
model="
|
| 17 |
-
|
| 18 |
-
temperature=0
|
| 19 |
)
|
|
|
|
| 20 |
chat_with_tools = chat.bind_tools(all_tools)
|
| 21 |
|
| 22 |
# 2. Define the agent state
|
|
|
|
| 3 |
from langchain_core.messages import HumanMessage, AIMessage, AnyMessage
|
| 4 |
from langgraph.prebuilt import ToolNode, tools_condition
|
| 5 |
from langgraph.graph import START, StateGraph
|
| 6 |
+
from langchain_openai import ChatOpenAI
|
| 7 |
from tools import all_tools
|
| 8 |
import os
|
| 9 |
|
| 10 |
# 1. Setup once
|
| 11 |
+
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 12 |
+
if not OPENAI_API_KEY:
|
| 13 |
+
raise ValueError("Missing OPENAI_API_KEY environment variable.")
|
| 14 |
|
| 15 |
+
chat = ChatOpenAI(
|
| 16 |
+
model="gpt-3.5-turbo",
|
| 17 |
+
openai_api_key=OPENAI_API_KEY,
|
| 18 |
+
temperature=0,
|
| 19 |
)
|
| 20 |
+
|
| 21 |
chat_with_tools = chat.bind_tools(all_tools)
|
| 22 |
|
| 23 |
# 2. Define the agent state
|