Spaces:
Running
Running
Update document_generator_v3.py
Browse files- document_generator_v3.py +4 -2
document_generator_v3.py
CHANGED
|
@@ -354,10 +354,10 @@ class DocumentGenerator:
|
|
| 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,
|
| 361 |
]
|
| 362 |
# Update user content to include image context if provided
|
| 363 |
if image_context:
|
|
@@ -561,6 +561,7 @@ async def generate_document_outline_endpoint(
|
|
| 561 |
vision_tools = VisionTools(ai_client)
|
| 562 |
images = ""
|
| 563 |
documents = ""
|
|
|
|
| 564 |
try:
|
| 565 |
image_context = ""
|
| 566 |
if images:
|
|
@@ -572,6 +573,7 @@ async def generate_document_outline_endpoint(
|
|
| 572 |
|
| 573 |
json_document = document_generator.generate_document_outline(
|
| 574 |
query,
|
|
|
|
| 575 |
template,
|
| 576 |
image_context=image_context
|
| 577 |
)
|
|
|
|
| 354 |
return content.lstrip()
|
| 355 |
|
| 356 |
@log_execution
|
| 357 |
+
def generate_document_outline(self, query: str, num_pages:int, 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, num_pages=num_pages) if not template else DOCUMENT_TEMPLATE_PROMPT_USER.format(query=query, num_pages=num_pages)}
|
| 361 |
]
|
| 362 |
# Update user content to include image context if provided
|
| 363 |
if image_context:
|
|
|
|
| 561 |
vision_tools = VisionTools(ai_client)
|
| 562 |
images = ""
|
| 563 |
documents = ""
|
| 564 |
+
num_pages = 2
|
| 565 |
try:
|
| 566 |
image_context = ""
|
| 567 |
if images:
|
|
|
|
| 573 |
|
| 574 |
json_document = document_generator.generate_document_outline(
|
| 575 |
query,
|
| 576 |
+
num_pages,
|
| 577 |
template,
|
| 578 |
image_context=image_context
|
| 579 |
)
|