renderers html and md tested and fixed
This commit is contained in:
parent
a68dac200e
commit
df15f54f4b
2 changed files with 17 additions and 7 deletions
|
|
@ -156,6 +156,7 @@ class RendererHtml(BaseRenderer):
|
||||||
self.logger.warning(f"Style validation failed: {str(e)}")
|
self.logger.warning(f"Style validation failed: {str(e)}")
|
||||||
return self._get_default_html_styles()
|
return self._get_default_html_styles()
|
||||||
|
|
||||||
|
|
||||||
def _get_default_html_styles(self) -> Dict[str, Any]:
|
def _get_default_html_styles(self) -> Dict[str, Any]:
|
||||||
"""Default HTML styles."""
|
"""Default HTML styles."""
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ async def process_documents_and_generate_summary():
|
||||||
prompt=userPrompt,
|
prompt=userPrompt,
|
||||||
documents=documents,
|
documents=documents,
|
||||||
options=ai_options,
|
options=ai_options,
|
||||||
outputFormat="pdf",
|
outputFormat="html",
|
||||||
title="Formulaire"
|
title="Formulaire"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -270,13 +270,15 @@ async def process_documents_and_generate_summary():
|
||||||
file_ext = '.xlsx'
|
file_ext = '.xlsx'
|
||||||
elif 'pptx' in doc_mime.lower() or 'presentationml' in doc_mime.lower():
|
elif 'pptx' in doc_mime.lower() or 'presentationml' in doc_mime.lower():
|
||||||
file_ext = '.pptx'
|
file_ext = '.pptx'
|
||||||
|
elif 'markdown' in doc_mime.lower() or 'md' in doc_mime.lower():
|
||||||
|
file_ext = '.md'
|
||||||
else:
|
else:
|
||||||
logger.warning(f"⚠️ Unknown MIME type: {doc_mime}, using .bin")
|
logger.warning(f"⚠️ Unknown MIME type: {doc_mime}, using .bin")
|
||||||
|
|
||||||
# Also check filename for hints
|
# Also check filename for hints
|
||||||
if doc_name and '.' in doc_name:
|
if doc_name and '.' in doc_name:
|
||||||
name_ext = '.' + doc_name.split('.')[-1].lower()
|
name_ext = '.' + doc_name.split('.')[-1].lower()
|
||||||
if name_ext in ['.docx', '.pdf', '.txt', '.html', '.json', '.csv', '.xlsx', '.pptx']:
|
if name_ext in ['.docx', '.pdf', '.txt', '.html', '.json', '.csv', '.xlsx', '.pptx', '.md']:
|
||||||
file_ext = name_ext
|
file_ext = name_ext
|
||||||
logger.info(f"📄 Using extension from filename: {file_ext}")
|
logger.info(f"📄 Using extension from filename: {file_ext}")
|
||||||
|
|
||||||
|
|
@ -284,12 +286,19 @@ async def process_documents_and_generate_summary():
|
||||||
|
|
||||||
# Save document
|
# Save document
|
||||||
output_path = output_dir / f"{test_name}_{timestamp}{file_ext}"
|
output_path = output_dir / f"{test_name}_{timestamp}{file_ext}"
|
||||||
doc_bytes = base64.b64decode(doc_data)
|
|
||||||
|
|
||||||
with open(output_path, 'wb') as f:
|
# Handle different content types
|
||||||
f.write(doc_bytes)
|
if file_ext in ['.md', '.txt', '.html', '.json', '.csv']:
|
||||||
|
# Text-based formats - save directly as text
|
||||||
logger.info(f"✅ Document saved: {output_path} ({len(doc_bytes)} bytes)")
|
with open(output_path, 'w', encoding='utf-8') as f:
|
||||||
|
f.write(doc_data)
|
||||||
|
logger.info(f"✅ Document saved as text: {output_path} ({len(doc_data)} characters)")
|
||||||
|
else:
|
||||||
|
# Binary formats - decode from base64
|
||||||
|
doc_bytes = base64.b64decode(doc_data)
|
||||||
|
with open(output_path, 'wb') as f:
|
||||||
|
f.write(doc_bytes)
|
||||||
|
logger.info(f"✅ Document saved as binary: {output_path} ({len(doc_bytes)} bytes)")
|
||||||
|
|
||||||
# Also save raw content as text
|
# Also save raw content as text
|
||||||
content = response.get('content', '')
|
content = response.get('content', '')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue