Browse Source

fix: add web.py and linkai base url

master
zhayujie 1 year ago
parent
commit
1cff2521f4
4 changed files with 6 additions and 5 deletions
  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 View File

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


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


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


# do http request # 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)) timeout=conf().get("request_timeout", 180))
if res.status_code == 200: if res.status_code == 200:
# execute success # execute success


+ 2
- 1
config.py View File

@@ -112,7 +112,8 @@ available_setting = {
# 知识库平台配置 # 知识库平台配置
"use_linkai": False, "use_linkai": False,
"linkai_api_key": "", "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 View File

@@ -68,8 +68,7 @@ class MJTask:
# midjourney bot # midjourney bot
class MJBot: class MJBot:
def __init__(self, config): 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.headers = {"Authorization": "Bearer " + conf().get("linkai_api_key")}
self.config = config self.config = config
self.tasks = {} self.tasks = {}


+ 1
- 0
requirements.txt View File

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

Loading…
Cancel
Save