(category: str, data_info: Dict[str, str], refine_before_image_path: str, image_path: str, improvement_suggestion: str, refine_before_code: str,
generation_prompt: str, user_history_generation_prompt:str, model_name: str)
| 245 | |
| 246 | |
| 247 | def create_generation_request(category: str, data_info: Dict[str, str], refine_before_image_path: str, image_path: str, improvement_suggestion: str, refine_before_code: str, |
| 248 | generation_prompt: str, user_history_generation_prompt:str, model_name: str) -> Dict: |
| 249 | |
| 250 | # user_prompt = create_user_prompt(category, instruction, data_info) |
| 251 | refine_before_image_base64 = encode_image_to_base64(refine_before_image_path) |
| 252 | image_base64 = encode_image_to_base64(image_path) |
| 253 | user1_content = [ |
| 254 | { |
| 255 | "type": "text", |
| 256 | "text": f"# Task /n Category: {category}. Note that in this environment, the version of matplotlib is {matplotlib.__version__}, the version of seaborn is {seaborn.__version__}, the version of plotly is {plotly.__version__}, the version of bokeh is {bokeh.__version__}, the version of altair is {altair.__version__}." |
| 257 | }, |
| 258 | { |
| 259 | "type": "image_url", |
| 260 | "image_url": { |
| 261 | "url": image_base64 |
| 262 | } |
| 263 | } |
| 264 | ] |
| 265 | |
| 266 | messages = [ |
| 267 | {"role": "system", "content": user_history_generation_prompt}, |
| 268 | {"role": "user", "content": user1_content} |
| 269 | ] |
| 270 | |
| 271 | assistant1_content = f"""Here's the Python code: |
| 272 | ```python |
| 273 | {refine_before_code} |
| 274 | ``` |
| 275 | """ |
| 276 | |
| 277 | user2_content = [ |
| 278 | { |
| 279 | "type": "text", |
| 280 | "text": f"Look at this chart image and fix the errors in the code based on the instruction provided.\nCategory: {category}.\n\n**Instruction**: {improvement_suggestion}.\n\n**chart image**:" |
| 281 | }, |
| 282 | { |
| 283 | "type": "image_url", |
| 284 | "image_url": { |
| 285 | "url": refine_before_image_base64 |
| 286 | } |
| 287 | } |
| 288 | ] |
| 289 | |
| 290 | messages.extend([ |
| 291 | {"role": "assistant", "content": assistant1_content}, |
| 292 | {"role": "user", "content": user2_content} |
| 293 | ]) |
| 294 | |
| 295 | print(user_history_generation_prompt) |
| 296 | print(user1_content[0]) |
| 297 | print(assistant1_content) |
| 298 | print(user2_content[0]) |
| 299 | |
| 300 | return { |
| 301 | "model": model_name, |
| 302 | "messages": messages, |
| 303 | "max_tokens": 32768, |
| 304 | "temperature": 0.0, |
no test coverage detected