qaolin commited on
Commit
9aba3b9
·
1 Parent(s): b24b394

Wikitool and agent model to gemini

Browse files
.devcontainer/devcontainer.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "image": "pytorch/pytorch",
3
+ "runArgs": [
4
+ "--network=host"
5
+ ],
6
+ "postCreateCommand": "pip install -r /workspaces/qaolin_Final_Assignment/requirements.txt"
7
+ }
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .env
2
+ test*
agents/BasicAgent.py CHANGED
@@ -1,7 +1,7 @@
1
  import os
2
 
3
- from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, HfApiModel
4
-
5
 
6
  class BasicAgent(CodeAgent):
7
  def __init__(self):
@@ -16,19 +16,21 @@ class BasicAgent(CodeAgent):
16
  print(f"LLM Config: Model='{model_name}'")
17
 
18
  try:
19
- llm = HfApiModel(
20
- model_id=model_name,
21
- temperature=0.1,
22
- )
23
  except Exception as e:
24
  print(f"Error initializing LLM: {e}")
25
  raise
26
 
 
27
  print("Initializing tools...")
28
  try:
29
  search_tool = DuckDuckGoSearchTool()
30
  visit_tool = VisitWebpageTool()
31
- tools = [search_tool, visit_tool]
 
32
  print(f"Tools initialized: {[tool.name for tool in tools]}")
33
  except Exception as e:
34
  print(f"Error initializing tools: {e}")
 
1
  import os
2
 
3
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, HfApiModel, LiteLLMModel, Tool
4
+ from langchain_community.tools.wikidata.tool import WikidataAPIWrapper, WikidataQueryRun
5
 
6
  class BasicAgent(CodeAgent):
7
  def __init__(self):
 
16
  print(f"LLM Config: Model='{model_name}'")
17
 
18
  try:
19
+ llm = LiteLLMModel(
20
+ model_id=model_name,
21
+ api_key=os.environ.get("GEMINI_API_KEY", "")
22
+ )
23
  except Exception as e:
24
  print(f"Error initializing LLM: {e}")
25
  raise
26
 
27
+ # TOOLS
28
  print("Initializing tools...")
29
  try:
30
  search_tool = DuckDuckGoSearchTool()
31
  visit_tool = VisitWebpageTool()
32
+ wikidata = Tool.from_langchain(WikidataQueryRun(api_wrapper=WikidataAPIWrapper()))
33
+ tools = [search_tool, visit_tool, wikidata]
34
  print(f"Tools initialized: {[tool.name for tool in tools]}")
35
  except Exception as e:
36
  print(f"Error initializing tools: {e}")
requirements.txt CHANGED
@@ -4,4 +4,8 @@ huggingface_hub
4
  python-dotenv
5
  requests
6
  smolagents
7
- smolagents[litellm]
 
 
 
 
 
4
  python-dotenv
5
  requests
6
  smolagents
7
+ smolagents[litellm]
8
+ langchain-community
9
+ wikibase-rest-api-client
10
+ mediawikiapi
11
+ litellm==1.67.2