Spaces:
Sleeping
Sleeping
File size: 1,015 Bytes
04be80a c19d193 6aae614 9b5b26a 04be80a 6aae614 ae7a494 04be80a e121372 aeb2e71 13d500a 8c01ffb 04be80a 9b5b26a 8c01ffb 04be80a 861422e 04be80a 8c01ffb 8fe992b 04be80a aeb2e71 7a80b44 8c01ffb 861422e 8fe992b 04be80a 7a80b44 | 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 30 31 32 33 34 | from smolagents import CodeAgent, HfApiModel, load_tool
import yaml
from tools.final_answer import FinalAnswerTool
from Gradio_UI import GradioUI
# Initialize the mandatory final answer tool
final_answer = FinalAnswerTool()
# Set up the AI model connection
model = HfApiModel(
max_tokens=2096,
temperature=0.5,
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
)
# Import the image generation tool from the Hugging Face Hub
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
# Load the prompt templates from your prompts.yaml file
with open("prompts.yaml", 'r') as stream:
prompt_templates = yaml.safe_load(stream)
# Create the agent and provide it with the correct tools
agent = CodeAgent(
model=model,
# Ensure both the image tool and final answer tool are in this list
tools=[image_generation_tool, final_answer],
max_steps=6,
verbosity_level=1,
prompt_templates=prompt_templates
)
# Launch the user interface
GradioUI(agent).launch() |