bitcloud2's picture
working app_dev. hopefully working app
b0ed2e6
Raw
History Blame Contribute Delete
1.46 kB
import math
import os
import re
from bs4 import BeautifulSoup
import httpx
from smolagents import CodeAgent
from tools import search_tool
from gemini_model import GeminiApiModel
class SmolAgent:
"""
A simple agent using the custom GeminiApiModel.
Replace the __call__ method with your actual agent logic
using Hugging Face libraries (e.g., smolagents, transformers, inference API).
"""
def __init__(self):
model = GeminiApiModel(model_id="gemini-2.0-flash")
self.agent = CodeAgent(
tools=[search_tool],
model=model,
max_steps=5,
verbosity_level=0,
additional_authorized_imports=["httpx", "math", "os", "re", "bs4"],
)
print("SmolAgent initialized with GeminiApiModel.")
# Initialize any required components here
# e.g., load a model, tokenizer, setup API clients
def __call__(self, question: str) -> str:
"""
Processes the input question and returns an answer.
This is where the core agent logic should reside.
"""
print(f"SmolAgent received question (first 50 chars): {question[:50]}...")
# --- Agent Logic ---
# The CodeAgent will now use GeminiApiModel internally
answer = self.agent.run(question)
# -------------------------
print(f"SmolAgent returning answer (first 50 chars): {str(answer)[:50]}...")
return str(answer)