Browse Source

Merge branch 'zhayujie:master' into Peter

develop
uezhenxiang2023 GitHub 1 year ago
parent
commit
c55d81825a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 7 deletions
  1. +1
    -0
      bot/baidu/baidu_wenxin.py
  2. +2
    -2
      bot/linkai/link_ai_bot.py
  3. +2
    -0
      config-template.json
  4. +2
    -1
      config.py
  5. +2
    -2
      docker/Dockerfile.latest
  6. +1
    -2
      plugins/linkai/midjourney.py
  7. +1
    -0
      requirements.txt

+ 1
- 0
bot/baidu/baidu_wenxin.py View File

@@ -77,6 +77,7 @@ class BaiduWenxinBot(Bot):
payload = {'messages': session.messages}
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
response_text = json.loads(response.text)
logger.info(f"[BAIDU] response text={response_text}")
res_content = response_text["result"]
total_tokens = response_text["usage"]["total_tokens"]
completion_tokens = response_text["usage"]["completion_tokens"]


+ 2
- 2
bot/linkai/link_ai_bot.py View File

@@ -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
- 0
config-template.json View File

@@ -30,6 +30,8 @@
"conversation_max_tokens": 1000,
"expires_in_seconds": 3600,
"character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。",
"temperature": 0.7,
"top_p": 1,
"subscribe_msg": "感谢您的关注!\n这里是ChatGPT,可以自由对话。\n支持语音对话。\n支持图片输入。\n支持图片输出,画字开头的消息将按要求创作图片。\n支持tool、角色扮演和文字冒险等丰富的插件。\n输入{trigger_prefix}#help 查看详细指令。",
"use_linkai": false,
"linkai_api_key": "",


+ 2
- 1
config.py View File

@@ -115,7 +115,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
}




+ 2
- 2
docker/Dockerfile.latest View File

@@ -1,4 +1,4 @@
FROM python:3.10-slim
FROM python:3.10-slim-bullseye

LABEL maintainer="foo@bar.com"
ARG TZ='Asia/Shanghai'
@@ -32,4 +32,4 @@ RUN chmod +x /entrypoint.sh \

USER noroot

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]

+ 1
- 2
plugins/linkai/midjourney.py View File

@@ -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 View File

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

Loading…
Cancel
Save