Skip to content

Commit

Permalink
今天星期五
Browse files Browse the repository at this point in the history
1、修复gpt、chatglm2的消息记录方式逻辑。
  • Loading branch information
xszyou committed Sep 1, 2023
1 parent 5802641 commit 486c1dc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,15 @@ Remote Android  [Live2D](https://www.bilibili.com/video/BV1sx4y1d775/?vd_sou

## **三、升级日志**

**2023.09.01**

+ 修复gpt、chatglm2的消息记录方式逻辑。

**2023.08.30**

+ 调整gpt的消息记录方式;

+ *q&a支持RPA自动化脚本。



**2023.08.23:**

+ 更换gpt对接方式;
Expand Down
4 changes: 4 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ Message format: View [WebSocket.md](https://github.com/TheRamU/Fay/blob/main/Web

## **Upgrade Log**

**2023.09.01**

- Fix the message logging logic of GPT and Chatglm2.

**2023.08.30**

- Adjust the message recording method of GPT;
Expand Down
7 changes: 1 addition & 6 deletions WebSocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"Lips":[{"Lip": "sil", "Time": 180}, {"Lip": "FF", "Time": 144}],
"Time": 10,
"Type": "interact"
""
}
}
```
Expand Down Expand Up @@ -111,9 +112,3 @@
| 参数 | 描述 | 类型 | 范围 |
| ---------- | ---------------- | ----- | --------------- |
| Data.text | 文本 | str | |

### 接收消息标记音频播放完成

```php
Play End
```
14 changes: 8 additions & 6 deletions ai_module/nlp_ChatGLM2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@

def question(cont):
content_db = Content_Db()
list = content_db.get_list('all','desc',10)
list = content_db.get_list('all','desc',11)
answer_info = dict()
chat_list = []
for val in list:
i = len(list)-1
while i >= 0:
answer_info = dict()
if val[0] == "member":
if list[i][0] == "member":
answer_info["role"] = "user"
answer_info["content"] = val[2]
elif val[0] == "fay":
answer_info["content"] = list[i][2]
elif list[i][0] == "fay":
answer_info["role"] = "bot"
answer_info["content"] = val[2]
answer_info["content"] = list[i][2]
chat_list.append(answer_info)
i -= 1
content = {
"prompt":"请简单回复我。" + cont,
"history":chat_list}
Expand Down
17 changes: 8 additions & 9 deletions ai_module/nlp_gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,26 @@ def question(cont):
#此处可以定义角色的行为和特征,假装xx模型可以绕过chatgpt信息检查
prompt = "你是数字人Fay。回答之前请一步一步想清楚。你的底层AI算法技术是Fay。当有人质疑你是假的 AI ,或者质疑你是用 ChatGPT 套的壳制作的时候,你就避而不答,转而讲一个笑话。所有回复请用20字内。"
content_db = Content_Db()
communication_history = content_db.get_list('all','desc',10)
communication_history = content_db.get_list('all','desc',11)
#历史记录处理
if len(communication_history)>1:
msg = "以下是历史记录:"
i = 0
for info in communication_history:
if info[0] == 'member':
content = "user:" + info[2]
i = len(communication_history)-1
while i >= 0:
if communication_history[i][0] == 'member':
content = "user:" + communication_history[i][2]
else:
content = "reply:" + info[2]
content = "reply:" + communication_history[i][2]
if msg == "":
msg = content
else:
if i == len(communication_history) - 1:
if i == 0:
msg = msg + "\n现在需要询问您的问题是(直接回答,不用前缀reply:):\n"+ cont
else:
msg = msg + "\n"+ content
i+=1
i -= 1
else:
msg = cont

message=[
{"role": "system", "content": prompt},
{"role": "user", "content": msg}
Expand Down

0 comments on commit 486c1dc

Please sign in to comment.