Skip to content

Commit

Permalink
Merge pull request zhayujie#1218 from zhayujie/feature-app-market
Browse files Browse the repository at this point in the history
feat: no quota hint and add group qrcode
  • Loading branch information
zhayujie committed Jun 5, 2023
2 parents 12dc742 + 07fd819 commit dfe1c23
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ https://user-images.githubusercontent.com/26161723/233777277-e3b9928e-b88f-43e2-

Demo made by [Visionn](https://www.wangpc.cc/)

# 体验

了解项目更新和体验最新功能:

<img width="240" src="./docs/images/contact.jpg">

# 更新日志

>**2023.04.26:** 支持企业微信应用号部署,兼容插件,并支持语音图片交互,支持Railway部署,[使用文档](https://github.com/zhayujie/chatgpt-on-wechat/blob/master/channel/wechatcom/README.md)。(contributed by [@lanvent](https://github.com/lanvent) in [#944](https://github.com/zhayujie/chatgpt-on-wechat/pull/944))
Expand Down Expand Up @@ -205,6 +211,8 @@ FAQs: <https://github.com/zhayujie/chatgpt-on-wechat/wiki/FAQs>

## 联系

欢迎提交PR、Issues,以及Star支持一下。程序运行遇到问题优先查看 [常见问题列表](https://github.com/zhayujie/chatgpt-on-wechat/wiki/FAQs) ,其次前往 [Issues](https://github.com/zhayujie/chatgpt-on-wechat/issues) 中搜索。如果你想了解更多项目细节,并与开发者们交流更多关于AI技术的实践,欢迎加入星球:
欢迎提交PR、Issues,以及Star支持一下。程序运行遇到问题可以查看 [常见问题列表](https://github.com/zhayujie/chatgpt-on-wechat/wiki/FAQs) ,其次前往 [Issues](https://github.com/zhayujie/chatgpt-on-wechat/issues) 中搜索。

如果你想了解更多项目细节,与开发者们交流更多关于AI技术的实践,欢迎加入星球:

<a href="https://public.zsxq.com/groups/88885848842852.html"><img width="360" src="./docs/images/planet.jpg"></a>
13 changes: 12 additions & 1 deletion bot/linkai/link_ai_bot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# access LinkAI knowledge base platform
# docs: https://link-ai.tech/platform/link-app/wechat

from bot.bot import Bot
from bridge.context import ContextType
from bridge.reply import Reply, ReplyType
from common.log import logger
from bridge.context import Context
Expand All @@ -13,6 +15,7 @@ class LinkAIBot(Bot):

# authentication failed
AUTH_FAILED_CODE = 401
NO_QUOTA_CODE = 406

def __init__(self):
self.base_url = "https://api.link-ai.chat/v1"
Expand Down Expand Up @@ -51,19 +54,27 @@ def _chat(self, query, context, retry_count=0):
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 linkai_api_key, res={res}")
return Reply(ReplyType.ERROR, "请再问我一次吧")

elif res.get("code") == self.NO_QUOTA_CODE:
logger.exception(f"[LINKAI] please check your account quota, https://link-ai.chat/console/account")
return Reply(ReplyType.ERROR, "提问太快啦,请休息一下再问我吧")

else:
# retry
time.sleep(2)
logger.warn(f"[LINKAI] do retry, times={retry_count}")
return self._chat(query, context, retry_count + 1)

# execute success
reply_content = res["data"]["content"]
logger.info(f"[LINKAI] reply={reply_content}")
self.sessions.session_reply(reply_content, session_id)
return Reply(ReplyType.TEXT, reply_content)

except Exception as e:
logger.exception(e)
# retry
Expand Down
2 changes: 2 additions & 0 deletions config-template.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"open_ai_api_key": "YOUR API KEY",
"model": "gpt-3.5-turbo",
"linkai_api_key": "YOUR API KEY",
"linkai_app_code": "",
"proxy": "",
"single_chat_prefix": [
"bot",
Expand Down
Binary file added docs/images/contact.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion plugins/godcmd/godcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def on_handle_context(self, e_context: EventContext):
except Exception as e:
ok, result = False, "你没有设置私有GPT模型"
elif cmd == "reset":
if bottype in [const.OPEN_AI, const.CHATGPT, const.CHATGPTONAZURE]:
if bottype in [const.OPEN_AI, const.CHATGPT, const.CHATGPTONAZURE, const.LINKAI]:
bot.sessions.clear_session(session_id)
channel.cancel_session(session_id)
ok, result = True, "会话已重置"
Expand Down

0 comments on commit dfe1c23

Please sign in to comment.