pub struct WebSocketHumanLoopProvider { /* private fields */ }Available on crate feature
human-loop only.Expand description
WebSocket 人工介入 Provider。
在本地启动 WebSocket 服务器,向已连接的客户端推送审批/输入请求, 并异步等待第一个响应。适合与 Web UI、移动端或自定义工具集成。
§使用方法
// Requires the `websocket` feature.§协议
服务端 → 客户端:
{
"kind": "approval" | "input",
"request_id": "uuid",
"prompt": "...",
"tool_name": "xxx",
"args": { ... }
}客户端 → 服务端:
{
"request_id": "uuid",
"decision": "approved" | "rejected",
"text": "用户输入(input 场景)",
"reason": "可选说明"
}Implementations§
Source§impl WebSocketHumanLoopProvider
impl WebSocketHumanLoopProvider
Sourcepub async fn bind(port: u16) -> Result<WebSocketHumanLoopProvider, Error>
pub async fn bind(port: u16) -> Result<WebSocketHumanLoopProvider, Error>
绑定端口并启动 WebSocket 服务器,默认超时 5 分钟。
Sourcepub async fn bind_with_timeout(
port: u16,
timeout: Duration,
) -> Result<WebSocketHumanLoopProvider, Error>
pub async fn bind_with_timeout( port: u16, timeout: Duration, ) -> Result<WebSocketHumanLoopProvider, Error>
绑定端口并启动 WebSocket 服务器,自定义超时。
Trait Implementations§
Source§impl HumanLoopProvider for WebSocketHumanLoopProvider
impl HumanLoopProvider for WebSocketHumanLoopProvider
Source§fn request(
&self,
req: HumanLoopRequest,
) -> Pin<Box<dyn Future<Output = Result<HumanLoopResponse, ReactError>> + Send + '_>>
fn request( &self, req: HumanLoopRequest, ) -> Pin<Box<dyn Future<Output = Result<HumanLoopResponse, ReactError>> + Send + '_>>
发起人工介入请求
Auto Trait Implementations§
impl Freeze for WebSocketHumanLoopProvider
impl !RefUnwindSafe for WebSocketHumanLoopProvider
impl Send for WebSocketHumanLoopProvider
impl Sync for WebSocketHumanLoopProvider
impl Unpin for WebSocketHumanLoopProvider
impl UnsafeUnpin for WebSocketHumanLoopProvider
impl !UnwindSafe for WebSocketHumanLoopProvider
Blanket Implementations§
Source§impl<T> BatchApprovalProvider for Twhere
T: HumanLoopProvider,
impl<T> BatchApprovalProvider for Twhere
T: HumanLoopProvider,
Source§fn batch_request(
&self,
batch: BatchApprovalRequest,
) -> Pin<Box<dyn Future<Output = Result<BatchApprovalResponse, ReactError>> + Send + '_>>
fn batch_request( &self, batch: BatchApprovalRequest, ) -> Pin<Box<dyn Future<Output = Result<BatchApprovalResponse, ReactError>> + Send + '_>>
批量审批请求 Read more
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request