Spaces:
Sleeping
Sleeping
Dmitry Kisselev commited on
Commit ·
3cc3e3f
1
Parent(s): 2bded1b
Initial deployment of customer support chatbot
Browse files
agent.py
CHANGED
|
@@ -11,6 +11,9 @@ class SupportAgent:
|
|
| 11 |
"""Customer support agent with MCP tool integration."""
|
| 12 |
|
| 13 |
def __init__(self, mcp_client: MCPClient, auth_handler: AuthHandler):
|
|
|
|
|
|
|
|
|
|
| 14 |
self.client = OpenAI(api_key=OPENAI_API_KEY)
|
| 15 |
self.model = OPENAI_MODEL
|
| 16 |
self.mcp_client = mcp_client
|
|
@@ -226,6 +229,9 @@ Be friendly, professional, and helpful. Provide clear, concise answers."""
|
|
| 226 |
|
| 227 |
try:
|
| 228 |
# Call OpenAI with tool calling
|
|
|
|
|
|
|
|
|
|
| 229 |
response = self.client.chat.completions.create(
|
| 230 |
model=self.model,
|
| 231 |
messages=messages,
|
|
@@ -295,6 +301,7 @@ Be friendly, professional, and helpful. Provide clear, concise answers."""
|
|
| 295 |
messages.append(message)
|
| 296 |
messages.extend(tool_results)
|
| 297 |
|
|
|
|
| 298 |
final_response = self.client.chat.completions.create(
|
| 299 |
model=self.model,
|
| 300 |
messages=messages
|
|
|
|
| 11 |
"""Customer support agent with MCP tool integration."""
|
| 12 |
|
| 13 |
def __init__(self, mcp_client: MCPClient, auth_handler: AuthHandler):
|
| 14 |
+
# Initialize OpenAI client
|
| 15 |
+
# Traces are automatically sent to OpenAI dashboard when using the Python SDK
|
| 16 |
+
# View them at: https://platform.openai.com/logs/traces
|
| 17 |
self.client = OpenAI(api_key=OPENAI_API_KEY)
|
| 18 |
self.model = OPENAI_MODEL
|
| 19 |
self.mcp_client = mcp_client
|
|
|
|
| 229 |
|
| 230 |
try:
|
| 231 |
# Call OpenAI with tool calling
|
| 232 |
+
# Traces are automatically sent to OpenAI dashboard
|
| 233 |
+
# View traces at: https://platform.openai.com/logs/traces
|
| 234 |
+
# All API calls are automatically traced - no additional configuration needed
|
| 235 |
response = self.client.chat.completions.create(
|
| 236 |
model=self.model,
|
| 237 |
messages=messages,
|
|
|
|
| 301 |
messages.append(message)
|
| 302 |
messages.extend(tool_results)
|
| 303 |
|
| 304 |
+
# Final response - automatically traced
|
| 305 |
final_response = self.client.chat.completions.create(
|
| 306 |
model=self.model,
|
| 307 |
messages=messages
|
config.py
CHANGED
|
@@ -16,5 +16,10 @@ MCP_SERVER_URL = os.getenv("MCP_SERVER_URL", "https://vipfapwm3x.us-east-1.awsap
|
|
| 16 |
HF_TOKEN = os.getenv("HF_TOKEN", "")
|
| 17 |
|
| 18 |
# OpenAI Model
|
| 19 |
-
OPENAI_MODEL = "gpt-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
|
|
|
| 16 |
HF_TOKEN = os.getenv("HF_TOKEN", "")
|
| 17 |
|
| 18 |
# OpenAI Model
|
| 19 |
+
OPENAI_MODEL = "gpt-4.1-mini"
|
| 20 |
+
|
| 21 |
+
# OpenAI Tracing Configuration
|
| 22 |
+
# Set OPENAI_TRACING=true to enable tracing (default: enabled)
|
| 23 |
+
# Tracing allows you to see detailed logs in OpenAI dashboard
|
| 24 |
+
OPENAI_TRACING = os.getenv("OPENAI_TRACING", "true").lower() == "true"
|
| 25 |
|