Skip to content

Commit

Permalink
聊天页 直接复读-插队首 全播放器适配 并 修复类型未携带的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed Apr 12, 2024
1 parent 543fec3 commit aad2ffb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"idle_time_task_forget_reserve_num": 1,
"image_recognition_schedule_forget_duration": 0.1,
"image_recognition_schedule_forget_reserve_num": 1,
"message_queue_max_len": 10,
"message_queue_max_len": 50,
"priority_mapping": {
"copywriting": 1,
"abnormal_alarm": 1,
Expand Down
2 changes: 1 addition & 1 deletion config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"idle_time_task_forget_reserve_num": 1,
"image_recognition_schedule_forget_duration": 0.1,
"image_recognition_schedule_forget_reserve_num": 1,
"message_queue_max_len": 10,
"message_queue_max_len": 50,
"priority_mapping": {
"copywriting": 1,
"abnormal_alarm": 1,
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def send():
logging.info(f"API收到数据:{data_json}")

if data_json["type"] in ["reread", "reread_top_priority"]:
my_handle.reread_handle(data_json)
my_handle.reread_handle(data_json, type=data_json["type"])
elif data_json["type"] == "comment":
my_handle.process_data(data_json, "comment")
elif data_json["type"] == "tuning":
Expand Down
6 changes: 4 additions & 2 deletions utils/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def get_priority_level(audio_json):
# 查找插入位置
new_data_priority = get_priority_level(audio_json)

logging.debug(f"优先级: {new_data_priority}")
logging.info(f"优先级: {new_data_priority}")

# 如果新数据没有 'type' 键或其类型不在 priority_mapping 中,直接插入到末尾
if new_data_priority is None:
Expand All @@ -441,9 +441,11 @@ def get_priority_level(audio_json):
insert_position = i + 1
break

logging.info(f"insert_position={insert_position}")

# 数据队列数据量超长判断,插入位置索引大于最大数,则说明优先级低与队列中已存在数据,丢弃数据
if insert_position >= int(self.config.get("filter", "message_queue_max_len")):
logging.info(f"message_queue 已满,数据丢弃")
logging.info(f"message_queue 已满,数据丢弃:【{audio_json['content']}")
return {"code": 1, "msg": f"message_queue 已满,数据丢弃:【{audio_json['content']}】"}

# 获取线程锁,避免同时操作
Expand Down
7 changes: 0 additions & 7 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4738,13 +4738,6 @@ def talk_chat_box_reread(insert_index=-1, type="reread"):
"content": content
}
else:
# 重载一下配置
tmp_config = Config(config_path)

# 判断下播放器类型
if tmp_config.get("play_audio", "player") != "audio_player_v2":
ui.notify(position="top", type="warning", message="插队功能仅在音频播放器为audio_player_v2的情况下可用")
return

data = {
"type": type,
Expand Down

0 comments on commit aad2ffb

Please sign in to comment.