Merge pull request #17 from NoobHumiliator/spark_api
接入讯飞星火web模式api 可以无限白嫖
This commit is contained in:
@@ -57,3 +57,11 @@ report_reminder:
|
|||||||
tigerbot:
|
tigerbot:
|
||||||
key: key
|
key: key
|
||||||
model: tigerbot-7b-sft
|
model: tigerbot-7b-sft
|
||||||
|
|
||||||
|
# 使用讯飞星火web模式api需要抓取以下参数
|
||||||
|
# 抓取方式详见文档:https://www.bilibili.com/read/cv27066577
|
||||||
|
# xinghuo_web:
|
||||||
|
# cookie: cookie
|
||||||
|
# fd: fd
|
||||||
|
# GtToken: GtToken
|
||||||
|
# prompt: 你是智能聊天机器人,你叫wcferry。请用这个角色回答我的问题 # 根据需要对角色进行设定
|
||||||
|
|||||||
@@ -32,3 +32,4 @@ class Config(object):
|
|||||||
self.NEWS = yconfig["news"]["receivers"]
|
self.NEWS = yconfig["news"]["receivers"]
|
||||||
self.REPORT_REMINDERS = yconfig["report_reminder"]["receivers"]
|
self.REPORT_REMINDERS = yconfig["report_reminder"]["receivers"]
|
||||||
self.TIGERBOT = yconfig.get("tigerbot")
|
self.TIGERBOT = yconfig.get("tigerbot")
|
||||||
|
self.XINGHUO_WEB = yconfig.get("xinghuo_web")
|
||||||
|
|||||||
29
func_xinghuo_web.py
Normal file
29
func_xinghuo_web.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#! /usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from sparkdesk_web.core import SparkWeb
|
||||||
|
|
||||||
|
|
||||||
|
class XinghuoWeb():
|
||||||
|
def __init__(self, xhconf=None) -> None:
|
||||||
|
|
||||||
|
self._sparkWeb = SparkWeb(
|
||||||
|
cookie=xhconf["cookie"],
|
||||||
|
fd=xhconf["fd"],
|
||||||
|
GtToken=xhconf["GtToken"],
|
||||||
|
)
|
||||||
|
self._chat = self._sparkWeb.create_continuous_chat()
|
||||||
|
# 如果有提示词
|
||||||
|
if xhconf["prompt"]:
|
||||||
|
self._chat.chat(xhconf["prompt"])
|
||||||
|
|
||||||
|
def get_answer(self, msg: str, sender: str = None) -> str:
|
||||||
|
answer = self._chat.chat(msg)
|
||||||
|
return answer
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
from configuration import Config
|
||||||
|
c = Config()
|
||||||
|
xinghuo = XinghuoWeb(c.XINGHUO_WEB)
|
||||||
|
rsp = xinghuo.get_answer("你还活着?")
|
||||||
|
print(rsp)
|
||||||
@@ -5,4 +5,6 @@ pandas
|
|||||||
pyyaml
|
pyyaml
|
||||||
requests
|
requests
|
||||||
schedule
|
schedule
|
||||||
|
pyhandytools
|
||||||
|
sparkdesk-api==1.3.0
|
||||||
wcferry>=39.0.3.0
|
wcferry>=39.0.3.0
|
||||||
|
|||||||
3
robot.py
3
robot.py
@@ -14,6 +14,7 @@ from func_chatgpt import ChatGPT
|
|||||||
from func_chengyu import cy
|
from func_chengyu import cy
|
||||||
from func_news import News
|
from func_news import News
|
||||||
from func_tigerbot import TigerBot
|
from func_tigerbot import TigerBot
|
||||||
|
from func_xinghuo_web import XinghuoWeb
|
||||||
from job_mgmt import Job
|
from job_mgmt import Job
|
||||||
|
|
||||||
|
|
||||||
@@ -33,6 +34,8 @@ class Robot(Job):
|
|||||||
elif self.config.CHATGPT:
|
elif self.config.CHATGPT:
|
||||||
cgpt = self.config.CHATGPT
|
cgpt = self.config.CHATGPT
|
||||||
self.chat = ChatGPT(cgpt.get("key"), cgpt.get("api"), cgpt.get("proxy"), cgpt.get("prompt"))
|
self.chat = ChatGPT(cgpt.get("key"), cgpt.get("api"), cgpt.get("proxy"), cgpt.get("prompt"))
|
||||||
|
elif self.config.XINGHUO_WEB:
|
||||||
|
self.chat = XinghuoWeb(self.config.XINGHUO_WEB)
|
||||||
else:
|
else:
|
||||||
self.chat = None
|
self.chat = None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user