Mike Jay commited on
Commit
c743288
Β·
1 Parent(s): a85a69f

runs but guest info tool needs debuging

Browse files
Files changed (4) hide show
  1. .gitignore +1 -0
  2. app.py +21 -9
  3. retriever.py β†’ guest_info.py +1 -1
  4. requirements.txt +3 -1
.gitignore CHANGED
@@ -1,5 +1,6 @@
1
  # omit IDE configs
2
  .vscode/settings.json
 
3
 
4
  # OS clutter
5
  **/.DS_Store
 
1
  # omit IDE configs
2
  .vscode/settings.json
3
+ .gradio
4
 
5
  # OS clutter
6
  **/.DS_Store
app.py CHANGED
@@ -2,28 +2,40 @@
2
 
3
  import os
4
 
5
- from smolagents import GradioUI, CodeAgent, InferenceClientModel
6
 
7
- from retriever import load_guest_dataset
8
 
9
- OPENAI_API_KEY = os.environ["OPENAI_API_KEY"]
10
- BASE_URL = os.environ["BASE_URL"]
11
 
 
 
 
 
12
 
13
- model = InferenceClientModel(api_key=OPENAI_API_KEY, base_url=BASE_URL)
14
 
15
 
16
  # Load the guest dataset and initialize the guest info tool
17
- guest_info_tool = load_guest_dataset()
 
 
18
 
19
  # Create Alfred with all the tools
20
  alfred = CodeAgent(
21
- tools=[guest_info_tool],
22
  model=model,
23
- add_base_tools=True, # Add any additional base tools
 
24
  planning_interval=3, # Enable planning every 3 steps
25
  )
26
 
 
 
27
 
28
  if __name__ == "__main__":
29
- GradioUI(alfred).launch()
 
 
 
 
 
 
 
2
 
3
  import os
4
 
5
+ from smolagents import CodeAgent, OpenAIServerModel, FinalAnswerTool
6
 
7
+ from guest_info import guest_info_tool_factory
8
 
 
 
9
 
10
+ MODEL_ID = os.environ["MODEL_ID"]
11
+ BASE_URL = os.environ["BASE_URL"]
12
+ API_KEY = os.environ["OPENAI_API_KEY"]
13
+ API_BASE = "/".join([BASE_URL, "v1"])
14
 
15
+ model = OpenAIServerModel(model_id=MODEL_ID, api_base=API_BASE, api_key=API_KEY)
16
 
17
 
18
  # Load the guest dataset and initialize the guest info tool
19
+ guest_info_tool = guest_info_tool_factory()
20
+
21
+ final_answer_tool = FinalAnswerTool()
22
 
23
  # Create Alfred with all the tools
24
  alfred = CodeAgent(
 
25
  model=model,
26
+ tools=[guest_info_tool, final_answer_tool],
27
+ add_base_tools=False, # Add any additional base tools
28
  planning_interval=3, # Enable planning every 3 steps
29
  )
30
 
31
+ # Question for agent
32
+ # Tell me about our guest named 'Lady Ada Lovelace'
33
 
34
  if __name__ == "__main__":
35
+ # GradioUI(alfred).launch(share=False)
36
+
37
+ # Example query Alfred might receive during the gala
38
+ response = alfred.run("Tell me about our guest named 'Lady Ada Lovelace'.")
39
+
40
+ print("🎩 Alfred's Response:")
41
+ print(response)
retriever.py β†’ guest_info.py RENAMED
@@ -30,7 +30,7 @@ class GuestInfoRetrieverTool(Tool):
30
  return "No matching guest information found."
31
 
32
 
33
- def load_guest_dataset():
34
  """Load the dataset"""
35
 
36
  DATASETS = [ # pylint: disable=invalid-name
 
30
  return "No matching guest information found."
31
 
32
 
33
+ def guest_info_tool_factory():
34
  """Load the dataset"""
35
 
36
  DATASETS = [ # pylint: disable=invalid-name
requirements.txt CHANGED
@@ -1,3 +1,5 @@
1
  datasets
 
2
  langchain-community
3
- smolagents
 
 
1
  datasets
2
+ duckduckgo-search
3
  langchain-community
4
+ rank_bm25
5
+ smolagents[litellm]