zonca commited on
Commit
563885e
·
1 Parent(s): d71aa4c

system prompt and use zephyr

Browse files
Files changed (1) hide show
  1. app.py +21 -6
app.py CHANGED
@@ -5,24 +5,39 @@ import inspect
5
  import pandas as pd
6
 
7
  # Updated smolagents import
8
- from smolagents import CodeAgent, DuckDuckGoSearchTool
 
 
 
 
9
 
10
  # (Keep Constants as is)
11
  # --- Constants ---
12
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
13
 
14
 
 
 
 
 
 
 
 
 
 
 
15
  class MyAgent:
16
  def __init__(self):
17
  print("MyAgent initialized.")
18
- # Standard tools for CodeAgent
19
  self.tools = [DuckDuckGoSearchTool()]
20
- # You can add more tools if needed
21
- self.agent = CodeAgent(tools=self.tools)
 
22
 
23
  def __call__(self, question: str) -> str:
24
- # Use the agent to answer the question
25
- result = self.agent.run(question)
 
26
  return result
27
 
28
 
 
5
  import pandas as pd
6
 
7
  # Updated smolagents import
8
+ from smolagents import (
9
+ CodeAgent,
10
+ DuckDuckGoSearchTool,
11
+ HfApiModel,
12
+ ) # Add HfApiModel import
13
 
14
  # (Keep Constants as is)
15
  # --- Constants ---
16
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
17
 
18
 
19
+ SYSTEM_PROMPT = (
20
+ "You are a general AI assistant. I will ask you a question. "
21
+ "Report your thoughts, and finish your answer with the following template: "
22
+ "FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. "
23
+ "If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. "
24
+ "If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. "
25
+ "If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string."
26
+ )
27
+
28
+
29
  class MyAgent:
30
  def __init__(self):
31
  print("MyAgent initialized.")
 
32
  self.tools = [DuckDuckGoSearchTool()]
33
+ # Use the specified model
34
+ self.model = HfApiModel(repo_id="HuggingFaceH4/zephyr-7b-beta")
35
+ self.agent = CodeAgent(tools=self.tools, model=self.model)
36
 
37
  def __call__(self, question: str) -> str:
38
+ # Prepend the system prompt to the question
39
+ prompt = f"{SYSTEM_PROMPT}\n\nQuestion: {question}"
40
+ result = self.agent.run(prompt)
41
  return result
42
 
43