Pārlūkot izejas kodu

feat: no quota hint and add group qrcode

master
zhayujie pirms 1 gada
vecāks
revīzija
210042bb81
5 mainītis faili ar 22 papildinājumiem un 3 dzēšanām
  1. +7
    -1
      README.md
  2. +12
    -1
      bot/linkai/link_ai_bot.py
  3. +2
    -0
      config-template.json
  4. Binārs
      docs/images/contact.jpg
  5. +1
    -1
      plugins/godcmd/godcmd.py

+ 7
- 1
README.md Parādīt failu

@@ -205,6 +205,12 @@ 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) 中搜索。

进一步了解项目细节和最新进展,可以加入技术交流群:

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

如果你想获取更多项目资料,与开发者们交流更多关于AI技术的实践,欢迎加入星球:


<a href="https://public.zsxq.com/groups/88885848842852.html"><img width="360" src="./docs/images/planet.jpg"></a> <a href="https://public.zsxq.com/groups/88885848842852.html"><img width="360" src="./docs/images/planet.jpg"></a>

+ 12
- 1
bot/linkai/link_ai_bot.py Parādīt failu

@@ -1,5 +1,7 @@
# access LinkAI knowledge base platform
# docs: https://link-ai.tech/platform/link-app/wechat

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


# authentication failed # authentication failed
AUTH_FAILED_CODE = 401 AUTH_FAILED_CODE = 401
NO_QUOTA_CODE = 406


def __init__(self): def __init__(self):
self.base_url = "https://api.link-ai.chat/v1" self.base_url = "https://api.link-ai.chat/v1"
@@ -51,19 +54,27 @@ class LinkAIBot(Bot):
res = requests.post(url=self.base_url + "/chat/completion", json=body, headers=headers).json() res = requests.post(url=self.base_url + "/chat/completion", json=body, headers=headers).json()


if not res or not res["success"]: if not res or not res["success"]:

if res.get("code") == self.AUTH_FAILED_CODE: if res.get("code") == self.AUTH_FAILED_CODE:
logger.exception(f"[LINKAI] please check your linkai_api_key, res={res}") logger.exception(f"[LINKAI] please check your linkai_api_key, res={res}")
return Reply(ReplyType.ERROR, "请再问我一次吧") 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: else:
# retry # retry
time.sleep(2) time.sleep(2)
logger.warn(f"[LINKAI] do retry, times={retry_count}") logger.warn(f"[LINKAI] do retry, times={retry_count}")
return self._chat(query, context, retry_count + 1) return self._chat(query, context, retry_count + 1)

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

except Exception as e: except Exception as e:
logger.exception(e) logger.exception(e)
# retry # retry


+ 2
- 0
config-template.json Parādīt failu

@@ -1,6 +1,8 @@
{ {
"open_ai_api_key": "YOUR API KEY", "open_ai_api_key": "YOUR API KEY",
"model": "gpt-3.5-turbo", "model": "gpt-3.5-turbo",
"linkai_api_key": "YOUR API KEY",
"linkai_app_code": "",
"proxy": "", "proxy": "",
"single_chat_prefix": [ "single_chat_prefix": [
"bot", "bot",


Binārs
docs/images/contact.jpg Parādīt failu

Pirms Pēc
Platums: 1046  |  Augstums: 1238  |  Izmērs: 646KB

+ 1
- 1
plugins/godcmd/godcmd.py Parādīt failu

@@ -297,7 +297,7 @@ class Godcmd(Plugin):
except Exception as e: except Exception as e:
ok, result = False, "你没有设置私有GPT模型" ok, result = False, "你没有设置私有GPT模型"
elif cmd == "reset": 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) bot.sessions.clear_session(session_id)
channel.cancel_session(session_id) channel.cancel_session(session_id)
ok, result = True, "会话已重置" ok, result = True, "会话已重置"


Notiek ielāde…
Atcelt
Saglabāt