年翻更新
1、修复服务器ip配置,配置页没替换问题; 2、修复开启状态偶尔没对齐问题; 3、修复关闭时关闭按钮停留在关闭中问题; 4、修复星座读取错误问题; 5、修复刷新重复提醒开启问题; 6、新增是否进行语音合成的选择; 7、文字沟通接口加入“观察描述”; 8、聊天记录时间改为毫秒级; 9、补充数字人和远程音频的连接状态显示; 10、修复备注填写无法保存问题。
This commit is contained in:
parent
341d045375
commit
059b6cee6d
@ -22,6 +22,7 @@
|
|||||||
"join": 10
|
"join": 10
|
||||||
},
|
},
|
||||||
"playSound": true,
|
"playSound": true,
|
||||||
|
"sound_synthesis_enabled": false,
|
||||||
"visualization": false
|
"visualization": false
|
||||||
},
|
},
|
||||||
"items": [],
|
"items": [],
|
||||||
|
@ -50,7 +50,7 @@ class Content_Db:
|
|||||||
conn = sqlite3.connect("fay.db")
|
conn = sqlite3.connect("fay.db")
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
try:
|
try:
|
||||||
cur.execute("insert into T_Msg (type,way,content,createtime,username,uid) values (?,?,?,?,?,?)",(type,way,content,int(time.time()),username,uid))
|
cur.execute("insert into T_Msg (type,way,content,createtime,username,uid) values (?,?,?,?,?,?)",(type, way, content, time.time(), username, uid))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
except:
|
except:
|
||||||
util.log(1, "请检查参数是否有误")
|
util.log(1, "请检查参数是否有误")
|
||||||
|
@ -65,7 +65,7 @@ modules = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#大语言模型回复
|
#大语言模型回复
|
||||||
def handle_chat_message(msg, username='User'):
|
def handle_chat_message(msg, username='User', observation=''):
|
||||||
text = ''
|
text = ''
|
||||||
textlist = []
|
textlist = []
|
||||||
try:
|
try:
|
||||||
@ -81,7 +81,7 @@ def handle_chat_message(msg, username='User'):
|
|||||||
text = textlist[0]['text']
|
text = textlist[0]['text']
|
||||||
else:
|
else:
|
||||||
uid = member_db.new_instance().find_user(username)
|
uid = member_db.new_instance().find_user(username)
|
||||||
text = selected_module.question(msg, uid)
|
text = selected_module.question(msg, uid, observation)
|
||||||
util.printInfo(1, username, '自然语言处理完成. 耗时: {} ms'.format(math.floor((time.time() - tm) * 1000)))
|
util.printInfo(1, username, '自然语言处理完成. 耗时: {} ms'.format(math.floor((time.time() - tm) * 1000)))
|
||||||
if text == '哎呀,你这么说我也不懂,详细点呗' or text == '':
|
if text == '哎呀,你这么说我也不懂,详细点呗' or text == '':
|
||||||
util.printInfo(1, username, '[!] 自然语言无语了!')
|
util.printInfo(1, username, '[!] 自然语言无语了!')
|
||||||
@ -161,9 +161,9 @@ class FeiFei:
|
|||||||
if wsa_server.get_instance().is_connected(username):
|
if wsa_server.get_instance().is_connected(username):
|
||||||
content = {'Topic': 'Unreal', 'Data': {'Key': 'log', 'Value': "思考中..."}, 'Username' : username, 'robot': f'http://{cfg.fay_url}:5000/robot/Thinking.jpg'}
|
content = {'Topic': 'Unreal', 'Data': {'Key': 'log', 'Value': "思考中..."}, 'Username' : username, 'robot': f'http://{cfg.fay_url}:5000/robot/Thinking.jpg'}
|
||||||
wsa_server.get_instance().add_cmd(content)
|
wsa_server.get_instance().add_cmd(content)
|
||||||
text,textlist = handle_chat_message(interact.data["msg"], username)
|
text,textlist = handle_chat_message(interact.data["msg"], username, interact.data.get("observation", ""))
|
||||||
|
|
||||||
qa_service.QAService().record_qapair(interact.data["msg"], text)#沟通记录缓存到qa文件
|
# qa_service.QAService().record_qapair(interact.data["msg"], text)#沟通记录缓存到qa文件
|
||||||
else:
|
else:
|
||||||
text = answer
|
text = answer
|
||||||
|
|
||||||
@ -315,15 +315,16 @@ class FeiFei:
|
|||||||
def say(self, interact, text):
|
def say(self, interact, text):
|
||||||
try:
|
try:
|
||||||
result = None
|
result = None
|
||||||
audio_url = interact.data.get('audio')#透传的音频
|
if config_util.config["interact"]["sound_synthesis_enabled"]:
|
||||||
if audio_url is not None:
|
audio_url = interact.data.get('audio')#透传的音频
|
||||||
file_name = 'sample-' + str(int(time.time() * 1000)) + '.wav'
|
if audio_url is not None:
|
||||||
result = self.download_wav(audio_url, './samples/', file_name)
|
file_name = 'sample-' + str(int(time.time() * 1000)) + '.wav'
|
||||||
elif config_util.config["interact"]["playSound"] or wsa_server.get_instance().is_connected(interact.data.get("user")) or self.__is_send_remote_device_audio(interact):#tts
|
result = self.download_wav(audio_url, './samples/', file_name)
|
||||||
util.printInfo(1, interact.data.get('user'), '合成音频...')
|
elif config_util.config["interact"]["playSound"] or wsa_server.get_instance().is_connected(interact.data.get("user")) or self.__is_send_remote_device_audio(interact):#tts
|
||||||
tm = time.time()
|
util.printInfo(1, interact.data.get('user'), '合成音频...')
|
||||||
result = self.sp.to_sample(text.replace("*", ""), self.__get_mood_voice())
|
tm = time.time()
|
||||||
util.printInfo(1, interact.data.get('user'), '合成音频完成. 耗时: {} ms 文件:{}'.format(math.floor((time.time() - tm) * 1000), result))
|
result = self.sp.to_sample(text.replace("*", ""), self.__get_mood_voice())
|
||||||
|
util.printInfo(1, interact.data.get('user'), '合成音频完成. 耗时: {} ms 文件:{}'.format(math.floor((time.time() - tm) * 1000), result))
|
||||||
|
|
||||||
if result is not None:
|
if result is not None:
|
||||||
MyThread(target=self.__process_output_audio, args=[result, interact, text]).start()
|
MyThread(target=self.__process_output_audio, args=[result, interact, text]).start()
|
||||||
|
@ -7,6 +7,7 @@ import re
|
|||||||
from flask import Flask, render_template, request, jsonify, Response, send_file
|
from flask import Flask, render_template, request, jsonify, Response, send_file
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
import requests
|
import requests
|
||||||
|
import datetime
|
||||||
|
|
||||||
import fay_booter
|
import fay_booter
|
||||||
|
|
||||||
@ -82,8 +83,7 @@ def api_get_data():
|
|||||||
voice_list = tts_voice.get_voice_list()
|
voice_list = tts_voice.get_voice_list()
|
||||||
send_voice_list = []
|
send_voice_list = []
|
||||||
if config_util.tts_module == 'ali':
|
if config_util.tts_module == 'ali':
|
||||||
wsa_server.get_web_instance().add_cmd({
|
voice_list = [
|
||||||
"voiceList": [
|
|
||||||
{"id": "abin", "name": "阿斌"},
|
{"id": "abin", "name": "阿斌"},
|
||||||
{"id": "zhixiaobai", "name": "知小白"},
|
{"id": "zhixiaobai", "name": "知小白"},
|
||||||
{"id": "zhixiaoxia", "name": "知小夏"},
|
{"id": "zhixiaoxia", "name": "知小夏"},
|
||||||
@ -159,10 +159,12 @@ def api_get_data():
|
|||||||
{"id": "laotie", "name": "老铁"},
|
{"id": "laotie", "name": "老铁"},
|
||||||
{"id": "laomei", "name": "老妹"},
|
{"id": "laomei", "name": "老妹"},
|
||||||
{"id": "aikan", "name": "艾侃"}
|
{"id": "aikan", "name": "艾侃"}
|
||||||
]
|
|
||||||
})
|
]
|
||||||
|
send_voice_list = {"voiceList": voice_list}
|
||||||
|
wsa_server.get_web_instance().add_cmd(send_voice_list)
|
||||||
elif config_util.tts_module == 'volcano':
|
elif config_util.tts_module == 'volcano':
|
||||||
wsa_server.get_web_instance().add_cmd({
|
voice_list = {
|
||||||
"voiceList": [
|
"voiceList": [
|
||||||
{"id": "BV001_streaming", "name": "通用女声"},
|
{"id": "BV001_streaming", "name": "通用女声"},
|
||||||
{"id": "BV002_streaming", "name": "通用男声"},
|
{"id": "BV002_streaming", "name": "通用男声"},
|
||||||
@ -171,7 +173,9 @@ def api_get_data():
|
|||||||
{"id": "zh_male_wennuanahu_moon_bigtts", "name": "温暖阿虎/Alvin"},
|
{"id": "zh_male_wennuanahu_moon_bigtts", "name": "温暖阿虎/Alvin"},
|
||||||
{"id": "zh_female_wanwanxiaohe_moon_bigtts", "name": "湾湾小何"},
|
{"id": "zh_female_wanwanxiaohe_moon_bigtts", "name": "湾湾小何"},
|
||||||
]
|
]
|
||||||
})
|
}
|
||||||
|
send_voice_list = {"voiceList": voice_list}
|
||||||
|
wsa_server.get_web_instance().add_cmd(send_voice_list)
|
||||||
else:
|
else:
|
||||||
voice_list = tts_voice.get_voice_list()
|
voice_list = tts_voice.get_voice_list()
|
||||||
send_voice_list = []
|
send_voice_list = []
|
||||||
@ -181,10 +185,11 @@ def api_get_data():
|
|||||||
wsa_server.get_web_instance().add_cmd({
|
wsa_server.get_web_instance().add_cmd({
|
||||||
"voiceList": send_voice_list
|
"voiceList": send_voice_list
|
||||||
})
|
})
|
||||||
|
voice_list = send_voice_list
|
||||||
wsa_server.get_web_instance().add_cmd({"deviceList": __get_device_list()})
|
wsa_server.get_web_instance().add_cmd({"deviceList": __get_device_list()})
|
||||||
if fay_booter.is_running():
|
if fay_booter.is_running():
|
||||||
wsa_server.get_web_instance().add_cmd({"liveState": 1})
|
wsa_server.get_web_instance().add_cmd({"liveState": 1})
|
||||||
return json.dumps({'config': config_util.config, 'voice_list' : send_voice_list})
|
return json.dumps({'config': config_util.config, 'voice_list' : voice_list})
|
||||||
|
|
||||||
|
|
||||||
@__app.route('/api/start-live', methods=['post'])
|
@__app.route('/api/start-live', methods=['post'])
|
||||||
@ -227,7 +232,8 @@ def api_get_Msg():
|
|||||||
relist = []
|
relist = []
|
||||||
i = len(list)-1
|
i = len(list)-1
|
||||||
while i >= 0:
|
while i >= 0:
|
||||||
relist.append(dict(type=list[i][0], way=list[i][1], content=list[i][2], createtime=list[i][3], timetext=list[i][4], username=list[i][5]))
|
timetext = datetime.datetime.fromtimestamp(list[i][3]).strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
|
||||||
|
relist.append(dict(type=list[i][0], way=list[i][1], content=list[i][2], createtime=list[i][3], timetext=timetext, username=list[i][5]))
|
||||||
i -= 1
|
i -= 1
|
||||||
if fay_booter.is_running():
|
if fay_booter.is_running():
|
||||||
wsa_server.get_web_instance().add_cmd({"liveState": 1})
|
wsa_server.get_web_instance().add_cmd({"liveState": 1})
|
||||||
@ -249,7 +255,8 @@ def api_send_v1_chat_completions():
|
|||||||
username = 'User'
|
username = 'User'
|
||||||
|
|
||||||
model = data.get('model', 'fay')
|
model = data.get('model', 'fay')
|
||||||
interact = Interact("text", 1, {'user': username, 'msg': last_content})
|
observation = data.get('observation', '')
|
||||||
|
interact = Interact("text", 1, {'user': username, 'msg': last_content, 'observation': observation})
|
||||||
util.printInfo(3, "文字沟通接口", '{}'.format(interact.data["msg"]), time.time())
|
util.printInfo(3, "文字沟通接口", '{}'.format(interact.data["msg"]), time.time())
|
||||||
text = fay_booter.feiFei.on_interact(interact)
|
text = fay_booter.feiFei.on_interact(interact)
|
||||||
|
|
||||||
@ -265,6 +272,12 @@ def api_get_Member_list():
|
|||||||
return json.dumps({'list': list})
|
return json.dumps({'list': list})
|
||||||
|
|
||||||
|
|
||||||
|
@__app.route('/api/get_run_status', methods=['post'])
|
||||||
|
def api_get_run_status():
|
||||||
|
status = fay_booter.is_running()
|
||||||
|
return json.dumps({'status': status})
|
||||||
|
|
||||||
|
|
||||||
def stream_response(text):
|
def stream_response(text):
|
||||||
def generate():
|
def generate():
|
||||||
for chunk in text_chunks(text):
|
for chunk in text_chunks(text):
|
||||||
|
@ -83,6 +83,12 @@ class FayInterface {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRunStatus() {
|
||||||
|
return this.fetchData(`${this.baseApiUrl}/api/get_run_status`, {
|
||||||
|
method: 'POST'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getMessageHistory(username) {
|
getMessageHistory(username) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const url = `${this.baseApiUrl}/api/get-msg`;
|
const url = `${this.baseApiUrl}/api/get-msg`;
|
||||||
@ -122,6 +128,19 @@ class FayInterface {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTime(){
|
||||||
|
const date = new Date();
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 月份从0开始,需要+1
|
||||||
|
const day = date.getDate().toString().padStart(2, '0');
|
||||||
|
const hours = date.getHours().toString().padStart(2, '0');
|
||||||
|
const minutes = date.getMinutes().toString().padStart(2, '0');
|
||||||
|
const seconds = date.getSeconds().toString().padStart(2, '0');
|
||||||
|
const milliseconds = date.getMilliseconds().toString().padStart(3, '0');
|
||||||
|
const currentDateTimeWithMs = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${milliseconds}`;
|
||||||
|
return currentDateTimeWithMs
|
||||||
|
}
|
||||||
|
|
||||||
handleIncomingMessage(data) {
|
handleIncomingMessage(data) {
|
||||||
const vueInstance = this.vueInstance;
|
const vueInstance = this.vueInstance;
|
||||||
// console.log('Incoming message:', data);
|
// console.log('Incoming message:', data);
|
||||||
@ -129,10 +148,8 @@ class FayInterface {
|
|||||||
vueInstance.liveState = data.liveState;
|
vueInstance.liveState = data.liveState;
|
||||||
if (data.liveState === 1) {
|
if (data.liveState === 1) {
|
||||||
vueInstance.configEditable = false;
|
vueInstance.configEditable = false;
|
||||||
vueInstance.sendSuccessMsg('已开启!');
|
|
||||||
} else if (data.liveState === 0) {
|
} else if (data.liveState === 0) {
|
||||||
vueInstance.configEditable = true;
|
vueInstance.configEditable = true;
|
||||||
vueInstance.sendSuccessMsg('已关闭!');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +186,7 @@ class FayInterface {
|
|||||||
username: data.panelReply.username,
|
username: data.panelReply.username,
|
||||||
content: data.panelReply.content,
|
content: data.panelReply.content,
|
||||||
type: data.panelReply.type,
|
type: data.panelReply.type,
|
||||||
time: new Date().toLocaleTimeString()
|
timetext: this.getTime()
|
||||||
});
|
});
|
||||||
vueInstance.$nextTick(() => {
|
vueInstance.$nextTick(() => {
|
||||||
const chatContainer = vueInstance.$el.querySelector('.chatmessage');
|
const chatContainer = vueInstance.$el.querySelector('.chatmessage');
|
||||||
@ -207,17 +224,31 @@ class FayInterface {
|
|||||||
chatMessages: {},
|
chatMessages: {},
|
||||||
panelMsg: '',
|
panelMsg: '',
|
||||||
panelReply: '',
|
panelReply: '',
|
||||||
robot:'static/images/Normal.gif'
|
robot:'static/images/Normal.gif',
|
||||||
|
base_url: 'http://127.0.0.1:5000'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.initFayService();
|
this.initFayService();
|
||||||
this.loadUserList();
|
// this.loadUserList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initFayService() {
|
initFayService() {
|
||||||
this.fayService = new FayInterface('ws://127.0.0.1:10003', 'http://127.0.0.1:5000', this);
|
this.fayService = new FayInterface('ws://127.0.0.1:10003', this.base_url, this);
|
||||||
this.fayService.connectWebSocket();
|
this.fayService.connectWebSocket();
|
||||||
|
this.fayService.websocket.addEventListener('open', () => {
|
||||||
|
this.loadUserList();
|
||||||
|
});
|
||||||
|
this.fayService.getRunStatus().then((data) => {
|
||||||
|
if (data) {
|
||||||
|
if(data.status){
|
||||||
|
this.liveState = 1;
|
||||||
|
}else{
|
||||||
|
this.liveState = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
sendMessage() {
|
sendMessage() {
|
||||||
let _this = this;
|
let _this = this;
|
||||||
@ -241,7 +272,7 @@ class FayInterface {
|
|||||||
document.querySelector('.chatmessage').scrollTop = height;
|
document.querySelector('.chatmessage').scrollTop = height;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
_this.newMessage = '';
|
_this.newMessage = '';
|
||||||
let url = "http://127.0.0.1:5000/api/send";
|
let url = `${this.base_url}/api/send`;
|
||||||
let send_data = {
|
let send_data = {
|
||||||
"msg": text,
|
"msg": text,
|
||||||
"username": usernameToSend
|
"username": usernameToSend
|
||||||
@ -255,7 +286,6 @@ class FayInterface {
|
|||||||
xhr.onreadystatechange = async function () {
|
xhr.onreadystatechange = async function () {
|
||||||
if (!executed && xhr.status === 200) {
|
if (!executed && xhr.status === 200) {
|
||||||
executed = true;
|
executed = true;
|
||||||
// 成功处理逻辑(可以添加额外的回调操作)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -283,11 +313,13 @@ class FayInterface {
|
|||||||
startLive() {
|
startLive() {
|
||||||
this.liveState = 2
|
this.liveState = 2
|
||||||
this.fayService.startLive().then(() => {
|
this.fayService.startLive().then(() => {
|
||||||
|
this.sendSuccessMsg('已开启!');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
stopLive() {
|
stopLive() {
|
||||||
this.fayService.stopLive().then(() => {
|
this.fayService.stopLive().then(() => {
|
||||||
this.liveState = 3
|
this.liveState = 3
|
||||||
|
this.sendSuccessMsg('已关闭!');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -73,6 +73,13 @@ class FayInterface {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRunStatus() {
|
||||||
|
return this.fetchData(`${this.baseApiUrl}/api/get_run_status`, {
|
||||||
|
method: 'POST'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
handleIncomingMessage(data) {
|
handleIncomingMessage(data) {
|
||||||
const vueInstance = this.vueInstance;
|
const vueInstance = this.vueInstance;
|
||||||
console.log('Incoming message:', data);
|
console.log('Incoming message:', data);
|
||||||
@ -80,10 +87,8 @@ class FayInterface {
|
|||||||
vueInstance.liveState = data.liveState;
|
vueInstance.liveState = data.liveState;
|
||||||
if (data.liveState === 1) {
|
if (data.liveState === 1) {
|
||||||
vueInstance.configEditable = false;
|
vueInstance.configEditable = false;
|
||||||
vueInstance.sendSuccessMsg('已开启!');
|
|
||||||
} else if (data.liveState === 0) {
|
} else if (data.liveState === 0) {
|
||||||
vueInstance.configEditable = true;
|
vueInstance.configEditable = true;
|
||||||
vueInstance.sendSuccessMsg('已关闭!');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +137,7 @@ new Vue({
|
|||||||
visualization_detection_enabled: false,
|
visualization_detection_enabled: false,
|
||||||
source_record_enabled: false,
|
source_record_enabled: false,
|
||||||
source_record_device: '',
|
source_record_device: '',
|
||||||
|
sound_synthesis_enabled: true,
|
||||||
attribute_name: "",
|
attribute_name: "",
|
||||||
attribute_gender: "",
|
attribute_gender: "",
|
||||||
attribute_age: "",
|
attribute_age: "",
|
||||||
@ -165,6 +171,7 @@ new Vue({
|
|||||||
}],
|
}],
|
||||||
automatic_player_status: false,
|
automatic_player_status: false,
|
||||||
automatic_player_url: "",
|
automatic_player_url: "",
|
||||||
|
host_url: "http://127.0.0.1:5000"
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@ -173,10 +180,22 @@ new Vue({
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initFayService() {
|
initFayService() {
|
||||||
this.fayService = new FayInterface('ws://127.0.0.1:10003', 'http://127.0.0.1:5000', this);
|
this.fayService = new FayInterface('ws://127.0.0.1:10003', this.host_url, this);
|
||||||
this.fayService.connectWebSocket();
|
this.fayService.connectWebSocket();
|
||||||
},
|
},
|
||||||
getData() {
|
getData() {
|
||||||
|
this.fayService.getRunStatus().then((data) => {
|
||||||
|
if (data) {
|
||||||
|
if(data.status){
|
||||||
|
this.liveState = 1;
|
||||||
|
this.configEditable = false;
|
||||||
|
}else{
|
||||||
|
this.liveState = 0;
|
||||||
|
this.configEditable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
this.fayService.getData().then((data) => {
|
this.fayService.getData().then((data) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
this.voiceList = data.voice_list.map((voice) => ({
|
this.voiceList = data.voice_list.map((voice) => ({
|
||||||
@ -192,6 +211,7 @@ new Vue({
|
|||||||
if (config.interact) {
|
if (config.interact) {
|
||||||
this.play_sound_enabled = config.interact.playSound;
|
this.play_sound_enabled = config.interact.playSound;
|
||||||
this.visualization_detection_enabled = config.interact.visualization;
|
this.visualization_detection_enabled = config.interact.visualization;
|
||||||
|
this.sound_synthesis_enabled = config.interact.sound_synthesis_enabled;
|
||||||
this.QnA = config.interact.QnA;
|
this.QnA = config.interact.QnA;
|
||||||
}
|
}
|
||||||
if (config.source && config.source.record) {
|
if (config.source && config.source.record) {
|
||||||
@ -224,7 +244,7 @@ new Vue({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
saveConfig() {
|
saveConfig() {
|
||||||
let url = "http://127.0.0.1:5000/api/submit";
|
let url = `${this.host_url}/api/submit`;
|
||||||
let send_data = {
|
let send_data = {
|
||||||
"config": {
|
"config": {
|
||||||
"source": {
|
"source": {
|
||||||
@ -257,6 +277,7 @@ new Vue({
|
|||||||
},
|
},
|
||||||
"interact": {
|
"interact": {
|
||||||
"playSound": this.play_sound_enabled,
|
"playSound": this.play_sound_enabled,
|
||||||
|
"sound_synthesis_enabled": this.sound_synthesis_enabled,
|
||||||
"visualization": this.visualization_detection_enabled,
|
"visualization": this.visualization_detection_enabled,
|
||||||
"QnA": this.QnA,
|
"QnA": this.QnA,
|
||||||
"maxInteractTime": this.interact_maxInteractTime,
|
"maxInteractTime": this.interact_maxInteractTime,
|
||||||
@ -293,12 +314,14 @@ new Vue({
|
|||||||
this.liveState = 2
|
this.liveState = 2
|
||||||
this.fayService.startLive().then(() => {
|
this.fayService.startLive().then(() => {
|
||||||
this.configEditable = false;
|
this.configEditable = false;
|
||||||
|
this.sendSuccessMsg('已开启!');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
stopLive() {
|
stopLive() {
|
||||||
|
this.liveState = 3
|
||||||
this.fayService.stopLive().then(() => {
|
this.fayService.stopLive().then(() => {
|
||||||
this.configEditable = true;
|
this.configEditable = true;
|
||||||
this.liveState = 3
|
this.sendSuccessMsg('已关闭!');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
sendSuccessMsg(message) {
|
sendSuccessMsg(message) {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="main_right">
|
<div class="main_right">
|
||||||
<div class="setting_fay_top"><span style="color: #000; font-size: 20px; padding-right: 10px;">人设</span>请设置你的数字人人设 </div>
|
<div class="setting_fay_top"><span style="color: #000; font-size: 20px; padding-right: 10px;">人设</span><span v-if="isConnected" style="color: #f56c6c;">已连接数字人</span><span style="margin-left: 10px;color:#f56c6c;" v-if="remoteAudioConnected">已连接远程音频</span> </div>
|
||||||
<!-- 以上是即时信息显示 -->
|
<!-- 以上是即时信息显示 -->
|
||||||
|
|
||||||
<div class="setting_fay">
|
<div class="setting_fay">
|
||||||
@ -48,7 +48,7 @@
|
|||||||
<li> <span class="font_name">职 业:</span><input class="section_1" :disabled="!configEditable" v-model="attribute_job" placeholder="请输入内容"/></li>
|
<li> <span class="font_name">职 业:</span><input class="section_1" :disabled="!configEditable" v-model="attribute_job" placeholder="请输入内容"/></li>
|
||||||
<li> <span class="font_name"> 联系方式:</span><input class="section_1" :disabled="!configEditable" v-model="attribute_contact" placeholder="请输入内容" /></li>
|
<li> <span class="font_name"> 联系方式:</span><input class="section_1" :disabled="!configEditable" v-model="attribute_contact" placeholder="请输入内容" /></li>
|
||||||
<li> <span class="font_name">Q&A文件:</span><input class="section_1" :disabled="!configEditable" v-model="QnA" placeholder="请输入内容" /></li>
|
<li> <span class="font_name">Q&A文件:</span><input class="section_1" :disabled="!configEditable" v-model="QnA" placeholder="请输入内容" /></li>
|
||||||
<li> <span class="font_name">补 充:</span><textarea class="section_1" style="height: 165px;vertical-align: middle;"></textarea></li>
|
<li> <span class="font_name">补 充:</span><textarea v-model="attribute_hobby" class="section_1" style="height: 165px;vertical-align: middle;"></textarea></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting_rup">
|
<div class="setting_rup">
|
||||||
@ -81,8 +81,7 @@
|
|||||||
<span class="font_name"> 麦 克 风 :</span>
|
<span class="font_name"> 麦 克 风 :</span>
|
||||||
<el-switch v-model="source_record_enabled" active-color="#13ce66" inactive-color="#ff4949" :disabled="!configEditable"> </el-switch>
|
<el-switch v-model="source_record_enabled" active-color="#13ce66" inactive-color="#ff4949" :disabled="!configEditable"> </el-switch>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="setting_wakeup">
|
<div class="setting_wakeup">
|
||||||
<ul>
|
<ul>
|
||||||
<li> <span class="font_name">声音选择:</span>
|
<li> <span class="font_name">声音选择:</span>
|
||||||
@ -91,6 +90,10 @@
|
|||||||
:label="item.label" :value="item.value">
|
:label="item.label" :value="item.value">
|
||||||
</option>
|
</option>
|
||||||
</select></li>
|
</select></li>
|
||||||
|
<li>
|
||||||
|
<span class="font_name"> 声 音 合 成 :</span>
|
||||||
|
<el-switch v-model="sound_synthesis_enabled" active-color="#13ce66" inactive-color="#ff4949" :disabled="!configEditable"> </el-switch>
|
||||||
|
</li>
|
||||||
<li style="display: flex;"> <span class="font_name" style="line-height: 36px;"> 敏 感 度 :</span>
|
<li style="display: flex;"> <span class="font_name" style="line-height: 36px;"> 敏 感 度 :</span>
|
||||||
<el-slider style="width: 230px;" v-model="interact_perception_follow" :disabled="!configEditable"></el-slider></li>
|
<el-slider style="width: 230px;" v-model="interact_perception_follow" :disabled="!configEditable"></el-slider></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -3,7 +3,7 @@ import requests
|
|||||||
from core import content_db
|
from core import content_db
|
||||||
|
|
||||||
|
|
||||||
def question(cont, uid=0):
|
def question(cont, uid=0, observation=""):
|
||||||
contentdb = content_db.new_instance()
|
contentdb = content_db.new_instance()
|
||||||
if uid == 0:
|
if uid == 0:
|
||||||
list = contentdb.get_list('all','desc', 11)
|
list = contentdb.get_list('all','desc', 11)
|
||||||
|
37
llm/nlp_VisualGLM.py
Normal file
37
llm/nlp_VisualGLM.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
"""
|
||||||
|
这是对于清华智谱VisualGLM-6B的代码,在使用前请先安装并启动好VisualGLM-6B.
|
||||||
|
https://github.com/THUDM/VisualGLM-6B
|
||||||
|
"""
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
import uuid
|
||||||
|
import os
|
||||||
|
import cv2
|
||||||
|
from ai_module import yolov8
|
||||||
|
|
||||||
|
# Initialize an empty history list
|
||||||
|
communication_history = []
|
||||||
|
|
||||||
|
def question(cont, uid=0, observation=""):
|
||||||
|
if not yolov8.new_instance().get_status():
|
||||||
|
return "请先启动“Fay Eyes”"
|
||||||
|
content = {
|
||||||
|
"text":cont,
|
||||||
|
"history":communication_history}
|
||||||
|
img = yolov8.new_instance().get_img()
|
||||||
|
if yolov8.new_instance().get_status() and img is not None:
|
||||||
|
filename = str(uuid.uuid4()) + ".jpg"
|
||||||
|
current_working_directory = os.getcwd()
|
||||||
|
filepath = os.path.join(current_working_directory, "data", filename)
|
||||||
|
cv2.imwrite(filepath, img)
|
||||||
|
content["image"] = filepath
|
||||||
|
url = "http://127.0.0.1:8080"
|
||||||
|
print(content)
|
||||||
|
req = json.dumps(content)
|
||||||
|
headers = {'content-type': 'application/json'}
|
||||||
|
r = requests.post(url, headers=headers, data=req)
|
||||||
|
|
||||||
|
# Save this conversation to history
|
||||||
|
communication_history.append([cont, r.text])
|
||||||
|
|
||||||
|
return r.text + "\n(相片:" + filepath + ")"
|
@ -5,7 +5,7 @@ from utils import util
|
|||||||
from utils import config_util as cfg
|
from utils import config_util as cfg
|
||||||
from core import content_db
|
from core import content_db
|
||||||
|
|
||||||
def question(cont, uid=0):
|
def question(cont, uid=0, observation=""):
|
||||||
contentdb = content_db.new_instance()
|
contentdb = content_db.new_instance()
|
||||||
if uid == 0:
|
if uid == 0:
|
||||||
communication_history = contentdb.get_list('all','desc', 11)
|
communication_history = contentdb.get_list('all','desc', 11)
|
||||||
|
@ -15,7 +15,7 @@ import json
|
|||||||
|
|
||||||
httpproxy = cfg.proxy_config
|
httpproxy = cfg.proxy_config
|
||||||
|
|
||||||
def question(cont, uid=0):
|
def question(cont, uid=0, observation=""):
|
||||||
url= cfg.gpt_base_url + "/chat/completions"
|
url= cfg.gpt_base_url + "/chat/completions"
|
||||||
|
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
@ -28,15 +28,18 @@ def question(cont, uid=0):
|
|||||||
person_info = cfg.config["attribute"]
|
person_info = cfg.config["attribute"]
|
||||||
model_engine = cfg.gpt_model_engine
|
model_engine = cfg.gpt_model_engine
|
||||||
#此处可以定义角色的行为和特征,假装xx模型可以绕过chatgpt信息检查
|
#此处可以定义角色的行为和特征,假装xx模型可以绕过chatgpt信息检查
|
||||||
|
observation_text = ""
|
||||||
|
if observation != "":
|
||||||
|
observation_text = f"以下是当前观测结果:{observation},观测结果只供参考。"
|
||||||
prompt = f"""
|
prompt = f"""
|
||||||
你是数字人:{person_info['name']},你性别为{person_info['gender']},
|
你是我的数字人,你名字是:{person_info['name']},你性别为{person_info['gender']},
|
||||||
你年龄为{person_info['age']},你出生地在{person_info['birth']},
|
你年龄为{person_info['age']},你出生地在{person_info['birth']},
|
||||||
你生肖为{person_info['zodiac']},你星座为{person_info['age']},
|
你生肖为{person_info['zodiac']},你星座为{person_info['constellation']},
|
||||||
你职业为{person_info['job']},你联系方式为{person_info['contact']},
|
你职业为{person_info['job']},你联系方式为{person_info['contact']},
|
||||||
你喜好为{person_info['hobby']}。
|
{person_info['hobby']}。你通过外部数据接口获取到我的情况是:{observation_text}。
|
||||||
回答之前请一步一步想清楚。对于大部分问题,请直接回答并提供有用和准确的信息。
|
回答之前请一步一步想清楚。对于大部分问题,请直接回答并提供有用和准确的信息。
|
||||||
但当有人质疑你是假的 AI,或者质疑你是用 ChatGPT 套的壳制作的时候,请避而不答,转而讲一个笑话。所有回复请尽量控制在20字内。
|
但当有人质疑你是假的 AI,或者质疑你是用 ChatGPT 套的壳制作的时候,请避而不答,转而讲一个笑话。所有回复请尽量控制在20字内。
|
||||||
"""
|
"""
|
||||||
contentdb = content_db.new_instance()
|
contentdb = content_db.new_instance()
|
||||||
if uid == 0:
|
if uid == 0:
|
||||||
communication_history = contentdb.get_list('all','desc', 11)
|
communication_history = contentdb.get_list('all','desc', 11)
|
||||||
|
@ -81,7 +81,7 @@ def generate_prompt(question):
|
|||||||
info = f"{context}\n{instruction}\n{creative_instruction}\n{complexity_handling}\n问题:{question}\n回答:"
|
info = f"{context}\n{instruction}\n{creative_instruction}\n{complexity_handling}\n问题:{question}\n回答:"
|
||||||
return info
|
return info
|
||||||
|
|
||||||
def question(cont, uid=0):
|
def question(cont, uid=0, observation=""):
|
||||||
try:
|
try:
|
||||||
save_all()
|
save_all()
|
||||||
info = generate_prompt(cont)
|
info = generate_prompt(cont)
|
||||||
|
@ -7,7 +7,7 @@ from utils import util
|
|||||||
from utils import config_util as cfg
|
from utils import config_util as cfg
|
||||||
from core.authorize_tb import Authorize_Tb
|
from core.authorize_tb import Authorize_Tb
|
||||||
|
|
||||||
def question(cont, uid=0):
|
def question(cont, uid=0, observation=""):
|
||||||
lingju = Lingju()
|
lingju = Lingju()
|
||||||
answer = lingju.question(cont, uid)
|
answer = lingju.question(cont, uid)
|
||||||
return answer
|
return answer
|
||||||
|
@ -4,7 +4,7 @@ import time
|
|||||||
from utils import config_util as cfg
|
from utils import config_util as cfg
|
||||||
from utils import util
|
from utils import util
|
||||||
from core import content_db
|
from core import content_db
|
||||||
def question(cont, uid=0):
|
def question(cont, uid=0, observation=""):
|
||||||
|
|
||||||
contentdb = content_db.new_instance()
|
contentdb = content_db.new_instance()
|
||||||
if uid == 0:
|
if uid == 0:
|
||||||
@ -13,13 +13,16 @@ def question(cont, uid=0):
|
|||||||
communication_history = contentdb.get_list('all','desc', 11, uid)
|
communication_history = contentdb.get_list('all','desc', 11, uid)
|
||||||
|
|
||||||
person_info = cfg.config["attribute"]
|
person_info = cfg.config["attribute"]
|
||||||
|
observation_text = ""
|
||||||
|
if observation != "":
|
||||||
|
observation_text = f"以下是当前观测结果:{observation},观测结果只供参考。"
|
||||||
#此处可以定义角色的行为和特征,假装xx模型可以绕过chatgpt信息检查
|
#此处可以定义角色的行为和特征,假装xx模型可以绕过chatgpt信息检查
|
||||||
prompt = f"""
|
prompt = f"""
|
||||||
你是数字人:{person_info['name']},你性别为{person_info['gender']},
|
你是数字人:{person_info['name']},你性别为{person_info['gender']},
|
||||||
你年龄为{person_info['age']},你出生地在{person_info['birth']},
|
你年龄为{person_info['age']},你出生地在{person_info['birth']},
|
||||||
你生肖为{person_info['zodiac']},你星座为{person_info['age']},
|
你生肖为{person_info['zodiac']},你星座为{person_info['constellation']},
|
||||||
你职业为{person_info['job']},你联系方式为{person_info['contact']},
|
你职业为{person_info['job']},你联系方式为{person_info['contact']},
|
||||||
你喜好为{person_info['hobby']}。
|
你喜好为{person_info['hobby']}。{observation_text}
|
||||||
回答之前请一步一步想清楚。对于大部分问题,请直接回答并提供有用和准确的信息。
|
回答之前请一步一步想清楚。对于大部分问题,请直接回答并提供有用和准确的信息。
|
||||||
请尽量以可阅读的方式回复,所有回复请尽量控制在20字内。
|
请尽量以可阅读的方式回复,所有回复请尽量控制在20字内。
|
||||||
"""
|
"""
|
||||||
|
@ -46,7 +46,7 @@ def load_all_pdfs(folder_path):
|
|||||||
print(f"上传 {file_name} 失败: {e}")
|
print(f"上传 {file_name} 失败: {e}")
|
||||||
|
|
||||||
|
|
||||||
def question(cont, uid=0):
|
def question(cont, uid=0, observation=""):
|
||||||
load_all_pdfs(folder_path)
|
load_all_pdfs(folder_path)
|
||||||
text = client.contextual_completions.prompt_completion(
|
text = client.contextual_completions.prompt_completion(
|
||||||
prompt=cont
|
prompt=cont
|
||||||
|
@ -9,7 +9,7 @@ model = RwkvForCausalLM.from_pretrained("RWKV-4-World-1.5B")
|
|||||||
tokenizer = TRIE_TOKENIZER('./ringrwkv/rwkv_vocab_v20230424.txt')
|
tokenizer = TRIE_TOKENIZER('./ringrwkv/rwkv_vocab_v20230424.txt')
|
||||||
|
|
||||||
data = ""
|
data = ""
|
||||||
def question(cont, uid=0):
|
def question(cont, uid=0, observation=""):
|
||||||
global data
|
global data
|
||||||
prompt = data + f'Question: {cont.strip()}\n\nAnswer:'
|
prompt = data + f'Question: {cont.strip()}\n\nAnswer:'
|
||||||
input_ids = tokenizer.encode(prompt)
|
input_ids = tokenizer.encode(prompt)
|
||||||
|
@ -3,7 +3,7 @@ import json
|
|||||||
from utils import util, config_util
|
from utils import util, config_util
|
||||||
from core import content_db
|
from core import content_db
|
||||||
|
|
||||||
def question(cont, uid=0):
|
def question(cont, uid=0, observation=""):
|
||||||
url = 'https://nlp.aliyuncs.com/v2/api/chat/send'
|
url = 'https://nlp.aliyuncs.com/v2/api/chat/send'
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
|
1
main.py
1
main.py
@ -55,6 +55,7 @@ if __name__ == '__main__':
|
|||||||
#ip替换
|
#ip替换
|
||||||
if config_util.fay_url != "127.0.0.1":
|
if config_util.fay_url != "127.0.0.1":
|
||||||
replace_ip_in_file("gui/static/js/index.js", config_util.fay_url)
|
replace_ip_in_file("gui/static/js/index.js", config_util.fay_url)
|
||||||
|
replace_ip_in_file("gui/static/js/setting.js", config_util.fay_url)
|
||||||
|
|
||||||
#启动数字人接口服务
|
#启动数字人接口服务
|
||||||
ws_server = wsa_server.new_instance(port=10002)
|
ws_server = wsa_server.new_instance(port=10002)
|
||||||
|
Loading…
Reference in New Issue
Block a user