1- # Copyright (c) 2021 IMAGE Project, Shared Reality Lab, McGill University
1+ # Copyright (c) 2025 IMAGE Project, Shared Reality Lab, McGill University
22#
33# This program is free software: you can redistribute it and/or modify
44# it under the terms of the GNU Affero General Public License as
@@ -452,13 +452,16 @@ def followup():
452452 {"error" : "Failed to process focus area on image" }
453453 ), 500
454454
455+ # get followup prompt from env as an override if it exists
456+ followup_prompt = os .getenv ('FOLLOWUP_PROMPT_OVERRIDE' , FOLLOWUP_PROMPT )
457+
455458 if not focus :
456- system_prompt = FOLLOWUP_PROMPT
459+ system_prompt = followup_prompt
457460 else :
458- system_prompt = FOLLOWUP_PROMPT + FOLLOWUP_PROMPT_FOCUS
461+ system_prompt = followup_prompt + FOLLOWUP_PROMPT_FOCUS
459462
460463 system_message = {
461- "role" : "developer " ,
464+ "role" : "system " ,
462465 "content" : system_prompt
463466 }
464467
@@ -508,7 +511,9 @@ def followup():
508511
509512 followup_response_json = llm_client .chat_completion (
510513 prompt = "" , # Empty since we're using full messages via kwargs
511- json_schema = FOLLOWUP_RESPONSE_SCHEMA ,
514+ system_prompt = system_prompt ,
515+ json_schema = None , # qwen3 wants json_object not rigid schema
516+ response_format = {"type" : "json_object" },
512517 temperature = 0.0 ,
513518 messages = messages , # Pass full conversation history via kwargs
514519 parse_json = True ,
@@ -518,7 +523,7 @@ def followup():
518523 if followup_response_json is None :
519524 logging .error ("Failed to receive response from LLM." )
520525 return jsonify (
521- {"error" : "Failed to get graphic caption from LLM" }
526+ {"error" : "Failed to receive response from LLM" }
522527 ), 500
523528
524529 response_text , token_usage = followup_response_json
0 commit comments