bstraehle commited on
Commit
8df193a
·
verified ·
1 Parent(s): a64b881

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +26 -2
agent.py CHANGED
@@ -1,4 +1,4 @@
1
- import os
2
 
3
  from smolagents import (
4
  CodeAgent,
@@ -33,4 +33,28 @@ def run_agent(level, question, file_name, ground_truth):
33
  return answer, str(answer == ground_truth)
34
 
35
  get_final_answer(question, answer):
36
- return "Final answer"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from openai import OpenAI
2
 
3
  from smolagents import (
4
  CodeAgent,
 
33
  return answer, str(answer == ground_truth)
34
 
35
  get_final_answer(question, answer):
36
+ client = OpenAI()
37
+
38
+ prompt = """
39
+ You are given a question and a preliminary answer:
40
+ Question: {question}
41
+ Preliminary answer: {answer}
42
+ You must give the precise answer requested. Do not include explanations, steps, reasoning, or additional text. Be direct and specific.
43
+ For example, if asked "What is the capital of France?", respond simply with "Paris".
44
+ """
45
+
46
+ completion = client.chat.completions.create(
47
+ max_tokens = 1000,
48
+ messages = [{"role": "user",
49
+ "content": [{"type": "text", "text": prompt}],
50
+ model = MODEL_ID,
51
+ temperature = 0.0
52
+ )
53
+
54
+ content = completion.choices[0].message.content
55
+
56
+ print("###")
57
+ print(content)
58
+ print("###")
59
+
60
+ return content