Spaces:
Runtime error
Runtime error
"""Application File""" | |
import os | |
from smolagents import CodeAgent, OpenAIServerModel, FinalAnswerTool, GradioUI | |
from guest_info_retriever import guest_info_retriever_factory | |
MODEL_ID = os.environ["MODEL_ID"] | |
BASE_URL = os.environ["BASE_URL"] | |
API_KEY = os.environ["OPENAI_API_KEY"] | |
API_BASE = "/".join([BASE_URL, "v1"]) | |
model = OpenAIServerModel(model_id=MODEL_ID, api_base=API_BASE, api_key=API_KEY) | |
# Load the guest dataset and initialize the guest info tool | |
guest_info_tool = guest_info_retriever_factory() | |
final_answer_tool = FinalAnswerTool() | |
# Create Alfred with all the tools | |
alfred = CodeAgent( | |
model=model, | |
tools=[guest_info_tool, final_answer_tool], | |
add_base_tools=False, # Add any additional base tools | |
planning_interval=3, # Enable planning every 3 steps | |
) | |
# Question for agent | |
# Tell me about our guest named 'Lady Ada Lovelace' | |
if __name__ == "__main__": | |
GradioUI(alfred).launch(share=False) | |
# # Example query Alfred might receive during the gala | |
# response = alfred.run("Tell me about our guest named 'Lady Ada Lovelace'.") | |
# print("π© Alfred's Response:") | |
# print(response) | |