|
1 | 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
2 | 2 |
|
| 3 | +from typing import Dict, List, Union, Optional |
| 4 | +from typing_extensions import Literal, Annotated, TypeAlias |
| 5 | + |
| 6 | +from .turn import Turn |
| 7 | +from ..._utils import PropertyInfo |
3 | 8 | from ..._models import BaseModel |
4 | | -from .turn_response_event_payload import TurnResponseEventPayload |
| 9 | +from ..inference_step import InferenceStep |
| 10 | +from ..shared.tool_call import ToolCall |
| 11 | +from ..shield_call_step import ShieldCallStep |
| 12 | +from ..tool_execution_step import ToolExecutionStep |
| 13 | +from ..memory_retrieval_step import MemoryRetrievalStep |
| 14 | + |
| 15 | +__all__ = [ |
| 16 | + "TurnResponseEvent", |
| 17 | + "Payload", |
| 18 | + "PayloadAgentTurnResponseStepStartPayload", |
| 19 | + "PayloadAgentTurnResponseStepProgressPayload", |
| 20 | + "PayloadAgentTurnResponseStepProgressPayloadDelta", |
| 21 | + "PayloadAgentTurnResponseStepProgressPayloadDeltaTextDelta", |
| 22 | + "PayloadAgentTurnResponseStepProgressPayloadDeltaImageDelta", |
| 23 | + "PayloadAgentTurnResponseStepProgressPayloadDeltaToolCallDelta", |
| 24 | + "PayloadAgentTurnResponseStepProgressPayloadDeltaToolCallDeltaToolCall", |
| 25 | + "PayloadAgentTurnResponseStepCompletePayload", |
| 26 | + "PayloadAgentTurnResponseStepCompletePayloadStepDetails", |
| 27 | + "PayloadAgentTurnResponseTurnStartPayload", |
| 28 | + "PayloadAgentTurnResponseTurnCompletePayload", |
| 29 | + "PayloadAgentTurnResponseTurnAwaitingInputPayload", |
| 30 | +] |
| 31 | + |
| 32 | + |
| 33 | +class PayloadAgentTurnResponseStepStartPayload(BaseModel): |
| 34 | + event_type: Literal["step_start"] |
| 35 | + """Type of event being reported""" |
| 36 | + |
| 37 | + step_id: str |
| 38 | + """Unique identifier for the step within a turn""" |
| 39 | + |
| 40 | + step_type: Literal["inference", "tool_execution", "shield_call", "memory_retrieval"] |
| 41 | + """Type of step being executed""" |
| 42 | + |
| 43 | + metadata: Optional[Dict[str, Union[bool, float, str, List[object], object, None]]] = None |
| 44 | + """(Optional) Additional metadata for the step""" |
| 45 | + |
| 46 | + |
| 47 | +class PayloadAgentTurnResponseStepProgressPayloadDeltaTextDelta(BaseModel): |
| 48 | + text: str |
| 49 | + """The incremental text content""" |
| 50 | + |
| 51 | + type: Literal["text"] |
| 52 | + """Discriminator type of the delta. Always "text" """ |
| 53 | + |
| 54 | + |
| 55 | +class PayloadAgentTurnResponseStepProgressPayloadDeltaImageDelta(BaseModel): |
| 56 | + image: str |
| 57 | + """The incremental image data as bytes""" |
| 58 | + |
| 59 | + type: Literal["image"] |
| 60 | + """Discriminator type of the delta. Always "image" """ |
| 61 | + |
| 62 | + |
| 63 | +PayloadAgentTurnResponseStepProgressPayloadDeltaToolCallDeltaToolCall: TypeAlias = Union[str, ToolCall] |
| 64 | + |
| 65 | + |
| 66 | +class PayloadAgentTurnResponseStepProgressPayloadDeltaToolCallDelta(BaseModel): |
| 67 | + parse_status: Literal["started", "in_progress", "failed", "succeeded"] |
| 68 | + """Current parsing status of the tool call""" |
| 69 | + |
| 70 | + tool_call: PayloadAgentTurnResponseStepProgressPayloadDeltaToolCallDeltaToolCall |
| 71 | + """Either an in-progress tool call string or the final parsed tool call""" |
| 72 | + |
| 73 | + type: Literal["tool_call"] |
| 74 | + """Discriminator type of the delta. Always "tool_call" """ |
| 75 | + |
| 76 | + |
| 77 | +PayloadAgentTurnResponseStepProgressPayloadDelta: TypeAlias = Annotated[ |
| 78 | + Union[ |
| 79 | + PayloadAgentTurnResponseStepProgressPayloadDeltaTextDelta, |
| 80 | + PayloadAgentTurnResponseStepProgressPayloadDeltaImageDelta, |
| 81 | + PayloadAgentTurnResponseStepProgressPayloadDeltaToolCallDelta, |
| 82 | + ], |
| 83 | + PropertyInfo(discriminator="type"), |
| 84 | +] |
| 85 | + |
| 86 | + |
| 87 | +class PayloadAgentTurnResponseStepProgressPayload(BaseModel): |
| 88 | + delta: PayloadAgentTurnResponseStepProgressPayloadDelta |
| 89 | + """Incremental content changes during step execution""" |
| 90 | + |
| 91 | + event_type: Literal["step_progress"] |
| 92 | + """Type of event being reported""" |
| 93 | + |
| 94 | + step_id: str |
| 95 | + """Unique identifier for the step within a turn""" |
| 96 | + |
| 97 | + step_type: Literal["inference", "tool_execution", "shield_call", "memory_retrieval"] |
| 98 | + """Type of step being executed""" |
| 99 | + |
| 100 | + |
| 101 | +PayloadAgentTurnResponseStepCompletePayloadStepDetails: TypeAlias = Annotated[ |
| 102 | + Union[InferenceStep, ToolExecutionStep, ShieldCallStep, MemoryRetrievalStep], |
| 103 | + PropertyInfo(discriminator="step_type"), |
| 104 | +] |
| 105 | + |
| 106 | + |
| 107 | +class PayloadAgentTurnResponseStepCompletePayload(BaseModel): |
| 108 | + event_type: Literal["step_complete"] |
| 109 | + """Type of event being reported""" |
| 110 | + |
| 111 | + step_details: PayloadAgentTurnResponseStepCompletePayloadStepDetails |
| 112 | + """Complete details of the executed step""" |
| 113 | + |
| 114 | + step_id: str |
| 115 | + """Unique identifier for the step within a turn""" |
| 116 | + |
| 117 | + step_type: Literal["inference", "tool_execution", "shield_call", "memory_retrieval"] |
| 118 | + """Type of step being executed""" |
| 119 | + |
| 120 | + |
| 121 | +class PayloadAgentTurnResponseTurnStartPayload(BaseModel): |
| 122 | + event_type: Literal["turn_start"] |
| 123 | + """Type of event being reported""" |
| 124 | + |
| 125 | + turn_id: str |
| 126 | + """Unique identifier for the turn within a session""" |
| 127 | + |
| 128 | + |
| 129 | +class PayloadAgentTurnResponseTurnCompletePayload(BaseModel): |
| 130 | + event_type: Literal["turn_complete"] |
| 131 | + """Type of event being reported""" |
| 132 | + |
| 133 | + turn: Turn |
| 134 | + """Complete turn data including all steps and results""" |
| 135 | + |
| 136 | + |
| 137 | +class PayloadAgentTurnResponseTurnAwaitingInputPayload(BaseModel): |
| 138 | + event_type: Literal["turn_awaiting_input"] |
| 139 | + """Type of event being reported""" |
| 140 | + |
| 141 | + turn: Turn |
| 142 | + """Turn data when waiting for external tool responses""" |
| 143 | + |
5 | 144 |
|
6 | | -__all__ = ["TurnResponseEvent"] |
| 145 | +Payload: TypeAlias = Annotated[ |
| 146 | + Union[ |
| 147 | + PayloadAgentTurnResponseStepStartPayload, |
| 148 | + PayloadAgentTurnResponseStepProgressPayload, |
| 149 | + PayloadAgentTurnResponseStepCompletePayload, |
| 150 | + PayloadAgentTurnResponseTurnStartPayload, |
| 151 | + PayloadAgentTurnResponseTurnCompletePayload, |
| 152 | + PayloadAgentTurnResponseTurnAwaitingInputPayload, |
| 153 | + ], |
| 154 | + PropertyInfo(discriminator="event_type"), |
| 155 | +] |
7 | 156 |
|
8 | 157 |
|
9 | 158 | class TurnResponseEvent(BaseModel): |
10 | | - payload: TurnResponseEventPayload |
| 159 | + payload: Payload |
11 | 160 | """Event-specific payload containing event data""" |
0 commit comments