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

Function create_generation_request

RealChart2Code_eval/evaluate_task2.py:238–266  ·  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

236
237
238def create_generation_request(category: str, data_info: Dict[str, str], image_path: str,
239 generation_prompt: str, model_name: str) -> Dict:
240
241 text_prompt = create_user_prompt(category, data_info)
242 image_base64 = encode_image_to_base64(image_path)
243 user_content = [
244 {
245 "type": "text",
246 "text": f'{text_prompt}. 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__}.'
247 # "text": text_prompt
248 },
249 {
250 "type": "image_url",
251 "image_url": {
252 "url": image_base64
253 }
254 }
255 ]
256
257 return {
258 "model": model_name,
259 "messages": [
260 {"role": "system", "content": generation_prompt},
261 {"role": "user", "content": user_content}
262 ],
263 "max_tokens": 32768,
264 "temperature": 0.0,
265 "timeout": 1200
266 }
267
268
269def extract_python_code(response: str) -> str:

Callers 1

run_benchmarkFunction · 0.70

Calls 2

create_user_promptFunction · 0.70
encode_image_to_base64Function · 0.70

Tested by

no test coverage detected