Spaces:
Sleeping
Sleeping
Tuyen Pham
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,22 @@
|
|
| 1 |
import yaml
|
| 2 |
import os
|
| 3 |
from smolagents import GradioUI, CodeAgent, InferenceClientModel
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
# Get current directory path
|
| 7 |
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
@@ -13,13 +28,6 @@ from tools.catering_service_tool import SimpleTool as CateringServiceTool
|
|
| 13 |
from tools.superhero_party_theme_generator import SuperheroPartyThemeTool as SuperheroPartyThemeGenerator
|
| 14 |
from tools.final_answer import FinalAnswerTool as FinalAnswer
|
| 15 |
|
| 16 |
-
# Initialize Langfuse callback (reads from HF Spaces secrets) - @mangoobee
|
| 17 |
-
langfuse_callback = LangfuseCallback(
|
| 18 |
-
public_key=os.environ["LANGFUSE_PUBLIC_KEY"],
|
| 19 |
-
secret_key=os.environ["LANGFUSE_SECRET_KEY"],
|
| 20 |
-
host=os.environ["LANGFUSE_HOST"]
|
| 21 |
-
)
|
| 22 |
-
|
| 23 |
model = InferenceClientModel(
|
| 24 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
| 25 |
provider=None,
|
|
@@ -44,9 +52,9 @@ agent = CodeAgent(
|
|
| 44 |
planning_interval=None,
|
| 45 |
name=None,
|
| 46 |
description=None,
|
| 47 |
-
prompt_templates=prompt_templates
|
| 48 |
-
|
| 49 |
)
|
| 50 |
|
| 51 |
if __name__ == "__main__":
|
| 52 |
-
GradioUI(agent).launch()
|
|
|
|
| 1 |
import yaml
|
| 2 |
import os
|
| 3 |
from smolagents import GradioUI, CodeAgent, InferenceClientModel
|
| 4 |
+
|
| 5 |
+
# Langfuse + OpenTelemetry setup
|
| 6 |
+
from langfuse import get_client
|
| 7 |
+
from openinference.instrumentation.smolagents import SmolagentsInstrumentor
|
| 8 |
+
|
| 9 |
+
# Initialize Langfuse client (reads from environment variables automatically)
|
| 10 |
+
langfuse = get_client()
|
| 11 |
+
|
| 12 |
+
# Verify connection
|
| 13 |
+
if langfuse.auth_check():
|
| 14 |
+
print("✅ Langfuse client authenticated!")
|
| 15 |
+
else:
|
| 16 |
+
print("❌ Langfuse authentication failed!")
|
| 17 |
+
|
| 18 |
+
# Initialize OpenTelemetry instrumentation
|
| 19 |
+
SmolagentsInstrumentor().instrument()
|
| 20 |
|
| 21 |
# Get current directory path
|
| 22 |
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
| 28 |
from tools.superhero_party_theme_generator import SuperheroPartyThemeTool as SuperheroPartyThemeGenerator
|
| 29 |
from tools.final_answer import FinalAnswerTool as FinalAnswer
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
model = InferenceClientModel(
|
| 32 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
| 33 |
provider=None,
|
|
|
|
| 52 |
planning_interval=None,
|
| 53 |
name=None,
|
| 54 |
description=None,
|
| 55 |
+
prompt_templates=prompt_templates
|
| 56 |
+
# No callbacks parameter needed - instrumentation happens globally
|
| 57 |
)
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
| 60 |
+
GradioUI(agent).launch()
|