abtsousa commited on
Commit
3c439f4
·
1 Parent(s): f439125

Refactor Phoenix tracing setup and integrate with OracleBot

Browse files
Files changed (2) hide show
  1. app.py +4 -17
  2. logging/phoenix.py +19 -0
app.py CHANGED
@@ -9,12 +9,9 @@ from langchain_core.runnables import RunnableConfig
9
  import asyncio
10
  from typing import cast
11
 
12
- # Phoenix imports
13
- from phoenix.otel import register
14
- import logging
15
-
16
- from agent.agent import get_agent
17
  from agent.config import create_agent_config
 
18
 
19
  load_dotenv()
20
 
@@ -22,18 +19,8 @@ load_dotenv()
22
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
23
  APP_NAME = "OracleBot"
24
 
25
- # Phoenix tracing setup
26
- def start_phoenix():
27
- """Setup Phoenix tracing for the agent."""
28
- register(
29
- project_name=APP_NAME,
30
- auto_instrument=True,
31
- )
32
- logging.getLogger("openinference").setLevel(logging.CRITICAL)
33
- print("Phoenix tracing enabled.")
34
-
35
  # Initialize Phoenix (you can comment this out if you don't want tracing)
36
- start_phoenix()
37
 
38
  # --- Basic Agent Definition ---
39
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
@@ -46,7 +33,7 @@ start_phoenix()
46
 
47
  class BasicAgent:
48
  def __init__(self):
49
- self.agent = get_agent()
50
 
51
  async def __call__(self, question: str) -> str:
52
  print(f"Agent received question: {question}")
 
9
  import asyncio
10
  from typing import cast
11
 
12
+ from agent.agent import OracleBot
 
 
 
 
13
  from agent.config import create_agent_config
14
+ from logging.phoenix import start_phoenix
15
 
16
  load_dotenv()
17
 
 
19
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
20
  APP_NAME = "OracleBot"
21
 
 
 
 
 
 
 
 
 
 
 
22
  # Initialize Phoenix (you can comment this out if you don't want tracing)
23
+ start_phoenix(APP_NAME)
24
 
25
  # --- Basic Agent Definition ---
26
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
33
 
34
  class BasicAgent:
35
  def __init__(self):
36
+ self.agent = OracleBot()
37
 
38
  async def __call__(self, question: str) -> str:
39
  print(f"Agent received question: {question}")
logging/phoenix.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Phoenix tracing setup for the OracleBot application."""
2
+
3
+ import logging
4
+ from phoenix.otel import register
5
+ from app import APP_NAME
6
+
7
+
8
+ def start_phoenix(project_name: str = APP_NAME) -> None:
9
+ """Setup Phoenix tracing for the agent.
10
+
11
+ Args:
12
+ project_name: Name of the project to use for Phoenix tracing
13
+ """
14
+ register(
15
+ project_name=project_name,
16
+ auto_instrument=True,
17
+ )
18
+ logging.getLogger("openinference").setLevel(logging.CRITICAL)
19
+ print(f"Phoenix tracing enabled for project: {project_name}")