Skip to content

Commit

Permalink
Merge pull request zhayujie#1168 from zhayujie/feature-app-market
Browse files Browse the repository at this point in the history
fix: config name optimize
  • Loading branch information
zhayujie committed May 29, 2023
2 parents c29d391 + 69b6855 commit 776cdaf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions bot/linkai/link_ai_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ def _chat(self, query, context, retry_count=0):
session.messages.pop(0)

# load config
app_code = conf().get("app_code")
app_market_api_key = conf().get("app_market_api_key")
app_code = conf().get("linkai_app_code")
linkai_api_key = conf().get("linkai_api_key")
logger.info(f"[LINKAI] query={query}, app_code={app_code}")

body = {
"appCode": app_code,
"messages": session.messages
}
headers = {"Authorization": "Bearer " + app_market_api_key}
headers = {"Authorization": "Bearer " + linkai_api_key}

# do http request
res = requests.post(url=self.base_url + "/chat/completion", json=body, headers=headers).json()

if not res or not res["success"]:
if res.get("code") == self.AUTH_FAILED_CODE:
logger.exception(f"[LINKAI] please check your app_market_api_key, res={res}")
logger.exception(f"[LINKAI] please check your linkai_api_key, res={res}")
return Reply(ReplyType.ERROR, "请再问我一次吧")
else:
# retry
Expand Down
2 changes: 1 addition & 1 deletion bridge/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self):
self.btype["chat"] = const.OPEN_AI
if conf().get("use_azure_chatgpt", False):
self.btype["chat"] = const.CHATGPTONAZURE
if conf().get("app_market_api_key") and conf().get("app_code"):
if conf().get("linkai_api_key") and conf().get("linkai_app_code"):
self.btype["chat"] = const.LINKAI
self.bots = {}

Expand Down
6 changes: 3 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@
"appdata_dir": "", # 数据目录
# 插件配置
"plugin_trigger_prefix": "$", # 规范插件提供聊天相关指令的前缀,建议不要和管理员指令前缀"#"冲突
# 应用市场配置
"app_market_api_key": "",
"app_code": ""
# 知识库平台配置
"linkai_api_key": "",
"linkai_app_code": ""
}


Expand Down

0 comments on commit 776cdaf

Please sign in to comment.