解决历史上下文中图片 url 过期问题
This commit is contained in:
@@ -9,6 +9,7 @@ from fastapi import APIRouter
|
||||
from typing import AsyncGenerator
|
||||
from fastapi.responses import StreamingResponse
|
||||
from langchain_core.messages import SystemMessage, AIMessageChunk, ToolMessage, AIMessage, ToolMessageChunk
|
||||
from minio.commonconfig import CopySource
|
||||
|
||||
from src.core.config import PROJECT_ROOT, settings
|
||||
from src.server.deep_agent.agents.main_agent import build_main_agent, Context
|
||||
@@ -175,7 +176,9 @@ async def chat_stream(request: DeepAgentChatRequest):
|
||||
input_image_content += f"- 上传图片{i}: {path}\n"
|
||||
|
||||
bucket, object_name = path.split('/', 1)
|
||||
image_url = get_presigned_url(oss_client=minio_client, bucket=bucket, object_name=object_name)
|
||||
# image_url = get_presigned_url(oss_client=minio_client, bucket=bucket, object_name=object_name)
|
||||
copy_result = minio_client.copy_object("fida-public-bucket", path, CopySource(bucket, object_name))
|
||||
image_url = f"https://www.minio-api.aida.com.hk/{copy_result.bucket_name}/{copy_result.object_name}"
|
||||
content.append({"type": "image_url", "image_url": {"url": image_url}})
|
||||
files["input_image"].append(path)
|
||||
|
||||
@@ -185,11 +188,13 @@ async def chat_stream(request: DeepAgentChatRequest):
|
||||
input_image_content += f"- 引用图片: {request.quote_image_path}\n"
|
||||
|
||||
bucket, object_name = request.quote_image_path.split('/', 1)
|
||||
image_url = get_presigned_url(oss_client=minio_client, bucket=bucket, object_name=object_name)
|
||||
# image_url = get_presigned_url(oss_client=minio_client, bucket=bucket, object_name=object_name)
|
||||
copy_result = minio_client.copy_object("fida-public-bucket", request.quote_image_path, CopySource(bucket, object_name))
|
||||
image_url = f"https://www.minio-api.aida.com.hk/{copy_result.bucket_name}/{copy_result.object_name}"
|
||||
content.append({"type": "image_url", "image_url": {"url": image_url}})
|
||||
files["quote_image"] = request.quote_image_path
|
||||
|
||||
if initial_messages:
|
||||
if input_image_content:
|
||||
content[0]['text'] += input_image_content
|
||||
final_messages = {
|
||||
"messages": [
|
||||
|
||||
Reference in New Issue
Block a user