fix: 修复流式输出问题,以及各种神秘问题
This commit is contained in:
@@ -50,7 +50,9 @@ class Heartflow:
|
|||||||
|
|
||||||
# 检查所有子心流
|
# 检查所有子心流
|
||||||
for subheartflow_id, subheartflow in self._subheartflows.items():
|
for subheartflow_id, subheartflow in self._subheartflows.items():
|
||||||
if current_time - subheartflow.last_active_time > global_config.sub_heart_flow_stop_time: # 10分钟 = 600秒
|
if (
|
||||||
|
current_time - subheartflow.last_active_time > global_config.sub_heart_flow_stop_time
|
||||||
|
): # 10分钟 = 600秒
|
||||||
inactive_subheartflows.append(subheartflow_id)
|
inactive_subheartflows.append(subheartflow_id)
|
||||||
logger.info(f"发现不活跃的子心流: {subheartflow_id}")
|
logger.info(f"发现不活跃的子心流: {subheartflow_id}")
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ class ChatBot:
|
|||||||
logger.debug(f"8处理表情包时间: {timer2 - timer1}秒")
|
logger.debug(f"8处理表情包时间: {timer2 - timer1}秒")
|
||||||
|
|
||||||
timer1 = time.time()
|
timer1 = time.time()
|
||||||
await self._update_using_response(message, chat, response_set)
|
await self._update_using_response(message, response_set)
|
||||||
timer2 = time.time()
|
timer2 = time.time()
|
||||||
logger.info(f"6更新htfl时间: {timer2 - timer1}秒")
|
logger.info(f"6更新htfl时间: {timer2 - timer1}秒")
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ class ChatBot:
|
|||||||
stream_id, limit=global_config.MAX_CONTEXT_SIZE, combine=True
|
stream_id, limit=global_config.MAX_CONTEXT_SIZE, combine=True
|
||||||
)
|
)
|
||||||
|
|
||||||
heartflow.get_subheartflow(stream_id).do_after_reply(response_set, chat_talking_prompt)
|
await heartflow.get_subheartflow(stream_id).do_after_reply(response_set, chat_talking_prompt)
|
||||||
|
|
||||||
async def _send_response_messages(self, message, chat, response_set, thinking_id):
|
async def _send_response_messages(self, message, chat, response_set, thinking_id):
|
||||||
container = message_manager.get_container(chat.stream_id)
|
container = message_manager.get_container(chat.stream_id)
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ class ResponseGenerator:
|
|||||||
self.model_reasoning = LLM_request(
|
self.model_reasoning = LLM_request(
|
||||||
model=global_config.llm_reasoning,
|
model=global_config.llm_reasoning,
|
||||||
temperature=0.7,
|
temperature=0.7,
|
||||||
max_tokens=1000,
|
max_tokens=3000,
|
||||||
stream=True,
|
|
||||||
request_type="response",
|
request_type="response",
|
||||||
)
|
)
|
||||||
self.model_normal = LLM_request(
|
self.model_normal = LLM_request(
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
from fastapi import FastAPI, HTTPException
|
from fastapi import FastAPI, HTTPException
|
||||||
from typing import Dict, Any, Callable, List
|
from typing import Dict, Any, Callable, List
|
||||||
|
from src.common.logger import get_module_logger
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import asyncio
|
import asyncio
|
||||||
import uvicorn
|
import uvicorn
|
||||||
import os
|
import os
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
logger = get_module_logger("api")
|
||||||
|
|
||||||
|
|
||||||
class BaseMessageAPI:
|
class BaseMessageAPI:
|
||||||
@@ -50,8 +54,9 @@ class BaseMessageAPI:
|
|||||||
for handler in self.message_handlers:
|
for handler in self.message_handlers:
|
||||||
try:
|
try:
|
||||||
await handler(self.cache[0])
|
await handler(self.cache[0])
|
||||||
except Exception:
|
except Exception as e:
|
||||||
pass
|
logger.error(str(e))
|
||||||
|
logger.error(traceback.format_exc())
|
||||||
self.cache.pop(0)
|
self.cache.pop(0)
|
||||||
if len(self.cache) > 0:
|
if len(self.cache) > 0:
|
||||||
await asyncio.sleep(0.1 / len(self.cache))
|
await asyncio.sleep(0.1 / len(self.cache))
|
||||||
|
|||||||
Reference in New Issue
Block a user