Amalia commited on
Commit ·
8a4e9dd
1
Parent(s): 574f383
try litellmmodel
Browse files4 unmodified lines567889101181 unmodified lines939495969798991001011021031041051061071081091101111121131149611511611711811912012112212312412512612798991001011281291301311321331341351361371381391401414 unmodified linesimport inspectimport pandas as pdfrom typing import Dict, Listfrom smolagents import CodeAgent, tool, InferenceClientModelfrom smolagents import CodeAgent, LiteLLMModel, tool, InferenceClientModel, WikipediaSearchTool, VisitWebpageTool, DuckDuckGoSearchToolfrom langchain_community.tools.tavily_search import TavilySearchResultsfrom langchain_community.document_loaders import WikipediaLoader, ArxivLoader
81 unmodified lines# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------class BasicAgent: def __init__(self): model = LiteLLMModel(model_id=config.CLAUDE_3_5_SONNET_MODEL_ID, api_key=ANTHROPIC_API_KEY, temperature=DEFAULT_TEMPERATURE, max_retries=3) # System prompt recommended by GAIA benchmark instruction https://huggingface.co/spaces/gaia-benchmark/leaderboard # Emitting the part of final answer, as instructed by the HF course system_prompt = """ You are a general AI assistant. I will ask you a question. Report your thoughts. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string. """ # # Init agent with InferenceClientModel model_id = "Qwen/Qwen3-32B" # model_id = "Qwen/Qwen3-32B" # self.agent = CodeAgent( # model=InferenceClientModel(model_id=model_id, token=os.getenv("HF_TOKEN")), # tools=[multiply, add, subtract, modulus, web_search, arxiv_search, wikipedia_search], # max_steps=10, # verbosity_level=2, # )
# Init agent with LiteLLMModel model = LiteLLMModel(model_id="openai/gpt-4o-mini", api_key=os.getenv("OPENAI_API_KEY"), # temperature=DEFAULT_TEMPERATURE, max_retries=3) self.agent = CodeAgent( model=InferenceClientModel(model_id=model_id, token=os.getenv("HF_TOKEN")), tools=[multiply, add, subtract, modulus, web_search, arxiv_search, wikipedia_search], max_steps=10, verbosity_level=2, tools=[ multiply, add, subtract, modulus, web_search, arxiv_search, wikipedia_search, WikipediaSearchTool(), DuckDuckGoSearchTool(), VisitWebpageTool() ], model=model, # planning_interval=DEFAULT_PLANNING_INTERVAL, # step_callbacks=[generation_error_interrupter] )
print("BasicAgent initialized.") def __call__(self, question: str) -> str: print(f"Agent received question (first 50 chars): {question[:50]}...")app.py+42-6