Spaces:
Sleeping
Sleeping
Update agent.py
Browse files1234567891011121314151617181920212223247 unmodified lines3233343536import os# from transformers import pipeline # No longer directly using pipeline here# NEW IMPORTS for smolagentsfrom smolagents import CodeAgent, DuckDuckGoSearchToolfrom smolagents import TransformersModel # To use your local Hugging Face modelclass GaiaAgent:def __init__(self, model_id: str = "google/flan-t5-large"):# Initialize your LLM using smolagents's TransformersModel# This is the crucial part. Flan-T5 is a 'text2text-generation' model.# TransformersModel probably builds a pipeline, which needs the correct task.self.llm_model = TransformersModel(model_id=model_id,# Specify the task type for Flan-T5 modelstask="text2text-generation",# You might need to add device mapping if running into memory issues# e.g., device_map="auto" if on GPU)# Initialize the smolagents CodeAgentself.agent = CodeAgent(model=self.llm_model,tools=[DuckDuckGoSearchTool()],7 unmodified linesreturn responseexcept Exception as e:return f"An error occurred during agent processing: {e}"1234567891011121314151617187 unmodified lines26272829import osfrom smolagents import CodeAgent, DuckDuckGoSearchToolfrom smolagents import TransformersModelclass GaiaAgent:def __init__(self, model_id: str = "HuggingFaceH4/zephyr-7b-beta"): # <-- CHANGE MODEL HEREself.llm_model = TransformersModel(model_id=model_id,# For Zephyr (a causal LM), the default `AutoModelForCausalLM` works,# and `task="text-generation"` is appropriate for the pipeline.task="text-generation",# You might need device_map="auto" if you hit memory issues or have GPU:# device_map="auto")self.agent = CodeAgent(model=self.llm_model,tools=[DuckDuckGoSearchTool()],7 unmodified linesreturn responseexcept Exception as e:return f"An error occurred during agent processing: {e}"
agent.py+7-14