Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,14 +6,7 @@ from typing import List, Dict, Any, Union
|
|
6 |
import gradio as gr
|
7 |
from gradio.components.chatbot import ChatMessage
|
8 |
from anthropic import Anthropic
|
9 |
-
|
10 |
-
# Try to import smolagents MCP client, fallback to basic implementation
|
11 |
-
try:
|
12 |
-
from smolagents import MCPClient
|
13 |
-
SMOLAGENTS_AVAILABLE = True
|
14 |
-
except ImportError:
|
15 |
-
SMOLAGENTS_AVAILABLE = False
|
16 |
-
print("Warning: smolagents not available. Please install with: pip install smolagents")
|
17 |
|
18 |
class MCPClientWrapper:
|
19 |
def __init__(self):
|
@@ -39,12 +32,10 @@ class MCPClientWrapper:
|
|
39 |
|
40 |
# Make a small test request to validate the key
|
41 |
test_response = test_client.messages.create(
|
42 |
-
model="claude-
|
43 |
-
max_tokens=10,
|
44 |
messages=[{"role": "user", "content": "Hi"}]
|
45 |
)
|
46 |
|
47 |
-
# If we get here, the key is valid
|
48 |
self.api_key = api_key
|
49 |
self.anthropic = test_client
|
50 |
return "✅ Anthropic API key validated and set successfully"
|
@@ -332,7 +323,6 @@ def gradio_interface():
|
|
332 |
msg.submit(client.process_message, [msg, chatbot], [chatbot, msg])
|
333 |
clear_btn.click(lambda: [], None, chatbot)
|
334 |
|
335 |
-
|
336 |
return demo
|
337 |
|
338 |
if __name__ == "__main__":
|
|
|
6 |
import gradio as gr
|
7 |
from gradio.components.chatbot import ChatMessage
|
8 |
from anthropic import Anthropic
|
9 |
+
from smolagents import MCPClient
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
class MCPClientWrapper:
|
12 |
def __init__(self):
|
|
|
32 |
|
33 |
# Make a small test request to validate the key
|
34 |
test_response = test_client.messages.create(
|
35 |
+
model="claude-sonnet-4-20250514",
|
|
|
36 |
messages=[{"role": "user", "content": "Hi"}]
|
37 |
)
|
38 |
|
|
|
39 |
self.api_key = api_key
|
40 |
self.anthropic = test_client
|
41 |
return "✅ Anthropic API key validated and set successfully"
|
|
|
323 |
msg.submit(client.process_message, [msg, chatbot], [chatbot, msg])
|
324 |
clear_btn.click(lambda: [], None, chatbot)
|
325 |
|
|
|
326 |
return demo
|
327 |
|
328 |
if __name__ == "__main__":
|