Amalia commited on
Commit ·
8a4e9dd
1
Parent(s): 574f383
try litellmmodel
Browse files4 unmodified lines56789101181 unmodified lines939495969798991001011021031041054 unmodified linesimport inspectimport pandas as pdfrom typing import Dict, Listfrom smolagents import CodeAgent, tool, InferenceClientModelfrom langchain_community.tools.tavily_search import TavilySearchResultsfrom langchain_community.document_loaders import WikipediaLoader, ArxivLoader81 unmodified lines# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------class BasicAgent:def __init__(self):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,)print("BasicAgent initialized.")def __call__(self, question: str) -> str:print(f"Agent received question (first 50 chars): {question[:50]}...")4 unmodified lines56789101181 unmodified lines939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401414 unmodified linesimport inspectimport pandas as pdfrom typing import Dict, Listfrom smolagents import CodeAgent, LiteLLMModel, tool, InferenceClientModel, WikipediaSearchTool, VisitWebpageTool, DuckDuckGoSearchToolfrom langchain_community.tools.tavily_search import TavilySearchResultsfrom langchain_community.document_loaders import WikipediaLoader, ArxivLoader81 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 coursesystem_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"# 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 LiteLLMModelmodel = LiteLLMModel(model_id="openai/gpt-4o-mini", api_key=os.getenv("OPENAI_API_KEY"),# temperature=DEFAULT_TEMPERATURE,max_retries=3)self.agent = CodeAgent(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