ADK for TypeScript: API Reference
    Preparing search index...

    接口事件(Interface Event)

    表示代理(agent)与用户之间的对话中发生的某个事件。

    它用于存储对话的内容,以及代理(agent)执行的操作(例如函数调用等)。

    interface Event {
        "[EVENT_SIGNATURE_SYMBOL]"?: true;
        actions: EventActions;
        author?: string;
        branch?: string;
        citationMetadata?: CitationMetadata;
        content?: Content;
        customMetadata?: { [key: string]: unknown };
        errorCode?: string;
        errorMessage?: string;
        finishReason?: FinishReason;
        goAway?: LiveServerGoAway;
        groundingMetadata?: GroundingMetadata;
        id: string;
        inputTranscription?: Transcription;
        interactionId?: string;
        interrupted?: boolean;
        invocationId: string;
        isolationScope?: string;
        liveSessionId?: string;
        liveSessionResumptionUpdate?: LiveServerSessionResumptionUpdate;
        longRunningToolIds?: string[];
        modelVersion?: string;
        nodeInfo?: NodeInfo;
        output?: unknown;
        outputTranscription?: Transcription;
        partial?: boolean;
        route?: Route;
        timestamp: number;
        turnComplete?: boolean;
        usageMetadata?: GenerateContentResponseUsageMetadata;
    }

    层次结构(Hierarchy)查看摘要)

    "[EVENT_SIGNATURE_SYMBOL]"?: true

    用于标识该对象为 ADK 的品牌名称。 事件.

    由……设置 createEvent 并经过……的审核/检查。 isEvent这是可选的,因为事件数据也是从存储或会话数据中重新生成的;在这些数据中,包含产品品牌信息的字段(该字段属于不可序列化的类型)是缺失的。

    actions: EventActions

    代理所采取的行动。

    author?: string

    “user”或代理的名称,用于标识是谁将该事件添加到了会话中。

    branch?: string

    该事件的所属分支。 其格式为 `agent_1.agent_2.agent_3`,其中 `agent_1` 是 `agent_2` 的上级(即父节点),`agent_2` 又是 `agent_3` 的上级。

    当多个子代理不应看到其他子代理的对话历史记录时,可以使用“Branch”功能。

    citationMetadata?: CitationMetadata

    响应中的引用元数据(citation metadata)。

    content?: Content

    响应的内容。

    customMetadata?: { [key: string]: unknown }

    `LlmResponse` 的自定义元数据(custom metadata)。 这是一个可选的键值对(key-value pair),用于为 `LlmResponse` 添加标签。 **注意:** 整个对象必须能够被序列化为 JSON 格式。

    errorCode?: string

    如果响应是一个错误,则会返回错误代码。该错误代码因型号不同而有所差异。

    errorMessage?: string

    如果响应出现错误,则会显示错误信息。

    finishReason?: FinishReason

    响应的完成原因(即响应状态或完成方式)。

    goAway?: LiveServerGoAway

    这是一个服务器端发出的信号,表示实时连接即将被关闭。调用方应使用最新的会话恢复机制重新建立连接。

    groundingMetadata?: GroundingMetadata

    响应中的基础元数据(即用于描述响应内容的元数据)。

    id: string

    该事件的唯一标识符。 请不要自行分配该标识符;它将由系统(即会话管理机制)自动分配。

    inputTranscription?: Transcription

    用户输入内容的音频转录结果。

    interactionId?: string

    模型返回的交互 ID(如果有的话)。

    interrupted?: boolean

    该标志表示在生成内容时,大型语言模型(LLM)的运行被中断了。通常这种情况是由于用户在双方向(bidi)文本流传输过程中进行了干预(例如中途停止了操作)。

    invocationId: string

    该事件的调用 ID(invocation ID)在添加到会话(session)之前必须是非空的。

    isolationScope?: string

    **工作流程(Workflow):** `scope` 标签用于隔离多个代理(agent)之间的通信,从而确保各个代理无法看到彼此的事件。该机制类似于 Python 中的实现方式。 Event.isolation_scope.

    liveSessionId?: string

    该直播会话的会话 ID(Session ID)。

    liveSessionResumptionUpdate?: LiveServerSessionResumptionUpdate

    关于 LlmResponse 的会话恢复更新信息

    longRunningToolIds?: string[]

    这是一组长时间运行的函数调用的 ID。代理客户端可以通过这个字段来判断哪些函数调用处于“长时间运行”状态。该字段仅适用于函数调用事件(function call events)。

    modelVersion?: string

    用于生成响应的模型版本。

    nodeInfo?: NodeInfo

    工作流程(Workflow):用于追踪发送数据节点的来源信息。该功能基于 Python 实现。 Event.node_info.

    output?: unknown

    工作流程(Workflow):由发送数据(即“发射节点”)产生的结构化输出结果(如果有的话)。

    一类字段镜像技术(First-class field mirroring) google/adk-python Event.output该字段由工作流引擎使用,用于将节点的返回值与其内容一起传输。

    outputTranscription?: Transcription

    模型输出的音频转录文本。

    partial?: boolean

    该字段用于指示文本内容是否属于一个未完成的文本流。 仅适用于流式传输模式(streaming mode),且仅当文本内容为纯文本(plain text)时才会被使用。

    route?: Route

    **工作流程(Workflow):** 路由节点(routing node)会生成相应的路由键(route key),这些键会被图(graph)用来选择相应的输出边(outgoing edge)。 - 单个路由键只会触发一个分支(branch); - 如果路由键是一个数组(array),则所有与该数组中的某个值匹配的路由都会被触发(即多个分支会被同时执行)。 该机制的设计类似于 Python 的实现方式。 Event.route.

    timestamp: number

    该事件的时间戳。

    turnComplete?: boolean

    该字段用于指示模型返回的响应是否完整。 仅适用于流式处理(streaming mode)模式。

    usageMetadata?: GenerateContentResponseUsageMetadata

    LlmResponse 的使用元数据(usage metadata)。