Matthew commited on
Commit
cf74427
·
1 Parent(s): 692a76c

Add Langfuse instrumetation and basic agent

Browse files
Files changed (3) hide show
  1. agent.py +14 -3
  2. app.py +8 -0
  3. pyproject.toml +3 -0
agent.py CHANGED
@@ -1,8 +1,19 @@
 
 
 
 
 
1
  class DRAgent:
2
  def __init__(self):
 
 
 
 
 
 
3
  print("BasicAgent initialized.")
4
  def __call__(self, question: str) -> str:
5
  print(f"Agent received question (first 50 chars): {question[:50]}...")
6
- fixed_answer = "This is a default answer."
7
- print(f"Agent returning fixed answer: {fixed_answer}")
8
- return fixed_answer
 
1
+ from smolagents import (
2
+ ToolCallingAgent,
3
+ InferenceClientModel,
4
+ )
5
+
6
  class DRAgent:
7
  def __init__(self):
8
+ self.agent = ToolCallingAgent(
9
+ tools=[],
10
+ model=InferenceClientModel(
11
+ model_id="deepseek-ai/DeepSeek-R1-Distill-Qwen-32B"
12
+ ),
13
+ )
14
  print("BasicAgent initialized.")
15
  def __call__(self, question: str) -> str:
16
  print(f"Agent received question (first 50 chars): {question[:50]}...")
17
+ answer = self.agent.run(question)
18
+ print(f"Agent returning answer: {answer}")
19
+ return answer
app.py CHANGED
@@ -3,6 +3,9 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
 
 
 
6
 
7
  from agent import DRAgent
8
 
@@ -10,6 +13,11 @@ from agent import DRAgent
10
  # --- Constants ---
11
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
 
 
 
 
 
 
13
  # --- Basic Agent Definition ---
14
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
15
  # NB: Moved to `agent.py`
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from dotenv import load_dotenv
7
+ from langfuse import get_client
8
+ from openinference.instrumentation.smolagents import SmolagentsInstrumentor
9
 
10
  from agent import DRAgent
11
 
 
13
  # --- Constants ---
14
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
15
 
16
+ # Housekeeping (environment variables, telemetry, etc.)
17
+ load_dotenv()
18
+ langfuse = get_client()
19
+ SmolagentsInstrumentor().instrument()
20
+
21
  # --- Basic Agent Definition ---
22
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
23
  # NB: Moved to `agent.py`
pyproject.toml CHANGED
@@ -6,5 +6,8 @@ readme = "README.md"
6
  requires-python = ">=3.13"
7
  dependencies = [
8
  "gradio>=5.49.1",
 
 
9
  "requests>=2.32.5",
 
10
  ]
 
6
  requires-python = ">=3.13"
7
  dependencies = [
8
  "gradio>=5.49.1",
9
+ "langfuse>=3.8.1",
10
+ "openinference-instrumentation-smolagents>=0.1.19",
11
  "requests>=2.32.5",
12
+ "smolagents[telemetry]>=1.22.0",
13
  ]