Skip to content

Commit

Permalink
Merge pull request #269 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
修复智谱AI返回内容有\n时,也会进行语音合成的bug;删除部分违禁词
  • Loading branch information
Ikaros-521 authored Sep 1, 2023
2 parents 735b751 + 6c7360a commit 18dc3e4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,8 @@ cmd运行`npm i docsify-cli -g`

- 2023-09-01
- 新增 智谱AI的接入,支持上下文记忆。
- 修复智谱AI返回内容有\n时,也会进行语音合成的bug
- 删除部分违禁词

</details>

Expand Down
4 changes: 0 additions & 4 deletions data/badwords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@
毛淫欲
宿命论
打手槍
联系
民政部
抗震
核弹
Expand Down Expand Up @@ -2025,7 +2024,6 @@
多維社
出卖
李登柱
语句
性技巧
吴官正
爱滋
Expand Down Expand Up @@ -4687,7 +4685,6 @@
斷水
维护
特贡
公司
任亚平
賤人
宁王府
Expand Down Expand Up @@ -5615,7 +5612,6 @@
鄒德威
廖暉
裸女
女人
瓦良格
替考
淫照
Expand Down
4 changes: 4 additions & 0 deletions utils/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ async def my_play_voice(self, message):
# logging.info("裁剪后的合成文本:" + text)

message["content"] = message["content"].replace('\n', '。')

# 空数据就散了吧
if message["content"] == "":
return
except Exception as e:
logging.error(traceback.format_exc())
return
Expand Down
7 changes: 6 additions & 1 deletion utils/gpt_model/zhipu.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ def get_resp(self, prompt):

logging.info(f"总耗费token:{ret['data']['usage']['total_tokens']}")

return ret['data']['choices'][0]['content']
# 返回的文本回答,追加删除\n 字符
resp_content = ret['data']['choices'][0]['content'].replace("\\n", "")

# logging.info(f"resp_content={resp_content}")

return resp_content
except Exception as e:
logging.error(traceback.format_exc())
return None
Expand Down

0 comments on commit 18dc3e4

Please sign in to comment.