bgaultier commited on
Commit
2233b04
·
verified ·
1 Parent(s): 551736f

Moved to codestral from RAGaRenn

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
@@ -19,6 +19,8 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
19
  """
20
  return "What magic will you build ?"
21
 
 
 
22
  @tool
23
  def get_current_time_in_timezone(timezone: str) -> str:
24
  """A tool that fetches the current local time in a specified timezone.
@@ -36,35 +38,37 @@ def get_current_time_in_timezone(timezone: str) -> str:
36
 
37
 
38
  final_answer = FinalAnswerTool()
39
- visit_webpage = VisitWebpageTool()
40
 
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
 
52
  # Import tool from Hub
53
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
 
54
 
55
  with open("prompts.yaml", 'r') as stream:
56
  prompt_templates = yaml.safe_load(stream)
57
 
58
  agent = CodeAgent(
59
  model=model,
60
- tools=[visit_webpage, final_answer], ## add your tools here (don't remove final answer)
61
- max_steps=6,
62
  verbosity_level=1,
63
  grammar=None,
64
  planning_interval=None,
65
  name=None,
66
  description=None,
67
- prompt_templates=prompt_templates
 
68
  )
69
 
70
 
 
1
+ from smolagents import CodeAgent,DuckDuckGoSearchTool, OpenAIServerModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
 
19
  """
20
  return "What magic will you build ?"
21
 
22
+
23
+
24
  @tool
25
  def get_current_time_in_timezone(timezone: str) -> str:
26
  """A tool that fetches the current local time in a specified timezone.
 
38
 
39
 
40
  final_answer = FinalAnswerTool()
 
41
 
42
+ RAGARENN_BASE_URL = "https://ragarenn.eskemm-numerique.fr/sso/ch@t/api/"
 
43
 
44
+ model = OpenAIServerModel(
45
+ model_id="codestral:latest",
46
+ api_base=RAGARENN_BASE_URL, # your OpenAI-compatible base URL
47
+ api_key=os.getenv("RAGARENN_API_KEY"),
48
+ temperature=0.95,
49
+ max_tokens=2048,
50
+ flatten_messages_as_text=True, # key workaround for picky servers
51
  )
52
 
53
 
54
  # Import tool from Hub
55
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
56
+ visit_webpage_tool = VisitWebpageTool()
57
 
58
  with open("prompts.yaml", 'r') as stream:
59
  prompt_templates = yaml.safe_load(stream)
60
 
61
  agent = CodeAgent(
62
  model=model,
63
+ tools=[visit_webpage_tool, final_answer], ## add your tools here (don't remove final answer)
64
+ max_steps=16,
65
  verbosity_level=1,
66
  grammar=None,
67
  planning_interval=None,
68
  name=None,
69
  description=None,
70
+ prompt_templates=prompt_templates,
71
+ additional_authorized_imports=["json", "requests", "bs4"]
72
  )
73
 
74