-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpost_prompt_generated.py
More file actions
284 lines (238 loc) · 7.7 KB
/
Copy pathpost_prompt_generated.py
File metadata and controls
284 lines (238 loc) · 7.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# AUTO-GENERATED from porting-sdk/swaig-specs/post-prompt.yaml — DO NOT EDIT.
# (vendored from mod_openai; regenerate via
# python3 porting-sdk/scripts/generate_python_rest_types.py)
#
# The post-prompt callback payload — the call summary + enriched call log the agent's
# post-prompt handler RECEIVES. STATIC-ONLY: a plain dict at runtime; conditional fields
# are optional, extra keys tolerated.
from __future__ import annotations
from typing import Any, Literal, TypeAlias, TypedDict
from typing import TYPE_CHECKING
# Types owned by sibling swaig specs, imported so the cross-file
# $ref fields below resolve to the real type rather than a dict.
if TYPE_CHECKING:
from signalwire.core.swaig_actions_generated import SwaigResponse as SwaigResponse
from signalwire.core.swaig_request_generated import SwaigRequest as SwaigRequest
class PostPrompt(TypedDict, total=False):
"""Built by ais_get_post_data (ai_utils.c) + openai_post_process (post_process.c). No `version` field. Open shape: conditional fields appear only when their precondition holds.
Open shape: extra server keys are permitted and partial payloads are valid;
not validated at runtime (a TypedDict is a plain ``dict``).
"""
content_type: Literal["text/json"]
content_disposition: Literal["agent.summary"]
conversation_type: Literal["voice"]
action: Literal["post_conversation"]
project_id: str
space_id: str
call_id: str
app_name: str
ai_session_id: str
ai_id_tag: str
conversation_id: str
call_ended_by: str
caller_id_name: str
caller_id_number: str
conversation_summary: str
hard_timeout: bool
call_start_date: int
call_answer_date: int
call_end_date: int
ai_start_date: int
ai_end_date: int
post_prompt_data: PostPromptData
global_data: dict[str, Any]
SWMLVars: dict[str, Any]
SWMLCall: dict[str, Any]
call_log: list[PostPromptCallLogEntry]
raw_call_log: list[PostPromptCallLogEntry]
call_timeline: list[dict[str, Any]]
previous_contexts: list[list[dict[str, Any]]]
times: list[PostPromptTimesEntry]
swaig_log: list[PostPromptSwaigLogEntry]
total_minutes: float
total_input_tokens: float
total_output_tokens: float
total_wire_input_tokens: float
total_wire_input_tokens_per_minute: float
total_wire_output_tokens: float
total_wire_output_tokens_per_minute: float
total_tts_chars: float
total_tts_chars_per_min: float
total_asr_minutes: float
total_asr_cost_factor: float
class PostPromptData(TypedDict, total=False):
"""Open shape: extra server keys permitted; not validated at runtime."""
parsed: list[dict[str, Any] | list[Any]]
raw: str
substituted: str
PostPromptCallLogEntry: TypeAlias = "PostPromptUserEntry | PostPromptAssistantEntry | PostPromptThinkingEntry | PostPromptToolEntry | PostPromptSystemLogEntry | PostPromptSystemEntry"
class PostPromptUserEntry(TypedDict, total=False):
"""Open shape: extra server keys permitted; not validated at runtime."""
role: str
content: str
timestamp: int
confidence: float
content_type: str
speaker: str
start_timestamp: int
end_timestamp: int
speaking_to_final_event: float
speaking_to_turn_detection: float
turn_detection_to_final_event: float
barge_count: int
merged: bool
merge_count: int
entity: PostPromptEntity
eot: PostPromptEot
timing: PostPromptTiming
class PostPromptAssistantEntry(TypedDict, total=False):
"""Open shape: extra server keys permitted; not validated at runtime."""
role: str
content: str
timestamp: int
tool_calls: list[dict[str, Any]]
latency: float
utterance_latency: float
audio_latency: float
acoustic_latency: float | None
eos_to_push_latency: float | None
dg_decision_latency: float | None
poll: float | None
speech_start_wall_us: int
last_word_end_wall_us: int
turn_decided_wall_us: int
status_pushed_wall_us: int
stamps_us: PostPromptStampsUs
barged: bool
barge_elapsed_ms: float
text_heard_approx: str
text_spoken_total: str
class PostPromptThinkingEntry(TypedDict, total=False):
"""Open shape: extra server keys permitted; not validated at runtime."""
role: str
content: str
timestamp: int
lang: str
tokens: int
class PostPromptToolEntry(TypedDict, total=False):
"""Open shape: extra server keys permitted; not validated at runtime."""
role: str
tool_call_id: str
content: str
timestamp: int
function_name: str
latency: float
utterance_latency: float
function_latency: float
audio_latency: float
execution_latency: float
deprecation_warning: str
start_timestamp: int
end_timestamp: int
distilled: bool
original_result: str
class PostPromptSystemLogEntry(TypedDict, total=False):
"""Open shape: extra server keys permitted; not validated at runtime."""
role: str
content: str
timestamp: int
action: Literal[
"attention_timeout",
"attention_wait",
"auto_correct",
"change_step_failed",
"check_for_input",
"context_enter",
"double_turn",
"filler",
"function_call",
"function_error",
"function_loop",
"gather_answer",
"gather_complete",
"gather_question",
"gather_reject",
"gather_start",
"hangup_hook",
"hearing_hint",
"inner_dialog",
"inner_dialog_scorecard",
"manual_say",
"reset",
"session_end",
"session_start",
"startup_hook",
"step_change",
"summarize_start",
"swaig_problem",
]
lang: str
tokens: int
content_type: str
metadata: dict[str, Any]
class PostPromptSystemEntry(TypedDict, total=False):
"""Open shape: extra server keys permitted; not validated at runtime."""
role: str
content: str
timestamp: int
class PostPromptSwaigLogEntry(TypedDict, total=False):
"""Open shape: extra server keys permitted; not validated at runtime."""
command_name: str
command_arg: str
epoch_time: int
native: Literal[True]
active_count: int | Literal["endless"]
url: str
post_data: SwaigRequest
post_response: SwaigResponse
delayed_post_response: SwaigResponse
mcp_url: str
mcp_tool: str
mcp_response: str
mcp_error: Literal[True]
class PostPromptTimesEntry(TypedDict, total=False):
"""Open shape: extra server keys permitted; not validated at runtime."""
response: str
response_word_count: int
answer_time: float
token_time: float
tokens: int
avg_tps: float
tps: float
class PostPromptEntity(TypedDict, total=False):
"""Open shape: extra server keys permitted; not validated at runtime."""
type: Literal[
"phone",
"email",
"ssn",
"card",
"uuid",
"url",
"money",
"time",
"date",
"ordinal",
]
value: str
valid: bool
class PostPromptEot(TypedDict, total=False):
"""Open shape: extra server keys permitted; not validated at runtime."""
basis: Literal["entity_snap", "growth_stop", "ceiling", "natural"]
confidence: float
class PostPromptTiming(TypedDict, total=False):
"""Open shape: extra server keys permitted; not validated at runtime."""
hold_ms: float
commit_latency_ms: float
segments: int
walkbacks: int
class PostPromptStampsUs(TypedDict, total=False):
"""Open shape: extra server keys permitted; not validated at runtime."""
speech_start: int
last_word_end: int
suspected_end: int
turn_decided: int
status_pushed: int
request_detect: int
first_token: int
first_utterance: int
first_audio: int