Spaces:
Runtime error
Runtime error
check
Browse files- real_agent.py +13 -5
real_agent.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
from typing import TypedDict, Annotated
|
| 2 |
from langgraph.graph.message import add_messages
|
| 3 |
-
from langchain_core.messages import AnyMessage, HumanMessage, AIMessage
|
| 4 |
from langgraph.prebuilt import ToolNode
|
| 5 |
from langgraph.graph import START, StateGraph
|
| 6 |
from langgraph.prebuilt import tools_condition
|
|
@@ -13,19 +13,27 @@ import gradio as gr
|
|
| 13 |
from langfuse.langchain import CallbackHandler
|
| 14 |
from smolagents import VisitWebpageTool, GoogleSearchTool, PythonInterpreterTool
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
def call_build():
|
| 18 |
-
|
| 19 |
os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-842782bf-0e8d-4f50-8fb0-157464d5fe28"
|
| 20 |
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-3179ce99-f0e4-46f1-bbde-df3752414be3"
|
| 21 |
os.environ["LANGFUSE_HOST"] = "https://us.cloud.langfuse.com"
|
| 22 |
|
| 23 |
os.environ["OPENAI_API_KEY"] = "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"
|
| 24 |
|
| 25 |
-
os.environ["SERPAPI_API_KEY"] = "82491710ce6c6aa2d767d7796023a5ca11aa182fcda2a703cd44aea8d6da4489
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
# Initialize the web search tool
|
| 31 |
# search_tool = GoogleSearchTool(provider = "serpapi")
|
|
|
|
| 1 |
from typing import TypedDict, Annotated
|
| 2 |
from langgraph.graph.message import add_messages
|
| 3 |
+
from langchain_core.messages import AnyMessage, HumanMessage, AIMessage, SystemMessage
|
| 4 |
from langgraph.prebuilt import ToolNode
|
| 5 |
from langgraph.graph import START, StateGraph
|
| 6 |
from langgraph.prebuilt import tools_condition
|
|
|
|
| 13 |
from langfuse.langchain import CallbackHandler
|
| 14 |
from smolagents import VisitWebpageTool, GoogleSearchTool, PythonInterpreterTool
|
| 15 |
|
| 16 |
+
# load the system prompt from the file
|
| 17 |
+
with open("system_prompt.txt", "r", encoding="utf-8") as f:
|
| 18 |
+
system_prompt = f.read()
|
| 19 |
+
|
| 20 |
+
# System message
|
| 21 |
+
sys_msg = SystemMessage(content=system_prompt)
|
| 22 |
|
|
|
|
|
|
|
| 23 |
os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-842782bf-0e8d-4f50-8fb0-157464d5fe28"
|
| 24 |
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-3179ce99-f0e4-46f1-bbde-df3752414be3"
|
| 25 |
os.environ["LANGFUSE_HOST"] = "https://us.cloud.langfuse.com"
|
| 26 |
|
| 27 |
os.environ["OPENAI_API_KEY"] = "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"
|
| 28 |
|
| 29 |
+
os.environ["SERPAPI_API_KEY"] = "82491710ce6c6aa2d767d7796023a5ca11aa182fcda2a703cd44aea8d6da4489
|
| 30 |
+
langfuse_handler = CallbackHandler()
|
| 31 |
+
def call_build():
|
| 32 |
+
|
| 33 |
+
"
|
| 34 |
|
| 35 |
|
| 36 |
+
|
| 37 |
|
| 38 |
# Initialize the web search tool
|
| 39 |
# search_tool = GoogleSearchTool(provider = "serpapi")
|