refactor: improve image URL handling and clean up unused code in base_image_generate_node.py and tti.py
This commit is contained in:
parent
ebb475c19a
commit
99d94abe85
@ -40,7 +40,9 @@ class BaseImageGenerateNode(IImageGenerateNode):
|
|||||||
file_urls = []
|
file_urls = []
|
||||||
for image_url in image_urls:
|
for image_url in image_urls:
|
||||||
file_name = 'generated_image.png'
|
file_name = 'generated_image.png'
|
||||||
file = bytes_to_uploaded_file(requests.get(image_url).content, file_name)
|
if isinstance(image_url, str) and image_url.startswith('http'):
|
||||||
|
image_url = requests.get(image_url).content
|
||||||
|
file = bytes_to_uploaded_file(image_url, file_name)
|
||||||
meta = {
|
meta = {
|
||||||
'debug': False if application.id else True,
|
'debug': False if application.id else True,
|
||||||
'chat_id': chat_id,
|
'chat_id': chat_id,
|
||||||
|
|||||||
@ -5,9 +5,11 @@ from openai import OpenAI
|
|||||||
|
|
||||||
from common.config.tokenizer_manage_config import TokenizerManage
|
from common.config.tokenizer_manage_config import TokenizerManage
|
||||||
from common.utils.common import bytes_to_uploaded_file
|
from common.utils.common import bytes_to_uploaded_file
|
||||||
|
from knowledge.models import FileSourceType
|
||||||
# from dataset.serializers.file_serializers import FileSerializer
|
# from dataset.serializers.file_serializers import FileSerializer
|
||||||
from models_provider.base_model_provider import MaxKBBaseModel
|
from models_provider.base_model_provider import MaxKBBaseModel
|
||||||
from models_provider.impl.base_tti import BaseTextToImage
|
from models_provider.impl.base_tti import BaseTextToImage
|
||||||
|
from oss.serializers.file import FileSerializer
|
||||||
|
|
||||||
|
|
||||||
def custom_get_token_ids(text: str):
|
def custom_get_token_ids(text: str):
|
||||||
@ -45,9 +47,6 @@ class XinferenceTextToImage(MaxKBBaseModel, BaseTextToImage):
|
|||||||
**optional_params,
|
**optional_params,
|
||||||
)
|
)
|
||||||
|
|
||||||
def is_cache_model(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def check_auth(self):
|
def check_auth(self):
|
||||||
self.generate_image('生成一个小猫图片')
|
self.generate_image('生成一个小猫图片')
|
||||||
|
|
||||||
@ -57,11 +56,6 @@ class XinferenceTextToImage(MaxKBBaseModel, BaseTextToImage):
|
|||||||
file_urls = []
|
file_urls = []
|
||||||
# 临时文件
|
# 临时文件
|
||||||
for img in res.data:
|
for img in res.data:
|
||||||
file = bytes_to_uploaded_file(base64.b64decode(img.b64_json), 'file_name.jpg')
|
file_urls.append(base64.b64decode(img.b64_json))
|
||||||
meta = {
|
|
||||||
'debug': True,
|
|
||||||
}
|
|
||||||
# file_url = FileSerializer(data={'file': file, 'meta': meta}).upload()
|
|
||||||
# file_urls.append(f'http://localhost:8080{file_url}')
|
|
||||||
|
|
||||||
return file_urls
|
return file_urls
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user