Spaces:
Runtime error
Runtime error
| import json | |
| from datetime import datetime | |
| from pathlib import Path | |
| LOG_PATH = Path("logs/mcp_log.jsonl") | |
| LOG_PATH.parent.mkdir(parents=True, exist_ok=True) | |
| def log_mcp_entry(agent_id: str, user_query: str, response: str, model_name: str, base_url: str): | |
| entry = { | |
| "timestamp": datetime.utcnow().isoformat(), | |
| "agent_id": agent_id, | |
| "user_query": user_query, | |
| "response": response, | |
| "model_name": model_name, | |
| "base_url": base_url | |
| } | |
| with open(LOG_PATH, "a", encoding="utf-8") as f: | |
| f.write(json.dumps(entry) + "\n") | |