Commit 79ebf1e9 by wangfa

修改

parent aa1dfc77
...@@ -65,7 +65,7 @@ async def imagine(data=Body(None)): ...@@ -65,7 +65,7 @@ async def imagine(data=Body(None)):
error_message = "" error_message = ""
try: try:
response = await mid_journey.imagine(guild_id, channel_id, prompt) response = await mid_journey.imagine(guild_id, channel_id, prompt)
print(123) logger.info(response.status)
if response.status >= 400: if response.status >= 400:
error_message = "请求失败;请稍后再试" error_message = "请求失败;请稍后再试"
else: else:
...@@ -73,7 +73,6 @@ async def imagine(data=Body(None)): ...@@ -73,7 +73,6 @@ async def imagine(data=Body(None)):
"message": "您的图像正在准备中,请稍等片刻..." "message": "您的图像正在准备中,请稍等片刻..."
} }
except Exception as e: except Exception as e:
print(e)
response = {} response = {}
use_time = time.time() - start_time use_time = time.time() - start_time
if response: if response:
......
...@@ -7,6 +7,7 @@ config = configparser.ConfigParser() ...@@ -7,6 +7,7 @@ config = configparser.ConfigParser()
config.read(os.path.join(BASE_DIR, 'env.ini')) config.read(os.path.join(BASE_DIR, 'env.ini'))
DOWNLOAD_IMAGE_PATH = config.get('download', 'DOWNLOAD_IMAGE_PATH') DOWNLOAD_IMAGE_PATH = config.get('download', 'DOWNLOAD_IMAGE_PATH')
DOWNLOAD_URL = config.get('download', 'DOWNLOAD_URL')
# oss配置 # oss配置
ACCESS_KEY_ID = config.get('oss', 'ACCESS_KEY_ID') ACCESS_KEY_ID = config.get('oss', 'ACCESS_KEY_ID')
......
[download] [download]
DOWNLOAD_IMAGE_PATH= DOWNLOAD_IMAGE_PATH=
DOWNLOAD_URL=
[oss] [oss]
ENDPOINT= ENDPOINT=
......
from PIL import Image from PIL import Image
import requests import requests
import os 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 import hashlib
from oss2 import Auth, Bucket from oss2 import Auth, Bucket
from aip import AipImageProcess from aip import AipImageProcess
...@@ -108,10 +108,7 @@ async def download_image(url: str, filename: str, index: int = 0): ...@@ -108,10 +108,7 @@ async def download_image(url: str, filename: str, index: int = 0):
imgdata = base64.b64decode(data["image"]) imgdata = base64.b64decode(data["image"])
with open(file['path'], 'wb') as f: with open(file['path'], 'wb') as f:
f.write(imgdata) f.write(imgdata)
save_name = f"{DOWNLOAD_URL}/images/{file['name']}"
save_name = f"{SAVE_PATH}/{file['name']}"
await oss_upload(save_name, file['path'])
save_name = "https://{}.{}/{}".format(BUCKET_NAME, ENDPOINT, save_name)
result.append(save_name) result.append(save_name)
return result 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