-
- -
-
姓名:
-
-
- -
-
性别:
-
-
- -
-
年龄:
-
-
-
- -
-
出生地:
-
-
- -
-
生肖:
-
-
- -
-
星座:
-
-
- -
-
职业:
-
-
- -
-
喜好:
-
-
-
- -
-
联系方式:
-
-
-
+
+
+
+
Fay数字人助理版
+
+
+
+
+
人设:
+
+
+
+
+ -
+
姓名:
+
+
+ -
+
性别:
+
+
+ -
+
年龄:
+
+
+
+ -
+
出生地:
+
+
+ -
+
生肖:
+
+
+ -
+
星座:
+
+
+ -
+
职业:
+
+
+ -
+
喜好:
+
+
+
+ -
+
联系方式:
+
+
+
+
+
+
+
+ -
+
敏感度:
+
+
+
+
+ -
+
使用面板播放:
+
+
+
+
+
-
-
- -
-
送礼敏感度:
-
-
-
-
- -
-
关注敏感度:
-
-
- -
-
进入敏感度:
-
-
- -
-
留言敏感度:
-
-
- -
-
冷场敏感度:
-
-
- -
-
单次互动时长:
-
- 秒
-
- -
-
声音选择:{{attribute_voice}}
-
-
-
-
-
-
- -
-
使用面板播放:
-
-
-
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
[[item.timetext]]
+
+
+
+
+
[[item.content]]
+
+
+
+
[[item.content]]
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/gui/window.py b/gui/window.py
index f9ca15f..c3805b7 100644
--- a/gui/window.py
+++ b/gui/window.py
@@ -78,4 +78,4 @@ def init_ui(self):
self.mainLayout.setSpacing(5)
self.mainLayout.addWidget(self.pWebGroup)
self.setLayout(self.mainLayout)
- self.setMinimumSize(800, 800)
+ self.setMinimumSize(800, 800)
\ No newline at end of file
diff --git a/images/controller.png b/images/controller.png
index 2160a47..e24beb5 100644
Binary files a/images/controller.png and b/images/controller.png differ
diff --git a/images/luoji.png b/images/luoji.png
index 4fe254d..3fd1596 100644
Binary files a/images/luoji.png and b/images/luoji.png differ
diff --git a/main.py b/main.py
index c7a2c53..c39c1c0 100644
--- a/main.py
+++ b/main.py
@@ -11,7 +11,7 @@
from gui.window import MainWindow
from utils import config_util
from scheduler.thread_manager import MyThread
-
+from core.content_db import Content_Db
def __clear_samples():
if not os.path.exists("./samples"):
@@ -35,7 +35,10 @@ def __clear_songs():
__clear_samples()
__clear_songs()
config_util.load_config()
-
+ dbstatus = os.path.exists("fay.db")
+ if(dbstatus == False):
+ contentdb = Content_Db()
+ contentdb.init_db()
ws_server = wsa_server.new_instance(port=10002)
ws_server.start_server()
web_ws_server = wsa_server.new_web_instance(port=10003)
diff --git a/python_connector_demo/remote_audio.py b/python_connector_demo/remote_audio.py
index 038ddd8..af62a79 100644
--- a/python_connector_demo/remote_audio.py
+++ b/python_connector_demo/remote_audio.py
@@ -25,17 +25,17 @@ def receive_audio(client):
while True:
data = client.recv(9)
filedata = b''
- if b"\x00\x01\x02\x03\x04\x05\x06\x07\x08" == data: #wav文件开始传输标志
+ if b"\x00\x01\x02\x03\x04\x05\x06\x07\x08" == data: #mp3文件开始传输标志
while True:
data = client.recv(1024)
filedata += data
filedata = filedata.replace(b'\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8', b"") #去除心跳信息
- if b"\x08\x07\x06\x05\x04\x03\x02\x01\x00" == filedata[-9:]:#wav文件结束传输标志
+ if b"\x08\x07\x06\x05\x04\x03\x02\x01\x00" == filedata[-9:]:#mp3文件结束传输标志
filedata = filedata[:-9]
break
print("receive audio end:{}".format(len(filedata)), end="")
- filename = "sample/recv_{}.wav".format(time.time())
+ filename = "sample/recv_{}.mp3".format(time.time())
with open(filename, "wb") as f:
f.write(filedata)
f.close()
diff --git a/system.conf b/system.conf
index a100e0a..0298c13 100644
--- a/system.conf
+++ b/system.conf
@@ -13,18 +13,18 @@ ms_tts_region=
xf_ltp_app_id=
xf_ltp_api_key=
-#NLP三选一:xfaiui、yuan、chatgpt
-chat_module=xfaiui
+#NLP四选一:xfaiui、yuan、chatgpt、rasa(需启动chatglm及rasa,https://m.bilibili.com/video/BV1D14y1f7pr)
+chat_module=
-# 讯飞 自然语言处理 服务密钥(NLP3选1) https://aiui.xfyun.cn/solution/webapi/
+# 讯飞 自然语言处理 服务密钥(NLP4选1) https://aiui.xfyun.cn/solution/webapi/
xf_aiui_app_id=
xf_aiui_api_key=
-#浪.潮源大模型 服务密钥(NLP3选1) https://air.inspur.com/
+#浪.潮源大模型 服务密钥(NLP4选1) https://air.inspur.com/
yuan_1_0_account=
yuan_1_0_phone=
-#gpt 服务密钥(NLP3选1) https://openai.com/
+#gpt 服务密钥(NLP4选1) https://openai.com/
chatgpt_api_key=
#ngrok内网穿透id,远程设备可以通过互联网连接Fay(非必须)http://ngrok.cc
diff --git a/test/rasa/actions/actions.py b/test/rasa/actions/actions.py
index 3fd5f00..e28e080 100644
--- a/test/rasa/actions/actions.py
+++ b/test/rasa/actions/actions.py
@@ -109,3 +109,40 @@ def parse_datetime(datetime_str):
return datetime_obj
except ValueError:
print("无法解析日期和时间")
+
+class ActionAskProblem(Action):
+ def name(self) -> str:
+ return "action_ask_problem"
+
+ async def run(self, dispatcher: CollectingDispatcher, tracker, domain):
+ history = []
+ user_messages = []
+ bot_messages = []
+
+ # Separate user messages and bot messages
+ for event in tracker.events:
+ if event.get("event") == "user":
+ user_messages.append(event.get("text"))
+ elif event.get("event") == "bot":
+ bot_messages.append(event.get("text"))
+
+ # Combine user and bot messages
+ for user, bot in zip(user_messages, bot_messages):
+ history.append([user, bot])
+
+ print("*******************************")
+ print(history)
+ print("*******************************")
+
+ url = "http://127.0.0.1:8000"
+ req = json.dumps({
+ "prompt": tracker.latest_message.get("text"),
+ "history": history})
+ headers = {'content-type': 'application/json'}
+ r = requests.post(url, headers=headers, data=req)
+ a = json.loads(r.text).get('response')
+ history = json.loads(r.text).get('history')
+
+ dispatcher.utter_message(a)
+
+ return []
diff --git a/test/rasa/config.yml b/test/rasa/config.yml
index 6f0871d..e602b8a 100644
--- a/test/rasa/config.yml
+++ b/test/rasa/config.yml
@@ -2,38 +2,13 @@ recipe: default.v1
assistant_id: 20230416-203150-proud-texture
language: zh
pipeline:
-# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
-# # If you'd like to customize it, uncomment and adjust the pipeline.
-# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
- - name: JiebaTokenizer
- - name: RegexFeaturizer
- - name: LexicalSyntacticFeaturizer
- - name: CountVectorsFeaturizer
- - name: CountVectorsFeaturizer
- analyzer: char_wb
- min_ngram: 1
- max_ngram: 4
- - name: DIETClassifier
- epochs: 100
- constrain_similarities: true
- - name: EntitySynonymMapper
- - name: ResponseSelector
- epochs: 100
- constrain_similarities: true
- - name: FallbackClassifier
- threshold: 0.3
- ambiguity_threshold: 0.1
-policies:
-# # No configuration for policies was provided. The following default policies were used to train your model.
-# # If you'd like to customize them, uncomment and adjust the policies.
-# # See https://rasa.com/docs/rasa/policies for more information.
- - name: MemoizationPolicy
- - name: RulePolicy
- - name: UnexpecTEDIntentPolicy
- max_history: 5
- epochs: 100
- - name: TEDPolicy
- max_history: 5
- epochs: 100
- constrain_similarities: true
-
+ - name: JiebaTokenizer # 分词器,用于处理中文文本
+ - name: RegexFeaturizer # 基于正则表达式提取特征
+ - name: LexicalSyntacticFeaturizer # 用于提取词汇和句法特征
+ - name: CountVectorsFeaturizer # 根据词频创建词向量
+ - name: DIETClassifier # 支持中文的意图分类器
+ epochs: 100 # 训练轮数,可以根据需要进行调整
+ constrain_similarities: True
+policies:
+ - name: MemoizationPolicy # 记忆策略,用于记住先前的对话状态
+ - name: RulePolicy # 规则策略,用于处理基于规则的对话逻辑
\ No newline at end of file
diff --git a/test/rasa/data/nlu.yml b/test/rasa/data/nlu.yml
index fafbea5..4579742 100644
--- a/test/rasa/data/nlu.yml
+++ b/test/rasa/data/nlu.yml
@@ -14,17 +14,33 @@ nlu:
- 回头说
- 先这样
-- intent: ask_time
+- intent: ask_problem
examples: |
- - 现在几点钟了?
- - 请告诉我现在的时间
- - 你知道现在是几点吗?
+ - 请帮我写一篇文章
+ - 请问一下这个问题为什么这样?
+ - 我想写一篇文章
+ - 我想咨询一下这个问题
+ - 我想问问这里是什么错误
+ - 这个错误是怎么导致的
+ - 可以详细说说吗
+ - 详细一点说
+ - 详细
+ - 文章
+ - 继续
+ - 请教
+ - 请问
- intent: ask_date
examples: |
- 今天是几号?
- 今天星期几?
+- intent: ask_time
+ examples: |
+ - 现在几点钟了?
+ - 请告诉我现在的时间
+ - 你知道现在是几点吗?
+
- intent: out_of_scope
examples: |
- 今天天气真好
diff --git a/test/rasa/data/rules.yml b/test/rasa/data/rules.yml
index 2d2b4bf..66fa2a2 100644
--- a/test/rasa/data/rules.yml
+++ b/test/rasa/data/rules.yml
@@ -27,4 +27,9 @@ rules:
- intent: ask_time
- action: action_ask_time
+- rule: 用户咨询
+ steps:
+ - intent: ask_problem
+ - action: action_ask_problem
+
diff --git a/test/rasa/domain.yml b/test/rasa/domain.yml
index 0d14b7e..0643a78 100644
--- a/test/rasa/domain.yml
+++ b/test/rasa/domain.yml
@@ -6,6 +6,7 @@ intents:
- ask_time
- ask_date
- out_of_scope
+ - ask_problem
responses:
utter_greet:
@@ -23,3 +24,5 @@ actions:
- action_ask_time
- action_ask_date
- action_gpt_response
+ - action_ask_problem
+
diff --git a/test/rasa/models/20230504-183830-electrical-grass.tar.gz b/test/rasa/models/20230504-183830-electrical-grass.tar.gz
new file mode 100644
index 0000000..cf227dd
Binary files /dev/null and b/test/rasa/models/20230504-183830-electrical-grass.tar.gz differ
diff --git a/test/rasa/readme.txt b/test/rasa/readme.txt
index 66bed12..8fcac5a 100644
--- a/test/rasa/readme.txt
+++ b/test/rasa/readme.txt
@@ -2,4 +2,4 @@
2、安装rasa 包:rasa、rasa-sdk、jieba
3、进入test/rasa目录启动actions:rasa run actions
4、启动rasa api server:rasa run --enable-api
-5、fay_core.py 引入nlp_rasa.py
+5、fay_core.py 引入nlp_rasa.py
\ No newline at end of file