liamtk commited on
Commit
cf092a5
·
verified ·
1 Parent(s): 117db51

try local ollama

Browse files
Files changed (1) hide show
  1. app.py +23 -18
app.py CHANGED
@@ -1,10 +1,11 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
 
 
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
@@ -40,13 +41,16 @@ web_search = DuckDuckGoSearchTool()
40
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
41
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
42
 
43
- model = HfApiModel(
44
- max_tokens=2096,
45
- temperature=0.5,
46
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
47
- custom_role_conversions=None,
48
- )
49
 
 
 
 
50
 
51
  # Import tool from Hub
52
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
@@ -54,17 +58,18 @@ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_co
54
  with open("prompts.yaml", 'r') as stream:
55
  prompt_templates = yaml.safe_load(stream)
56
 
57
- agent = CodeAgent(
58
- model=model,
59
- tools=[final_answer, web_search, image_generation_tool], ## add your tools here (don't remove final answer)
60
- max_steps=6,
61
- verbosity_level=1,
62
- grammar=None,
63
- planning_interval=None,
64
- name=None,
65
- description=None,
66
- prompt_templates=prompt_templates
67
- )
68
 
 
69
 
70
  GradioUI(agent).launch()
 
1
+ from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool,LiteLLMModel
2
  import datetime
3
  import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
 
8
+
9
  from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
 
41
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
42
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
43
 
44
+ # model = HfApiModel(
45
+ # max_tokens=2096,
46
+ # temperature=0.5,
47
+ # model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
48
+ # custom_role_conversions=None,
49
+ # )
50
 
51
+ model = LiteLLMModel(
52
+ model_id='ollama_chat/qwen2.5:14b'
53
+ )
54
 
55
  # Import tool from Hub
56
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
 
58
  with open("prompts.yaml", 'r') as stream:
59
  prompt_templates = yaml.safe_load(stream)
60
 
61
+ # agent = CodeAgent(
62
+ # model=model,
63
+ # tools=[final_answer, web_search, image_generation_tool], ## add your tools here (don't remove final answer)
64
+ # max_steps=6,
65
+ # verbosity_level=1,
66
+ # grammar=None,
67
+ # planning_interval=None,
68
+ # name=None,
69
+ # description=None,
70
+ # prompt_templates=prompt_templates
71
+ # )
72
 
73
+ agent = CodeAgent(tools=[web_search], model=model)
74
 
75
  GradioUI(agent).launch()