feat: add file upload method with base64 encoding in image.py
parent
2a096152b0
commit
e17d7c4d10
|
|
@ -86,7 +86,6 @@ class QwenVLChatModel(MaxKBBaseModel, BaseChatOpenAI):
|
||||||
policy_data = self.get_upload_policy(self.openai_api_key.get_secret_value(), self.model_name)
|
policy_data = self.get_upload_policy(self.openai_api_key.get_secret_value(), self.model_name)
|
||||||
# 2. 上传文件到OSS
|
# 2. 上传文件到OSS
|
||||||
oss_url = self.upload_file_to_oss(policy_data, file_stream, file_name)
|
oss_url = self.upload_file_to_oss(policy_data, file_stream, file_name)
|
||||||
print(oss_url)
|
|
||||||
|
|
||||||
return oss_url
|
return oss_url
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import base64
|
||||||
|
import mimetypes
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from models_provider.base_model_provider import MaxKBBaseModel
|
from models_provider.base_model_provider import MaxKBBaseModel
|
||||||
|
|
@ -22,3 +24,10 @@ class VolcanicEngineImage(MaxKBBaseModel, BaseChatOpenAI):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_cache_model():
|
def is_cache_model():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def upload_file_and_get_url(self, file_stream, file_name):
|
||||||
|
"""上传文件并获取文件URL"""
|
||||||
|
base64_video = base64.b64encode(file_stream).decode("utf-8")
|
||||||
|
video_format = mimetypes.guess_type(file_name)[0]
|
||||||
|
return f'data:{video_format};base64,{base64_video}'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue