From 76a95c02266f3a5e0e16a38814c0d5623aa67578 Mon Sep 17 00:00:00 2001 From: Haikui Yang Date: Sun, 17 Dec 2023 19:50:06 +0800 Subject: [PATCH 1/2] Update open_ai_image.py --- bot/openai/open_ai_image.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bot/openai/open_ai_image.py b/bot/openai/open_ai_image.py index 974bf82..c80650f 100644 --- a/bot/openai/open_ai_image.py +++ b/bot/openai/open_ai_image.py @@ -12,6 +12,7 @@ from config import conf class OpenAIImage(object): def __init__(self): openai.api_key = conf().get("open_ai_api_key") + openai.api_base = conf().get("open_ai_api_base") if conf().get("rate_limit_dalle"): self.tb4dalle = TokenBucket(conf().get("rate_limit_dalle", 50)) From 43e93e8e22050d150ce1861a0fce836e449a4357 Mon Sep 17 00:00:00 2001 From: Haikui Yang Date: Mon, 1 Jan 2024 22:43:03 +0800 Subject: [PATCH 2/2] Update open_ai_image.py --- bot/openai/open_ai_image.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/openai/open_ai_image.py b/bot/openai/open_ai_image.py index c80650f..c205e8b 100644 --- a/bot/openai/open_ai_image.py +++ b/bot/openai/open_ai_image.py @@ -16,13 +16,14 @@ class OpenAIImage(object): if conf().get("rate_limit_dalle"): self.tb4dalle = TokenBucket(conf().get("rate_limit_dalle", 50)) - def create_img(self, query, retry_count=0, api_key=None): + def create_img(self, query, retry_count=0, api_key=None, api_base=None): try: if conf().get("rate_limit_dalle") and not self.tb4dalle.get_token(): return False, "请求太快了,请休息一下再问我吧" logger.info("[OPEN_AI] image_query={}".format(query)) response = openai.Image.create( api_key=api_key, + api_base=api_base, prompt=query, # 图片描述 n=1, # 每次生成图片的数量 model=conf().get("text_to_image") or "dall-e-2",