10 lines
336 B
Python
10 lines
336 B
Python
"""流式上下文,用于在 LangGraph 节点和 agent_service 之间传递 token 回调"""
|
|
import contextvars
|
|
import asyncio
|
|
from typing import Optional, Any
|
|
|
|
# 上下文变量:存储当前的 token 队列
|
|
token_queue_var: contextvars.ContextVar[Optional[asyncio.Queue]] = contextvars.ContextVar(
|
|
"token_queue", default=None
|
|
)
|