(category: str, data_info: Dict[str, str], image_path: str,
generation_prompt: str, model_name: str)
| 245 | |
| 246 | |
| 247 | def create_generation_request(category: str, data_info: Dict[str, str], image_path: str, |
| 248 | generation_prompt: str, model_name: str) -> Dict: |
| 249 | |
| 250 | # user_prompt = create_user_prompt(category, instruction, data_info) |
| 251 | image_base64 = encode_image_to_base64(image_path) |
| 252 | user_content = [ |
| 253 | { |
| 254 | "type": "text", |
| 255 | "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__}." |
| 256 | }, |
| 257 | { |
| 258 | "type": "image_url", |
| 259 | "image_url": { |
| 260 | "url": image_base64 |
| 261 | } |
| 262 | } |
| 263 | ] |
| 264 | |
| 265 | return { |
| 266 | "model": model_name, |
| 267 | "messages": [ |
| 268 | {"role": "system", "content": generation_prompt}, |
| 269 | {"role": "user", "content": user_content} |
| 270 | ], |
| 271 | "max_tokens": 32768, |
| 272 | "temperature": 0.0, |
| 273 | "timeout": 1200 |
| 274 | } |
| 275 | |
| 276 | |
| 277 | def extract_python_code(response: str) -> str: |
no test coverage detected