mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 02:30:41 -08:00
refactor: improve media rendering and response formatting with precise changes
- Modified g4f/providers/response.py to ensure format_images_markdown returns the result directly without additional flags in the 'format_images_markdown' function.
- Updated g4f/gui/server/api.py to add 'tempfiles' parameter with default empty list to '_create_response_stream' method.
- Changed or added code in API response handling to iterate over 'tempfiles' and attempt to remove each file after response completion, with exception handling (try-except block with logger.exception).
- Adjusted g4f/Tools/files.py to fix tempfile creation: corrected the 'suffix' parameter in 'get_tempfile' to use 'suffix' directly instead of splitting.
- In g4f/tools/media.py, changed 'render_part' function to handle 'text' key properly, checking 'part.get("text")' and returning a dictionary with 'type': 'text' and 'text': value, if present.
This commit is contained in:
parent
ff0618e25f
commit
c0d31c2abb
15 changed files with 516 additions and 61 deletions
|
|
@ -5,7 +5,7 @@ import asyncio
|
|||
from typing import Any
|
||||
|
||||
try:
|
||||
from markitdown import MarkItDown as MaItDo, StreamInfo
|
||||
from ...integration.markitdown import MarkItDown as MaItDo, StreamInfo
|
||||
has_markitdown = True
|
||||
except ImportError:
|
||||
has_markitdown = False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue