Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,12 +5,15 @@ from smolagents import CodeAgent, InferenceClientModel
|
|
| 5 |
from smolagents import DuckDuckGoSearchTool, Tool
|
| 6 |
from diffusers import DiffusionPipeline
|
| 7 |
import torch
|
|
|
|
| 8 |
|
| 9 |
from huggingface_hub import login
|
| 10 |
import os
|
| 11 |
|
| 12 |
token = os.environ.get("HF_TOKEN")
|
| 13 |
print(token)
|
|
|
|
|
|
|
| 14 |
if token:
|
| 15 |
login(token=token)
|
| 16 |
else:
|
|
@@ -83,6 +86,15 @@ search_tool = DuckDuckGoSearchTool()
|
|
| 83 |
#llm_engine = InferenceClientModel("Qwen/Qwen2.5-72B-Instruct")
|
| 84 |
|
| 85 |
llm_engine = InferenceClientModel("Qwen/Qwen2.5-Coder-32B-Instruct")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
agent = CodeAgent(tools=[image_generation_tool, search_tool], model=llm_engine)
|
| 87 |
|
| 88 |
# =========================================================
|
|
|
|
| 5 |
from smolagents import DuckDuckGoSearchTool, Tool
|
| 6 |
from diffusers import DiffusionPipeline
|
| 7 |
import torch
|
| 8 |
+
from smolagents import OpenAIServerModel
|
| 9 |
|
| 10 |
from huggingface_hub import login
|
| 11 |
import os
|
| 12 |
|
| 13 |
token = os.environ.get("HF_TOKEN")
|
| 14 |
print(token)
|
| 15 |
+
|
| 16 |
+
openai_token= os.environ.get("OPENAI_API_KEY")
|
| 17 |
if token:
|
| 18 |
login(token=token)
|
| 19 |
else:
|
|
|
|
| 86 |
#llm_engine = InferenceClientModel("Qwen/Qwen2.5-72B-Instruct")
|
| 87 |
|
| 88 |
llm_engine = InferenceClientModel("Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 89 |
+
|
| 90 |
+
# Inicialização do modelo OpenAI com smolagents
|
| 91 |
+
llm_engine = OpenAIServerModel(
|
| 92 |
+
model_id="gpt-4o-mini", # Exemplo: ajuste para o modelo OpenAI que deseja usar
|
| 93 |
+
api_base="https://api.openai.com/v1",
|
| 94 |
+
api_key=openai_token
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
agent = CodeAgent(tools=[image_generation_tool, search_tool], model=llm_engine)
|
| 99 |
|
| 100 |
# =========================================================
|