|
317 | 317 |
|
318 | 318 | def get_system_prompt(model, objective): |
319 | 319 | """ |
320 | | - Format the vision prompt |
| 320 | + Format the vision prompt more efficiently and print the name of the prompt used |
321 | 321 | """ |
| 322 | + |
| 323 | + prompt_map = { |
| 324 | + ("gpt-4-with-som", "Darwin"): ( |
| 325 | + SYSTEM_PROMPT_LABELED_MAC, |
| 326 | + "SYSTEM_PROMPT_LABELED_MAC", |
| 327 | + ), |
| 328 | + ("gpt-4-with-som", "Other"): ( |
| 329 | + SYSTEM_PROMPT_LABELED_WIN_LINUX, |
| 330 | + "SYSTEM_PROMPT_LABELED_WIN_LINUX", |
| 331 | + ), |
| 332 | + ("gpt-4-with-ocr", "Darwin"): (SYSTEM_PROMPT_OCR_MAC, "SYSTEM_PROMPT_OCR_MAC"), |
| 333 | + ("gpt-4-with-ocr", "Other"): ( |
| 334 | + SYSTEM_PROMPT_OCR_WIN_LINUX, |
| 335 | + "SYSTEM_PROMPT_OCR_WIN_LINUX", |
| 336 | + ), |
| 337 | + ("default", "Darwin"): (SYSTEM_PROMPT_MAC, "SYSTEM_PROMPT_MAC"), |
| 338 | + ("default", "Other"): (SYSTEM_PROMPT_WIN_LINUX, "SYSTEM_PROMPT_WIN_LINUX"), |
| 339 | + } |
| 340 | + |
| 341 | + os_type = "Darwin" if platform.system() == "Darwin" else "Other" |
| 342 | + |
| 343 | + # Fetching the prompt tuple (string and name) based on the model and OS |
| 344 | + prompt_tuple = prompt_map.get((model, os_type), prompt_map[("default", os_type)]) |
| 345 | + |
| 346 | + # Extracting the prompt string and its name |
| 347 | + prompt_string, prompt_name = prompt_tuple |
| 348 | + |
| 349 | + # Formatting the prompt |
| 350 | + prompt = prompt_string.format(objective=objective) |
| 351 | + |
| 352 | + # Optional verbose output |
322 | 353 | if VERBOSE: |
323 | | - print("[get_system_prompt] model", model) |
324 | | - if model == "gpt-4-with-som": |
325 | | - if platform.system() == "Darwin": |
326 | | - prompt = SYSTEM_PROMPT_LABELED_MAC.format(objective=objective) |
327 | | - else: |
328 | | - prompt = SYSTEM_PROMPT_LABELED_WIN_LINUX.format(objective=objective) |
329 | | - elif model == "gpt-4-with-ocr": |
330 | | - if platform.system() == "Darwin": |
331 | | - prompt = SYSTEM_PROMPT_OCR_MAC.format(objective=objective) |
332 | | - else: |
333 | | - prompt = SYSTEM_PROMPT_OCR_WIN_LINUX.format(objective=objective) |
334 | | - else: |
335 | | - if platform.system() == "Darwin": |
336 | | - prompt = SYSTEM_PROMPT_MAC.format(objective=objective) |
337 | | - else: |
338 | | - prompt = SYSTEM_PROMPT_WIN_LINUX.format(objective=objective) |
339 | | - |
340 | | - # if VERBOSE: |
341 | | - # print("[get_system_prompt] prompt", prompt) |
| 354 | + print("[get_system_prompt] model:", model) |
| 355 | + print("[get_system_prompt] prompt name:", prompt_name) |
| 356 | + # print("[get_system_prompt] prompt:", prompt) |
342 | 357 |
|
343 | 358 | return prompt |
344 | 359 |
|
|
0 commit comments