forked from xszyou/Fay
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ 打出Fay数字人助理版作为主分支(带货版移到分支[`fay-sales-edition`]); + 添加Fay助理的文字沟通窗口(文字与语音同步); + 添加沟通记录本地保存功能; + 升级ChatGLM-6B的应用逻辑,长文本与语音回复分享;
- Loading branch information
Showing
24 changed files
with
788 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import json | ||
import requests | ||
|
||
def question(cont): | ||
url="http://localhost:5005/webhooks/rest/webhook" | ||
req = json.dumps({"sender": "user", "message": cont}) | ||
headers = {'content-type': 'application/json'} | ||
r = requests.post(url, headers=headers, data=req) | ||
lists = json.loads(r.text) | ||
|
||
return lists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import sqlite3 | ||
import time | ||
import threading | ||
import functools | ||
def synchronized(func): | ||
@functools.wraps(func) | ||
def wrapper(self, *args, **kwargs): | ||
with self.lock: | ||
return func(self, *args, **kwargs) | ||
return wrapper | ||
class Content_Db: | ||
|
||
def __init__(self) -> None: | ||
self.lock = threading.Lock() | ||
|
||
|
||
|
||
#初始化 | ||
def init_db(self): | ||
conn = sqlite3.connect('fay.db') | ||
c = conn.cursor() | ||
c.execute('''CREATE TABLE T_Msg | ||
(id INTEGER PRIMARY KEY autoincrement, | ||
type char(10), | ||
way char(10), | ||
content TEXT NOT NULL, | ||
createtime Int);''') | ||
conn.commit() | ||
conn.close() | ||
|
||
|
||
|
||
|
||
#添加对话 | ||
@synchronized | ||
def add_content(self,type,way,content): | ||
conn = sqlite3.connect("fay.db") | ||
cur = conn.cursor() | ||
cur.execute("insert into T_Msg (type,way,content,createtime) values (?,?,?,?)",(type,way,content,int(time.time()))) | ||
|
||
conn.commit() | ||
conn.close() | ||
return cur.lastrowid | ||
|
||
|
||
|
||
#获取对话内容 | ||
@synchronized | ||
def get_list(self,way,order,limit): | ||
conn = sqlite3.connect("fay.db") | ||
cur = conn.cursor() | ||
if(way == 'all'): | ||
cur.execute("select type,way,content,createtime,datetime(createtime, 'unixepoch', 'localtime') as timetext from T_Msg order by createtime "+order+" limit ?",(limit,)) | ||
elif(way == 'notappended'): | ||
cur.execute("select type,way,content,createtime,datetime(createtime, 'unixepoch', 'localtime') as timetext from T_Msg where way != 'appended' order by createtime "+order+" limit ?",(limit,)) | ||
else: | ||
cur.execute("select type,way,content,createtime,datetime(createtime, 'unixepoch', 'localtime') as timetext from T_Msg where way = ? order by createtime "+order+" limit ?",(way,limit,)) | ||
|
||
list = cur.fetchall() | ||
conn.close() | ||
return list | ||
|
||
|
||
|
||
|
||
|
||
# a = Content_Db() | ||
# s = a.get_list('all','desc',10) | ||
# print(s) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.