Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,7 +44,21 @@ from smolagents.agent_types import AgentText, AgentImage, AgentAudio
|
|
| 44 |
from smolagents.gradio_ui import pull_messages_from_step, handle_agent_output_types
|
| 45 |
|
| 46 |
from smolagents import Tool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
|
|
|
| 48 |
|
| 49 |
class GoogleSearchTool(Tool):
|
| 50 |
name = "web_search"
|
|
|
|
| 44 |
from smolagents.gradio_ui import pull_messages_from_step, handle_agent_output_types
|
| 45 |
|
| 46 |
from smolagents import Tool
|
| 47 |
+
from huggingface_hub import InferenceClient
|
| 48 |
+
def hf_chat(api_key, model, text):
|
| 49 |
+
client = InferenceClient(api_key=api_key)
|
| 50 |
+
messages = [
|
| 51 |
+
{
|
| 52 |
+
"role": "user",
|
| 53 |
+
"content": text,
|
| 54 |
+
}
|
| 55 |
+
]
|
| 56 |
+
|
| 57 |
+
stream = client.chat.completions.create(
|
| 58 |
+
model=model, messages=messages, max_tokens=6000, stream=False
|
| 59 |
+
)
|
| 60 |
|
| 61 |
+
return stream.choices[0].message.content
|
| 62 |
|
| 63 |
class GoogleSearchTool(Tool):
|
| 64 |
name = "web_search"
|