Spaces:
Runtime error
Runtime error
File size: 809 Bytes
d87e33a 6f2e40d d87e33a 6f2e40d 3711b4f d87e33a 8140829 d87e33a 6f2e40d d87e33a 6f2e40d 9f8247b d87e33a 6f2e40d d87e33a 6f2e40d 4a79093 d87e33a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import json
from smolagents.agents import MultiStepAgent
from smolagents.models import HfApiModel # <- important, c'est le vrai model object
from Gradio_UI import GradioUI
# Charge la config de l'agent
with open("agent.json") as f:
agent_config = json.load(f)
# Instancie le modèle
model_cfg = agent_config.get("model", {})
model = HfApiModel(
model_id=model_cfg["data"]["model_id"],
max_tokens=model_cfg["data"].get("max_tokens", 2048),
temperature=model_cfg["data"].get("temperature", 0.5),
)
# Initialise l'agent
agent = MultiStepAgent(
tools=agent_config.get("tools", []),
model=model,
prompt_config_path="prompts.yaml",
max_steps=agent_config.get("max_steps", 6),
)
# Lance l'interface Gradio
ui = GradioUI(agent, file_upload_folder="uploads")
ui.launch(share=True)
|