Update app.py
Browse files10 unmodified lines111213141516141516171819202123242223242526272829303110 unmodified lines# --- Basic Agent Definition ---# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
from smolagents import CodeAgentfrom smolagents.models import OpenAIChatfrom my_tools import my_tool_list # 你需要新建/补全这个模块和列表from smolagents import CodeAgent, LiteLLMModel from my_tools import my_tool_list
class BasicAgent: def __init__(self): api_key = os.getenv("OPENAI_API_KEY") # ← 这里自动读取环境变量 if not api_key: raise ValueError("OPENAI_API_KEY not set in environment variables!") self.model = OpenAIChat(model="gpt-4o", api_key=api_key) self.agent = CodeAgent(model=self.model, tools=my_tool_list, max_steps=6) model = LiteLLMModel( model_id="gpt-4o", api_key=api_key ) self.agent = CodeAgent(model=model, tools=my_tool_list, max_steps=6)
def __call__(self, question: str) -> str:app.py+9-5