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