MCPcopy Create free account
hub / github.com/Speakn0w/RealChart2Code / create_generation_request

Function create_generation_request

RealChart2Code_eval/evaluate_task1.py:247–274  ·  view source on GitHub ↗
(category: str, data_info: Dict[str, str], image_path: str,
                            generation_prompt: str, model_name: str)

Source from the content-addressed store, hash-verified

245
246
247def 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
277def extract_python_code(response: str) -> str:

Callers 1

run_benchmarkFunction · 0.70

Calls 1

encode_image_to_base64Function · 0.70

Tested by

no test coverage detected