Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,8 @@ import os
|
|
| 3 |
import requests
|
| 4 |
|
| 5 |
from langchain_community.tools import DuckDuckGoSearchResults
|
|
|
|
|
|
|
| 6 |
import pandas as pd
|
| 7 |
|
| 8 |
from src.agent import Agent
|
|
@@ -15,6 +17,18 @@ tools = [
|
|
| 15 |
]
|
| 16 |
tools.append(DuckDuckGoSearchResults())
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# (Keep Constants as is)
|
| 19 |
# --- Constants ---
|
| 20 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
@@ -46,7 +60,8 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 46 |
model="gpt-4o",
|
| 47 |
tools=tools,
|
| 48 |
system_prompt_path="prompts/system_prompt.txt",
|
| 49 |
-
openai_api_key=os.environ.get("OPENAI_API_KEY")
|
|
|
|
| 50 |
)
|
| 51 |
except Exception as e:
|
| 52 |
print(f"Error instantiating agent: {e}")
|
|
|
|
| 3 |
import requests
|
| 4 |
|
| 5 |
from langchain_community.tools import DuckDuckGoSearchResults
|
| 6 |
+
from langfuse import Langfuse, get_client
|
| 7 |
+
from langfuse.langchain import CallbackHandler
|
| 8 |
import pandas as pd
|
| 9 |
|
| 10 |
from src.agent import Agent
|
|
|
|
| 17 |
]
|
| 18 |
tools.append(DuckDuckGoSearchResults())
|
| 19 |
|
| 20 |
+
Langfuse(
|
| 21 |
+
public_key=os.environ.get("LANGFUSE_PUBLIC_KEY"),
|
| 22 |
+
secret_key=os.environ.get("LANGFUSE_SECRET_KEY"),
|
| 23 |
+
host='https://cloud.langfuse.com'
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# Get the configured client instance
|
| 27 |
+
langfuse = get_client()
|
| 28 |
+
|
| 29 |
+
# Initialize the Langfuse handler
|
| 30 |
+
langfuse_handler = CallbackHandler()
|
| 31 |
+
|
| 32 |
# (Keep Constants as is)
|
| 33 |
# --- Constants ---
|
| 34 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
|
| 60 |
model="gpt-4o",
|
| 61 |
tools=tools,
|
| 62 |
system_prompt_path="prompts/system_prompt.txt",
|
| 63 |
+
openai_api_key=os.environ.get("OPENAI_API_KEY"),
|
| 64 |
+
langfuse_callback_handler=langfuse_handler
|
| 65 |
)
|
| 66 |
except Exception as e:
|
| 67 |
print(f"Error instantiating agent: {e}")
|