Spaces:
Runtime error
Runtime error
abtsousa
Implement cache directory management and update file fetching to use cache if no working directory is provided
e8c805a
| """Phoenix tracing setup for the OracleBot application.""" | |
| import logging | |
| import shutil | |
| from pathlib import Path | |
| from phoenix.otel import register | |
| DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space" | |
| APP_NAME = "OracleBot" | |
| # Define cache directory path globally | |
| CACHE_DIR = Path(__file__).parent / "cache" | |
| def initialize_cache_directory(): | |
| """Initialize the cache directory for file operations.""" | |
| # Remove existing cache directory if it exists | |
| if CACHE_DIR.exists(): | |
| print(f"Removing existing cache directory: {CACHE_DIR}") | |
| shutil.rmtree(CACHE_DIR) | |
| # Create fresh cache directory | |
| CACHE_DIR.mkdir(parents=True, exist_ok=True) | |
| print(f"Created fresh cache directory: {CACHE_DIR}") | |
| return str(CACHE_DIR) | |
| def start_phoenix(project_name: str = APP_NAME) -> None: | |
| """Setup Phoenix tracing for the agent. | |
| Args: | |
| project_name: Name of the project to use for Phoenix tracing | |
| """ | |
| register( | |
| project_name=project_name, | |
| auto_instrument=True, | |
| ) | |
| logging.getLogger("openinference").setLevel(logging.CRITICAL) | |
| print(f"Phoenix tracing enabled for project: {project_name}") | |