Davit6174 commited on
Commit
adf311c
·
verified ·
1 Parent(s): 3aeb007

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -39,26 +39,23 @@ class ZephyrAPI:
39
  "Authorization": f"Bearer {os.getenv('HF_TOKEN')}"
40
  }
41
  self.tool_descriptions = self.format_tools(tools or [])
42
- print("ZephyrAPI initialized using Inference API.")
43
 
44
  def format_tools(self, tools):
45
  return "\n".join([f"- {tool.name}: {tool.description}" for tool in tools])
46
 
47
  def __call__(self, question: str, scratchpad: str = "") -> str:
48
  prompt = f"""<|system|>
49
- You are a smart agent that can reason step-by-step and use tools when necessary.
 
 
 
 
 
50
 
51
  Available tools:
52
  {self.tool_descriptions}
53
 
54
- Respond with this format:
55
- Thought: do I need to use a tool?
56
- Action: tool_name
57
- Action Input: "input"
58
- Observation: tool result
59
- ... (repeat if needed)
60
- Final Answer: your final answer to the user
61
-
62
  <|user|>
63
  {question}
64
 
@@ -67,7 +64,7 @@ class ZephyrAPI:
67
  payload = {
68
  "inputs": prompt,
69
  "parameters": {
70
- "max_new_tokens": 256,
71
  "temperature": 0.7,
72
  "top_p": 0.9,
73
  }
 
39
  "Authorization": f"Bearer {os.getenv('HF_TOKEN')}"
40
  }
41
  self.tool_descriptions = self.format_tools(tools or [])
42
+ print(f"ZephyrAPI initialized using Inference API. with tools {self.tool_descriptions}")
43
 
44
  def format_tools(self, tools):
45
  return "\n".join([f"- {tool.name}: {tool.description}" for tool in tools])
46
 
47
  def __call__(self, question: str, scratchpad: str = "") -> str:
48
  prompt = f"""<|system|>
49
+ You are a general AI assistant. I will ask you a question.
50
+ Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
51
+ YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
52
+ 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.
53
+ 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.
54
+ 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.
55
 
56
  Available tools:
57
  {self.tool_descriptions}
58
 
 
 
 
 
 
 
 
 
59
  <|user|>
60
  {question}
61
 
 
64
  payload = {
65
  "inputs": prompt,
66
  "parameters": {
67
+ "max_new_tokens": 512,
68
  "temperature": 0.7,
69
  "top_p": 0.9,
70
  }