File size: 1,143 Bytes
a85a69f
 
 
 
195cc5c
a85a69f
7595a2c
a85a69f
 
c743288
 
 
 
a85a69f
c743288
a85a69f
 
 
7595a2c
c743288
 
a85a69f
 
 
 
c743288
 
a85a69f
 
 
c743288
 
a85a69f
 
195cc5c
c743288
195cc5c
 
c743288
195cc5c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""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)