更新pptx转成pdf
This commit is contained in:
parent
bf987f18aa
commit
598a852b7c
39
app.py
39
app.py
@ -626,22 +626,15 @@ class FeedbackClassifyRequest(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def _citation_display_filename(value: Any) -> Any:
|
||||||
|
|
||||||
|
|
||||||
def _citation_display_filename(
|
|
||||||
value: Any,
|
|
||||||
file_id: Any = "",
|
|
||||||
) -> Any:
|
|
||||||
"""仅转换文本溯源展示名,不修改 file_id 或实际文件路径。"""
|
"""仅转换文本溯源展示名,不修改 file_id 或实际文件路径。"""
|
||||||
if not isinstance(value, str):
|
if not isinstance(value, str):
|
||||||
return value
|
return value
|
||||||
if not re.search(r"(?i)\.(?:pptx|ppt)$", value.strip()):
|
return re.sub(
|
||||||
return value
|
r"(?i)\.(?:pptx|ppt)$",
|
||||||
normalized_file_id = str(file_id or "").strip()
|
".pdf",
|
||||||
if not normalized_file_id:
|
value.strip(),
|
||||||
return value
|
)
|
||||||
return f"{normalized_file_id}.pdf"
|
|
||||||
|
|
||||||
|
|
||||||
def normalize_source_citation_filenames(
|
def normalize_source_citation_filenames(
|
||||||
@ -653,20 +646,7 @@ def normalize_source_citation_filenames(
|
|||||||
|
|
||||||
normalized: Dict[str, Any] = {}
|
normalized: Dict[str, Any] = {}
|
||||||
for resource_name, items in source_citation.items():
|
for resource_name, items in source_citation.items():
|
||||||
group_file_id = ""
|
display_resource = _citation_display_filename(resource_name)
|
||||||
if isinstance(items, list):
|
|
||||||
group_file_id = next(
|
|
||||||
(
|
|
||||||
item.get("file_id")
|
|
||||||
for item in items
|
|
||||||
if isinstance(item, dict) and item.get("file_id")
|
|
||||||
),
|
|
||||||
"",
|
|
||||||
)
|
|
||||||
display_resource = _citation_display_filename(
|
|
||||||
resource_name,
|
|
||||||
group_file_id,
|
|
||||||
)
|
|
||||||
|
|
||||||
if isinstance(items, list):
|
if isinstance(items, list):
|
||||||
normalized_items = []
|
normalized_items = []
|
||||||
@ -675,12 +655,10 @@ def normalize_source_citation_filenames(
|
|||||||
normalized_items.append(item)
|
normalized_items.append(item)
|
||||||
continue
|
continue
|
||||||
normalized_item = dict(item)
|
normalized_item = dict(item)
|
||||||
item_file_id = normalized_item.get("file_id") or group_file_id
|
|
||||||
for field in ("filename", "resource", "title"):
|
for field in ("filename", "resource", "title"):
|
||||||
if field in normalized_item:
|
if field in normalized_item:
|
||||||
normalized_item[field] = _citation_display_filename(
|
normalized_item[field] = _citation_display_filename(
|
||||||
normalized_item[field],
|
normalized_item[field]
|
||||||
item_file_id,
|
|
||||||
)
|
)
|
||||||
normalized_items.append(normalized_item)
|
normalized_items.append(normalized_item)
|
||||||
else:
|
else:
|
||||||
@ -699,6 +677,7 @@ def normalize_source_citation_filenames(
|
|||||||
return normalized
|
return normalized
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def format_stream_event(event_type: str,
|
def format_stream_event(event_type: str,
|
||||||
data: Dict[str, Any],
|
data: Dict[str, Any],
|
||||||
chat_id: str = "",
|
chat_id: str = "",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user