pvanand commited on
Commit
60bf5b7
·
verified ·
1 Parent(s): cdb0a43

Update document_generator.py

Browse files
Files changed (1) hide show
  1. document_generator.py +5 -2
document_generator.py CHANGED
@@ -354,11 +354,14 @@ class DocumentGenerator:
354
  return content.lstrip()
355
 
356
  @log_execution
357
- def generate_document_outline(self, query: str, template: bool = False, max_retries: int = 3) -> Optional[Dict]:
358
  messages = [
359
  {"role": "system", "content": DOCUMENT_OUTLINE_PROMPT_SYSTEM if not template else DOCUMENT_TEMPLATE_OUTLINE_PROMPT_SYSTEM},
360
- {"role": "user", "content": DOCUMENT_OUTLINE_PROMPT_USER.format(query=query) if not template else DOCUMENT_TEMPLATE_PROMPT_USER.format(query=query)}
361
  ]
 
 
 
362
 
363
  for attempt in range(max_retries):
364
  outline_response = self.ai_client.generate_response(messages, model="openai/gpt-4o")
 
354
  return content.lstrip()
355
 
356
  @log_execution
357
+ def generate_document_outline(self, query: str, template: bool = False, image_context: str = "", max_retries: int = 3) -> Optional[Dict]:
358
  messages = [
359
  {"role": "system", "content": DOCUMENT_OUTLINE_PROMPT_SYSTEM if not template else DOCUMENT_TEMPLATE_OUTLINE_PROMPT_SYSTEM},
360
+ {"role": "user", "content": DOCUMENT_OUTLINE_PROMPT_USER.format(query=query) if not template else DOCUMENT_TEMPLATE_PROMPT_USER.format(query=query, image_context=image_context)}
361
  ]
362
+ # Update user content to include image context if provided
363
+ if image_context:
364
+ messages[1]["content"] += f"<attached_images>\n\n{image_context}\n\n</attached_images>"
365
 
366
  for attempt in range(max_retries):
367
  outline_response = self.ai_client.generate_response(messages, model="openai/gpt-4o")