Bladeren bron

fix: add web.py and linkai base url

master
zhayujie 1 jaar geleden
bovenliggende
commit
1cff2521f4
4 gewijzigde bestanden met toevoegingen van 6 en 5 verwijderingen
  1. +2
    -2
      bot/linkai/link_ai_bot.py
  2. +2
    -1
      config.py
  3. +1
    -2
      plugins/linkai/midjourney.py
  4. +1
    -0
      requirements.txt

+ 2
- 2
bot/linkai/link_ai_bot.py Bestand weergeven

@@ -22,7 +22,6 @@ class LinkAIBot(Bot, OpenAIImage):

def __init__(self):
super().__init__()
self.base_url = "https://api.link-ai.chat/v1"
self.sessions = SessionManager(ChatGPTSession, model=conf().get("model") or "gpt-3.5-turbo")

def reply(self, query, context: Context = None) -> Reply:
@@ -83,7 +82,8 @@ class LinkAIBot(Bot, OpenAIImage):
headers = {"Authorization": "Bearer " + linkai_api_key}

# do http request
res = requests.post(url=self.base_url + "/chat/completions", json=body, headers=headers,
base_url = conf().get("linkai_api_base", "https://api.link-ai.chat")
res = requests.post(url=base_url + "/v1/chat/completions", json=body, headers=headers,
timeout=conf().get("request_timeout", 180))
if res.status_code == 200:
# execute success


+ 2
- 1
config.py Bestand weergeven

@@ -112,7 +112,8 @@ available_setting = {
# 知识库平台配置
"use_linkai": False,
"linkai_api_key": "",
"linkai_app_code": ""
"linkai_app_code": "",
"linkai_api_base": "https://api.link-ai.chat" # linkAI服务地址,若国内无法访问或延迟较高可改为 https://api.link-ai.tech
}




+ 1
- 2
plugins/linkai/midjourney.py Bestand weergeven

@@ -68,8 +68,7 @@ class MJTask:
# midjourney bot
class MJBot:
def __init__(self, config):
self.base_url = "https://api.link-ai.chat/v1/img/midjourney"

self.base_url = conf().get("linkai_api_base", "https://api.link-ai.chat") + "/v1/img/midjourney"
self.headers = {"Authorization": "Bearer " + conf().get("linkai_api_key")}
self.config = config
self.tasks = {}


+ 1
- 0
requirements.txt Bestand weergeven

@@ -6,3 +6,4 @@ requests>=2.28.2
chardet>=5.1.0
Pillow
pre-commit
web.py

Laden…
Annuleren
Opslaan