mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-12 00:36:03 +00:00
perf: minor fixes
This commit is contained in:
@@ -106,6 +106,7 @@ class ChatMessageHandler(handler.MessageHandler):
|
|||||||
query.session.using_conversation.messages.extend(query.resp_messages)
|
query.session.using_conversation.messages.extend(query.resp_messages)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.ap.logger.error(f'对话({query.query_id})请求失败: {type(e).__name__} {str(e)}')
|
self.ap.logger.error(f'对话({query.query_id})请求失败: {type(e).__name__} {str(e)}')
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
hide_exception_info = query.pipeline_config['output']['misc']['hide-exception']
|
hide_exception_info = query.pipeline_config['output']['misc']['hide-exception']
|
||||||
|
|
||||||
|
|||||||
@@ -10,17 +10,7 @@ metadata:
|
|||||||
zh_Hans: "用于流水线调试的网页聊天适配器"
|
zh_Hans: "用于流水线调试的网页聊天适配器"
|
||||||
icon: ""
|
icon: ""
|
||||||
spec:
|
spec:
|
||||||
config:
|
config: []
|
||||||
- name: enable-stream-reply
|
|
||||||
label:
|
|
||||||
en_US: Enable Stream Reply Mode
|
|
||||||
zh_Hans: 启用电报流式回复模式
|
|
||||||
description:
|
|
||||||
en_US: If enabled, the bot will use the stream of telegram reply mode
|
|
||||||
zh_Hans: 如果启用,将使用电报流式方式来回复内容
|
|
||||||
type: boolean
|
|
||||||
required: true
|
|
||||||
default: false
|
|
||||||
execution:
|
execution:
|
||||||
python:
|
python:
|
||||||
path: "webchat.py"
|
path: "webchat.py"
|
||||||
|
|||||||
@@ -148,8 +148,6 @@ class MessageChunk(pydantic.BaseModel):
|
|||||||
|
|
||||||
tool_call_id: typing.Optional[str] = None
|
tool_call_id: typing.Optional[str] = None
|
||||||
|
|
||||||
# tool_calls: typing.Optional[list[ToolCallChunk]] = None
|
|
||||||
|
|
||||||
is_final: bool = False
|
is_final: bool = False
|
||||||
|
|
||||||
def readable_str(self) -> str:
|
def readable_str(self) -> str:
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ class LLMAPIRequester(metaclass=abc.ABCMeta):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
|
||||||
async def invoke_llm_stream(
|
async def invoke_llm_stream(
|
||||||
self,
|
self,
|
||||||
query: core_entities.Query,
|
query: core_entities.Query,
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ class LocalAgentRunner(runner.RequestRunner):
|
|||||||
query.use_llm_model,
|
query.use_llm_model,
|
||||||
req_messages,
|
req_messages,
|
||||||
query.use_funcs,
|
query.use_funcs,
|
||||||
stream=is_stream,
|
|
||||||
extra_args=query.use_llm_model.model_entity.extra_args,
|
extra_args=query.use_llm_model.model_entity.extra_args,
|
||||||
):
|
):
|
||||||
yield msg
|
yield msg
|
||||||
@@ -113,7 +112,6 @@ class LocalAgentRunner(runner.RequestRunner):
|
|||||||
query.use_llm_model,
|
query.use_llm_model,
|
||||||
req_messages,
|
req_messages,
|
||||||
query.use_funcs,
|
query.use_funcs,
|
||||||
stream=is_stream,
|
|
||||||
extra_args=query.use_llm_model.model_entity.extra_args,
|
extra_args=query.use_llm_model.model_entity.extra_args,
|
||||||
):
|
):
|
||||||
yield msg
|
yield msg
|
||||||
|
|||||||
@@ -134,8 +134,11 @@ stages:
|
|||||||
default: true
|
default: true
|
||||||
- name: remove_think
|
- name: remove_think
|
||||||
label:
|
label:
|
||||||
en_US: remove think
|
en_US: Remove CoT
|
||||||
zh_Hans: 删除深度思考消息
|
zh_Hans: 删除思维链
|
||||||
|
description:
|
||||||
|
en_US: If enabled, LangBot will remove the LLM thought content in response
|
||||||
|
zh_Hans: 如果启用,将自动删除大模型回复中的模型思考内容
|
||||||
type: boolean
|
type: boolean
|
||||||
required: true
|
required: true
|
||||||
default: true
|
default: true
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ export default function DebugDialog({
|
|||||||
const botMessage: Message = {
|
const botMessage: Message = {
|
||||||
id: -1,
|
id: -1,
|
||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
content: '生成中...',
|
content: 'Generating...',
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
message_chain: [{ type: 'Plain', text: '' }],
|
message_chain: [{ type: 'Plain', text: '' }],
|
||||||
};
|
};
|
||||||
@@ -216,6 +216,7 @@ export default function DebugDialog({
|
|||||||
selectedPipelineId,
|
selectedPipelineId,
|
||||||
(data) => {
|
(data) => {
|
||||||
// 处理流式响应数据
|
// 处理流式响应数据
|
||||||
|
console.log('data', data);
|
||||||
if (data.message) {
|
if (data.message) {
|
||||||
// 更新完整内容
|
// 更新完整内容
|
||||||
fullContent = data.message.content;
|
fullContent = data.message.content;
|
||||||
@@ -231,8 +232,11 @@ export default function DebugDialog({
|
|||||||
|
|
||||||
typingInterval = setInterval(() => {
|
typingInterval = setInterval(() => {
|
||||||
if (currentPos < targetContent.length) {
|
if (currentPos < targetContent.length) {
|
||||||
displayContent = targetContent.substring(0, currentPos + 1);
|
displayContent = targetContent.substring(
|
||||||
currentPos++;
|
0,
|
||||||
|
currentPos + 10,
|
||||||
|
);
|
||||||
|
currentPos += 10;
|
||||||
|
|
||||||
// 更新bot消息
|
// 更新bot消息
|
||||||
setMessages((prevMessages) => {
|
setMessages((prevMessages) => {
|
||||||
@@ -255,7 +259,7 @@ export default function DebugDialog({
|
|||||||
} else {
|
} else {
|
||||||
clearInterval(typingInterval);
|
clearInterval(typingInterval);
|
||||||
}
|
}
|
||||||
}, 30); // 调整这个值可以改变打字速度
|
}, 1); // 调整这个值可以改变打字速度
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user