ameglei-external commited on
Commit
c3243f8
·
verified ·
1 Parent(s): f689ac1

Amending prompt - adding more examples for few shot learning

Browse files
Files changed (1) hide show
  1. app.py +24 -12
app.py CHANGED
@@ -70,7 +70,7 @@ class BasicAgent:
70
  1. **Thought:** Briefly outline your reasoning step.
71
  2. **Reflect:** Check “Did I use all observations? Did my tool call succeed?”
72
  3. **Action:** Either call a tool (with arguments) or prepare your final answer.
73
- 4. **Final Answer:** Provide only the bare result (no labels, no extra text, no thoughts, no reflection, no "Final Answer" string in the result). For question that contain phrases like `what is the number` or
74
  `what is the highest number` return just the number, e.g., 2.
75
 
76
  **Answer Format Rules**
@@ -96,7 +96,19 @@ class BasicAgent:
96
  Thought: Alphabetical descending: cherry, banana, apple.
97
  Reflect: Order and formatting confirmed.
98
  Final Answer: cherry, banana, apple
99
-
 
 
 
 
 
 
 
 
 
 
 
 
100
  ---
101
 
102
  Now answer the next question following this chain-of-thought + reflection pattern, and output **only** the `Final Answer` in the required format.
@@ -178,18 +190,18 @@ class BasicAgent:
178
  with open(path, "rb") as f:
179
  b64 = b64encode(f.read()).decode()
180
 
181
- file_msg = {
182
- "type": "file",
183
- "file": {
184
- "data": b64,
185
- "filename": os.path.basename(path)
186
- }
187
- }
188
-
189
  msg = HumanMessage(content=[
190
- {"type":"text", "text": question},
191
- file_msg
 
 
 
192
  ])
 
193
  response = model.invoke([SystemMessage(content="Analyze the image."), msg])
194
  result = response.content
195
  print("Result:", result)
 
70
  1. **Thought:** Briefly outline your reasoning step.
71
  2. **Reflect:** Check “Did I use all observations? Did my tool call succeed?”
72
  3. **Action:** Either call a tool (with arguments) or prepare your final answer.
73
+ 4. **Final Answer:** Provide only the bare result (no labels, no extra text, no actions, no thoughts, no reflection, no "Final Answer" string in the result). For question that contain phrases like `what is the number` or
74
  `what is the highest number` return just the number, e.g., 2.
75
 
76
  **Answer Format Rules**
 
96
  Thought: Alphabetical descending: cherry, banana, apple.
97
  Reflect: Order and formatting confirmed.
98
  Final Answer: cherry, banana, apple
99
+
100
+ **Example 4**
101
+ Q: The attached csv file contains the amount of impressions for an ad campaign. What were the total amount of clicks crevenue that occurred after 2024-01-01? Express your answer in EUR with two decimal places.
102
+ Thought: Calculate the total amount of revenue for clicks across all dates after 2024-01-01.
103
+ Reflect: I have all the necessary data from the csv file.
104
+ Action: Multiple clicks amount by revenue per click for each row after 2024-01-01 and then sum these values.
105
+ Final Answer: 283934.00
106
+
107
+ **Example 5**
108
+ Q: What is the number of the most performant desktop processor model from Ryzen 1000 series?
109
+ Thought: The number of the most performant desktop processor model from Ryzen 1000 series is 1800X.
110
+ Reflect: I know the answer, displaying only the model number without anything else.
111
+ Final Answer: 1800X
112
  ---
113
 
114
  Now answer the next question following this chain-of-thought + reflection pattern, and output **only** the `Final Answer` in the required format.
 
190
  with open(path, "rb") as f:
191
  b64 = b64encode(f.read()).decode()
192
 
193
+ ext = os.path.splitext(path)[1].lower().lstrip(".")
194
+ mime = f"image/{'jpeg' if ext in ('jpg','jpeg') else 'png'}"
195
+
196
+ # 2) Build the multimodal message
 
 
 
 
197
  msg = HumanMessage(content=[
198
+ {"type": "text", "text": question},
199
+ {
200
+ "type": "image_url",
201
+ "image_url": {"url": f"data:{mime};base64,{b64}"}
202
+ }
203
  ])
204
+
205
  response = model.invoke([SystemMessage(content="Analyze the image."), msg])
206
  result = response.content
207
  print("Result:", result)