This commit is contained in:
TechShrimp
2023-10-15 15:12:12 +08:00
parent 7ced27123a
commit d1c1e2ca43
2 changed files with 13 additions and 7 deletions

View File

@@ -58,9 +58,10 @@ tigerbot:
key: key key: key
model: tigerbot-7b-sft model: tigerbot-7b-sft
# 使用讯飞星火模型api需要抓取以下参数 # 使用讯飞星火web模式api需要抓取以下参数
# 抓取方式详见https://github.com/HildaM/sparkdesk-api/tree/main/docs # 抓取方式详见文档https://www.bilibili.com/read/cv27066577
xinghuo_web: # xinghuo_web:
cookie: cookie # cookie: cookie
fd: fd # fd: fd
GtToken: GtToken # GtToken: GtToken
# prompt: 你是智能聊天机器人你叫wcferry。请用这个角色回答我的问题 # 根据需要对角色进行设定

View File

@@ -2,20 +2,25 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from sparkdesk_web.core import SparkWeb from sparkdesk_web.core import SparkWeb
class XinghuoWeb(): class XinghuoWeb():
def __init__(self, xhconf=None) -> None: def __init__(self, xhconf=None) -> None:
self._sparkWeb = SparkWeb( self._sparkWeb = SparkWeb(
cookie=xhconf["cookie"], cookie=xhconf["cookie"],
fd=xhconf["fd"], fd=xhconf["fd"],
GtToken=xhconf["GtToken"] GtToken=xhconf["GtToken"],
) )
self._chat = self._sparkWeb.create_continuous_chat() 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: def get_answer(self, msg: str, sender: str = None) -> str:
answer = self._chat.chat(msg) answer = self._chat.chat(msg)
return answer return answer
if __name__ == "__main__": if __name__ == "__main__":
from configuration import Config from configuration import Config
c = Config() c = Config()