mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-24 02:57:13 +00:00
feat(provider): add pipeline reasoning controls (#2373)
* feat(provider): add pipeline reasoning controls * fix(provider): preserve local agent model compatibility * refactor(web): use shadcn reasoning slider * fix(runtime): stabilize reasoning chat delivery * fix(provider): route reasoning controls by model family * fix(provider): handle hosted Kimi reasoning protocols * fix(provider): map qwen reasoning levels to budgets * fix(provider): preserve think tags in streamed reasoning * fix(provider): preserve reasoning tool metadata * style(provider): satisfy ruff checks after merge * fix(persistence): preserve reasoning migration compatibility
This commit is contained in:
@@ -5,6 +5,7 @@ import contextvars
|
||||
import logging
|
||||
import time
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
|
||||
import pydantic
|
||||
@@ -25,6 +26,15 @@ _current_pipeline_uuid: contextvars.ContextVar[str | None] = contextvars.Context
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class WebSocketReplyContext:
|
||||
"""Trusted routing context retained when the originating socket reconnects."""
|
||||
|
||||
scope: WebSocketScope
|
||||
pipeline_uuid: str
|
||||
session_id: str | None
|
||||
|
||||
|
||||
class WebSocketMessage(pydantic.BaseModel):
|
||||
"""WebSocket消息格式"""
|
||||
|
||||
@@ -265,6 +275,11 @@ class WebSocketAdapter(abstract_platform_adapter.AbstractMessagePlatformAdapter)
|
||||
embed_target = self._parse_embed_target(sender_id)
|
||||
if embed_target is not None:
|
||||
return embed_target
|
||||
reply_context = getattr(message_source, '_websocket_reply_context', None)
|
||||
if isinstance(reply_context, WebSocketReplyContext):
|
||||
if reply_context.scope != self._scope():
|
||||
raise ValueError('WebSocket reply context does not match this adapter scope')
|
||||
return reply_context.pipeline_uuid, reply_context.session_id
|
||||
raise ValueError('WebSocket reply target is not bound to this adapter scope')
|
||||
|
||||
async def send_message(
|
||||
@@ -685,6 +700,16 @@ class WebSocketAdapter(abstract_platform_adapter.AbstractMessagePlatformAdapter)
|
||||
|
||||
# 异步触发事件处理
|
||||
# Use owner_bot's listeners if available, otherwise fall back to proxy bot
|
||||
object.__setattr__(
|
||||
event,
|
||||
'_websocket_reply_context',
|
||||
WebSocketReplyContext(
|
||||
scope=connection.scope,
|
||||
pipeline_uuid=pipeline_uuid,
|
||||
session_id=connection.session_id,
|
||||
),
|
||||
)
|
||||
|
||||
listeners = (
|
||||
owner_bot.adapter.listeners
|
||||
if (owner_bot and hasattr(owner_bot.adapter, 'listeners') and owner_bot.adapter.listeners)
|
||||
|
||||
Reference in New Issue
Block a user