Merge branch 'zhayujie:master' into Peter

This commit is contained in:
uezhenxiang2023
2023-08-25 12:12:06 +08:00
committed by GitHub
7 changed files with 11 additions and 7 deletions

View File

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

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
FROM python:3.10-slim FROM python:3.10-slim-bullseye
LABEL maintainer="foo@bar.com" LABEL maintainer="foo@bar.com"
ARG TZ='Asia/Shanghai' ARG TZ='Asia/Shanghai'
@@ -32,4 +32,4 @@ RUN chmod +x /entrypoint.sh \
USER noroot USER noroot
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]

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 = {}

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