CoolFace
Apppublic

fabmin/First_agent_template_test

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
app.py42 linesDownload Raw Back to root
1from smolagents import CodeAgent, load_tool2import datetime3import requests4import pytz5import yaml6from tools.final_answer import FinalAnswerTool7 8# For Ollama, we'll create a custom model class9class OllamaModel:10    def __init__(self, host="http://localhost:11434"):11        self.host = host12        13    def chat_completion(self, messages, **kwargs):14        response = requests.post(15            f"{self.host}/api/chat",16            json={17                "model": "qwen2-coder-7b-instruct",18                "messages": messages,19                "stream": False20            }21        )22        return response.json()23 24# Initialize your model25model = OllamaModel()26 27# Rest of your code remains the same28final_answer = FinalAnswerTool()29image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)30 31with open("prompts.yaml", 'r') as stream:32    prompt_templates = yaml.safe_load(stream)33 34agent = CodeAgent(35    model=model,36    tools=[final_answer, image_generation_tool],37    max_steps=6,38    verbosity_level=1,39    prompt_templates=prompt_templates40)41 42GradioUI(agent).launch()