Commit 79ebf1e9 by wangfa

修改

parent aa1dfc77
......@@ -65,7 +65,7 @@ async def imagine(data=Body(None)):
error_message = ""
try:
response = await mid_journey.imagine(guild_id, channel_id, prompt)
print(123)
logger.info(response.status)
if response.status >= 400:
error_message = "请求失败;请稍后再试"
else:
......@@ -73,7 +73,6 @@ async def imagine(data=Body(None)):
"message": "您的图像正在准备中,请稍等片刻..."
}
except Exception as e:
print(e)
response = {}
use_time = time.time() - start_time
if response:
......
......@@ -7,6 +7,7 @@ config = configparser.ConfigParser()
config.read(os.path.join(BASE_DIR, 'env.ini'))
DOWNLOAD_IMAGE_PATH = config.get('download', 'DOWNLOAD_IMAGE_PATH')
DOWNLOAD_URL = config.get('download', 'DOWNLOAD_URL')
# oss配置
ACCESS_KEY_ID = config.get('oss', 'ACCESS_KEY_ID')
......
[download]
DOWNLOAD_IMAGE_PATH=
DOWNLOAD_URL=
[oss]
ENDPOINT=
......
from PIL import Image
import requests
import os
from salai.common_config import DOWNLOAD_IMAGE_PATH, ACCESS_KEY_ID, ACCESS_KEY_SECRET, ENDPOINT, BUCKET_NAME, SAVE_PATH, BAIDU_API_SECRET_KEY, BAI_DU_API_KEY, BAI_DU_APP_ID
from salai.common_config import DOWNLOAD_IMAGE_PATH, ACCESS_KEY_ID, ACCESS_KEY_SECRET, ENDPOINT, BUCKET_NAME, DOWNLOAD_URL, BAIDU_API_SECRET_KEY, BAI_DU_API_KEY, BAI_DU_APP_ID
import hashlib
from oss2 import Auth, Bucket
from aip import AipImageProcess
......@@ -108,10 +108,7 @@ async def download_image(url: str, filename: str, index: int = 0):
imgdata = base64.b64decode(data["image"])
with open(file['path'], 'wb') as f:
f.write(imgdata)
save_name = f"{SAVE_PATH}/{file['name']}"
await oss_upload(save_name, file['path'])
save_name = "https://{}.{}/{}".format(BUCKET_NAME, ENDPOINT, save_name)
save_name = f"{DOWNLOAD_URL}/images/{file['name']}"
result.append(save_name)
return result
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment