Explorar o código

feat: chatGPT bot

zhayujie %!s(int64=3) %!d(string=hai) anos
pai
achega
a059005506

BIN=BIN
bot/baidu/__pycache__/baidu_unit_bot.cpython-36.pyc


+ 2 - 3
bot/baidu/baidu_unit_bot.py

@@ -1,6 +1,5 @@
 # encoding:utf-8
 
-import json
 import requests
 from bot.bot import Bot
 
@@ -17,8 +16,8 @@ class BaiduUnitBot(Bot):
             return response.json()['result']['context']['SYS_PRESUMED_HIST'][1]
 
     def get_token(self):
-        access_key = '${YOUR_ACCESS_KEY}'
-        secret_key = '${YOUR_SECRET_KEY}'
+        access_key = 'wdNwpvzh4fBr8xzTuPePOWhU'
+        secret_key = 'EUtLXyrogfTQV8nnjncnqNEfeyoHDUqS'
         host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=' + access_key + '&client_secret=' + secret_key
         response = requests.get(host)
         if response:

+ 3 - 0
bot/bot_factory.py

@@ -3,6 +3,7 @@ channel factory
 """
 
 from bot.baidu.baidu_unit_bot import BaiduUnitBot
+from bot.chatgpt.chat_gpt_bot import ChatGPTBot
 
 
 def create_bot(bot_type):
@@ -13,4 +14,6 @@ def create_bot(bot_type):
     """
     if bot_type == 'baidu':
         return BaiduUnitBot()
+    elif bot_type == 'chatGPT':
+        return ChatGPTBot()
     raise RuntimeError

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 6 - 0
bot/chatgpt/chat_gpt_bot.py


+ 1 - 1
bridge/bridge.py

@@ -6,4 +6,4 @@ class Bridge(object):
         pass
 
     def fetch_reply_content(self, query):
-        return bot_factory.BaiduUnitBot().reply(query)
+        return bot_factory.create_bot("chatGPT").reply(query)

BIN=BIN
channel/wechat/__pycache__/wechat_channel.cpython-36.pyc


+ 1 - 3
channel/wechat/wechat_channel.py

@@ -2,8 +2,6 @@
 wechat channel
 """
 import itchat
-import time
-import random
 import json
 from itchat.content import *
 from channel.channel import Channel
@@ -34,6 +32,6 @@ class WechatChannel(Channel):
             self.send(super().build_reply_content(msg['Text']), from_user_id)
 
     def send(self, msg, receiver):
-        time.sleep(random.randint(1, 3))
+        # time.sleep(random.randint(1, 3))
         print(msg, receiver)
         itchat.send(msg + " [bot]", toUserName=receiver)

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio