signalwire-agents 0.1.13__py3-none-any.whl → 1.0.17.dev4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- signalwire_agents/__init__.py +99 -15
- signalwire_agents/agent_server.py +248 -60
- signalwire_agents/agents/bedrock.py +296 -0
- signalwire_agents/cli/__init__.py +9 -0
- signalwire_agents/cli/build_search.py +951 -41
- signalwire_agents/cli/config.py +80 -0
- signalwire_agents/cli/core/__init__.py +10 -0
- signalwire_agents/cli/core/agent_loader.py +470 -0
- signalwire_agents/cli/core/argparse_helpers.py +179 -0
- signalwire_agents/cli/core/dynamic_config.py +71 -0
- signalwire_agents/cli/core/service_loader.py +303 -0
- signalwire_agents/cli/dokku.py +2320 -0
- signalwire_agents/cli/execution/__init__.py +10 -0
- signalwire_agents/cli/execution/datamap_exec.py +446 -0
- signalwire_agents/cli/execution/webhook_exec.py +134 -0
- signalwire_agents/cli/init_project.py +2636 -0
- signalwire_agents/cli/output/__init__.py +10 -0
- signalwire_agents/cli/output/output_formatter.py +255 -0
- signalwire_agents/cli/output/swml_dump.py +186 -0
- signalwire_agents/cli/simulation/__init__.py +10 -0
- signalwire_agents/cli/simulation/data_generation.py +374 -0
- signalwire_agents/cli/simulation/data_overrides.py +200 -0
- signalwire_agents/cli/simulation/mock_env.py +282 -0
- signalwire_agents/cli/swaig_test_wrapper.py +52 -0
- signalwire_agents/cli/test_swaig.py +566 -2366
- signalwire_agents/cli/types.py +81 -0
- signalwire_agents/core/__init__.py +2 -2
- signalwire_agents/core/agent/__init__.py +12 -0
- signalwire_agents/core/agent/config/__init__.py +12 -0
- signalwire_agents/core/agent/deployment/__init__.py +9 -0
- signalwire_agents/core/agent/deployment/handlers/__init__.py +9 -0
- signalwire_agents/core/agent/prompt/__init__.py +14 -0
- signalwire_agents/core/agent/prompt/manager.py +306 -0
- signalwire_agents/core/agent/routing/__init__.py +9 -0
- signalwire_agents/core/agent/security/__init__.py +9 -0
- signalwire_agents/core/agent/swml/__init__.py +9 -0
- signalwire_agents/core/agent/tools/__init__.py +15 -0
- signalwire_agents/core/agent/tools/decorator.py +97 -0
- signalwire_agents/core/agent/tools/registry.py +210 -0
- signalwire_agents/core/agent_base.py +845 -2916
- signalwire_agents/core/auth_handler.py +233 -0
- signalwire_agents/core/config_loader.py +259 -0
- signalwire_agents/core/contexts.py +418 -0
- signalwire_agents/core/data_map.py +3 -15
- signalwire_agents/core/function_result.py +116 -44
- signalwire_agents/core/logging_config.py +162 -18
- signalwire_agents/core/mixins/__init__.py +28 -0
- signalwire_agents/core/mixins/ai_config_mixin.py +442 -0
- signalwire_agents/core/mixins/auth_mixin.py +280 -0
- signalwire_agents/core/mixins/prompt_mixin.py +358 -0
- signalwire_agents/core/mixins/serverless_mixin.py +460 -0
- signalwire_agents/core/mixins/skill_mixin.py +55 -0
- signalwire_agents/core/mixins/state_mixin.py +153 -0
- signalwire_agents/core/mixins/tool_mixin.py +230 -0
- signalwire_agents/core/mixins/web_mixin.py +1142 -0
- signalwire_agents/core/security_config.py +333 -0
- signalwire_agents/core/skill_base.py +84 -1
- signalwire_agents/core/skill_manager.py +62 -20
- signalwire_agents/core/swaig_function.py +18 -5
- signalwire_agents/core/swml_builder.py +207 -11
- signalwire_agents/core/swml_handler.py +27 -21
- signalwire_agents/core/swml_renderer.py +123 -312
- signalwire_agents/core/swml_service.py +171 -203
- signalwire_agents/mcp_gateway/__init__.py +29 -0
- signalwire_agents/mcp_gateway/gateway_service.py +564 -0
- signalwire_agents/mcp_gateway/mcp_manager.py +513 -0
- signalwire_agents/mcp_gateway/session_manager.py +218 -0
- signalwire_agents/prefabs/concierge.py +0 -3
- signalwire_agents/prefabs/faq_bot.py +0 -3
- signalwire_agents/prefabs/info_gatherer.py +0 -3
- signalwire_agents/prefabs/receptionist.py +0 -3
- signalwire_agents/prefabs/survey.py +0 -3
- signalwire_agents/schema.json +9218 -5489
- signalwire_agents/search/__init__.py +7 -1
- signalwire_agents/search/document_processor.py +490 -31
- signalwire_agents/search/index_builder.py +307 -37
- signalwire_agents/search/migration.py +418 -0
- signalwire_agents/search/models.py +30 -0
- signalwire_agents/search/pgvector_backend.py +748 -0
- signalwire_agents/search/query_processor.py +162 -31
- signalwire_agents/search/search_engine.py +916 -35
- signalwire_agents/search/search_service.py +376 -53
- signalwire_agents/skills/README.md +452 -0
- signalwire_agents/skills/__init__.py +14 -2
- signalwire_agents/skills/api_ninjas_trivia/README.md +215 -0
- signalwire_agents/skills/api_ninjas_trivia/__init__.py +12 -0
- signalwire_agents/skills/api_ninjas_trivia/skill.py +237 -0
- signalwire_agents/skills/datasphere/README.md +210 -0
- signalwire_agents/skills/datasphere/skill.py +84 -3
- signalwire_agents/skills/datasphere_serverless/README.md +258 -0
- signalwire_agents/skills/datasphere_serverless/__init__.py +9 -0
- signalwire_agents/skills/datasphere_serverless/skill.py +82 -1
- signalwire_agents/skills/datetime/README.md +132 -0
- signalwire_agents/skills/datetime/__init__.py +9 -0
- signalwire_agents/skills/datetime/skill.py +20 -7
- signalwire_agents/skills/joke/README.md +149 -0
- signalwire_agents/skills/joke/__init__.py +9 -0
- signalwire_agents/skills/joke/skill.py +21 -0
- signalwire_agents/skills/math/README.md +161 -0
- signalwire_agents/skills/math/__init__.py +9 -0
- signalwire_agents/skills/math/skill.py +18 -4
- signalwire_agents/skills/mcp_gateway/README.md +230 -0
- signalwire_agents/skills/mcp_gateway/__init__.py +10 -0
- signalwire_agents/skills/mcp_gateway/skill.py +421 -0
- signalwire_agents/skills/native_vector_search/README.md +210 -0
- signalwire_agents/skills/native_vector_search/__init__.py +9 -0
- signalwire_agents/skills/native_vector_search/skill.py +569 -101
- signalwire_agents/skills/play_background_file/README.md +218 -0
- signalwire_agents/skills/play_background_file/__init__.py +12 -0
- signalwire_agents/skills/play_background_file/skill.py +242 -0
- signalwire_agents/skills/registry.py +395 -40
- signalwire_agents/skills/spider/README.md +236 -0
- signalwire_agents/skills/spider/__init__.py +13 -0
- signalwire_agents/skills/spider/skill.py +598 -0
- signalwire_agents/skills/swml_transfer/README.md +395 -0
- signalwire_agents/skills/swml_transfer/__init__.py +10 -0
- signalwire_agents/skills/swml_transfer/skill.py +359 -0
- signalwire_agents/skills/weather_api/README.md +178 -0
- signalwire_agents/skills/weather_api/__init__.py +12 -0
- signalwire_agents/skills/weather_api/skill.py +191 -0
- signalwire_agents/skills/web_search/README.md +163 -0
- signalwire_agents/skills/web_search/__init__.py +9 -0
- signalwire_agents/skills/web_search/skill.py +586 -112
- signalwire_agents/skills/wikipedia_search/README.md +228 -0
- signalwire_agents/{core/state → skills/wikipedia_search}/__init__.py +5 -4
- signalwire_agents/skills/{wikipedia → wikipedia_search}/skill.py +33 -3
- signalwire_agents/web/__init__.py +17 -0
- signalwire_agents/web/web_service.py +559 -0
- signalwire_agents-1.0.17.dev4.data/data/share/man/man1/sw-agent-init.1 +400 -0
- signalwire_agents-1.0.17.dev4.data/data/share/man/man1/sw-search.1 +483 -0
- signalwire_agents-1.0.17.dev4.data/data/share/man/man1/swaig-test.1 +308 -0
- {signalwire_agents-0.1.13.dist-info → signalwire_agents-1.0.17.dev4.dist-info}/METADATA +347 -215
- signalwire_agents-1.0.17.dev4.dist-info/RECORD +147 -0
- signalwire_agents-1.0.17.dev4.dist-info/entry_points.txt +6 -0
- signalwire_agents/core/state/file_state_manager.py +0 -219
- signalwire_agents/core/state/state_manager.py +0 -101
- signalwire_agents/skills/wikipedia/__init__.py +0 -9
- signalwire_agents-0.1.13.data/data/schema.json +0 -5611
- signalwire_agents-0.1.13.dist-info/RECORD +0 -67
- signalwire_agents-0.1.13.dist-info/entry_points.txt +0 -3
- {signalwire_agents-0.1.13.dist-info → signalwire_agents-1.0.17.dev4.dist-info}/WHEEL +0 -0
- {signalwire_agents-0.1.13.dist-info → signalwire_agents-1.0.17.dev4.dist-info}/licenses/LICENSE +0 -0
- {signalwire_agents-0.1.13.dist-info → signalwire_agents-1.0.17.dev4.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Copyright (c) 2025 SignalWire
|
|
3
|
+
|
|
4
|
+
This file is part of the SignalWire AI Agents SDK.
|
|
5
|
+
|
|
6
|
+
Licensed under the MIT License.
|
|
7
|
+
See LICENSE file in the project root for full license information.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from typing import List, Dict, Any, Optional
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class AIConfigMixin:
|
|
14
|
+
"""
|
|
15
|
+
Mixin class containing all AI configuration methods for AgentBase
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def add_hint(self, hint: str) -> 'AgentBase':
|
|
19
|
+
"""
|
|
20
|
+
Add a simple string hint to help the AI agent understand certain words better
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
hint: The hint string to add
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
Self for method chaining
|
|
27
|
+
"""
|
|
28
|
+
if isinstance(hint, str) and hint:
|
|
29
|
+
self._hints.append(hint)
|
|
30
|
+
return self
|
|
31
|
+
|
|
32
|
+
def add_hints(self, hints: List[str]) -> 'AgentBase':
|
|
33
|
+
"""
|
|
34
|
+
Add multiple string hints
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
hints: List of hint strings
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
Self for method chaining
|
|
41
|
+
"""
|
|
42
|
+
if hints and isinstance(hints, list):
|
|
43
|
+
for hint in hints:
|
|
44
|
+
if isinstance(hint, str) and hint:
|
|
45
|
+
self._hints.append(hint)
|
|
46
|
+
return self
|
|
47
|
+
|
|
48
|
+
def add_pattern_hint(self,
|
|
49
|
+
hint: str,
|
|
50
|
+
pattern: str,
|
|
51
|
+
replace: str,
|
|
52
|
+
ignore_case: bool = False) -> 'AgentBase':
|
|
53
|
+
"""
|
|
54
|
+
Add a complex hint with pattern matching
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
hint: The hint to match
|
|
58
|
+
pattern: Regular expression pattern
|
|
59
|
+
replace: Text to replace the hint with
|
|
60
|
+
ignore_case: Whether to ignore case when matching
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
Self for method chaining
|
|
64
|
+
"""
|
|
65
|
+
if hint and pattern and replace:
|
|
66
|
+
self._hints.append({
|
|
67
|
+
"hint": hint,
|
|
68
|
+
"pattern": pattern,
|
|
69
|
+
"replace": replace,
|
|
70
|
+
"ignore_case": ignore_case
|
|
71
|
+
})
|
|
72
|
+
return self
|
|
73
|
+
|
|
74
|
+
def add_language(self,
|
|
75
|
+
name: str,
|
|
76
|
+
code: str,
|
|
77
|
+
voice: str,
|
|
78
|
+
speech_fillers: Optional[List[str]] = None,
|
|
79
|
+
function_fillers: Optional[List[str]] = None,
|
|
80
|
+
engine: Optional[str] = None,
|
|
81
|
+
model: Optional[str] = None) -> 'AgentBase':
|
|
82
|
+
"""
|
|
83
|
+
Add a language configuration to support multilingual conversations
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
name: Name of the language (e.g., "English", "French")
|
|
87
|
+
code: Language code (e.g., "en-US", "fr-FR")
|
|
88
|
+
voice: TTS voice to use. Can be a simple name (e.g., "en-US-Neural2-F")
|
|
89
|
+
or a combined format "engine.voice:model" (e.g., "elevenlabs.josh:eleven_turbo_v2_5")
|
|
90
|
+
speech_fillers: Optional list of filler phrases for natural speech
|
|
91
|
+
function_fillers: Optional list of filler phrases during function calls
|
|
92
|
+
engine: Optional explicit engine name (e.g., "elevenlabs", "rime")
|
|
93
|
+
model: Optional explicit model name (e.g., "eleven_turbo_v2_5", "arcana")
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
Self for method chaining
|
|
97
|
+
|
|
98
|
+
Examples:
|
|
99
|
+
# Simple voice name
|
|
100
|
+
agent.add_language("English", "en-US", "en-US-Neural2-F")
|
|
101
|
+
|
|
102
|
+
# Explicit parameters
|
|
103
|
+
agent.add_language("English", "en-US", "josh", engine="elevenlabs", model="eleven_turbo_v2_5")
|
|
104
|
+
|
|
105
|
+
# Combined format
|
|
106
|
+
agent.add_language("English", "en-US", "elevenlabs.josh:eleven_turbo_v2_5")
|
|
107
|
+
"""
|
|
108
|
+
language = {
|
|
109
|
+
"name": name,
|
|
110
|
+
"code": code
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
# Handle voice formatting (either explicit params or combined string)
|
|
114
|
+
if engine or model:
|
|
115
|
+
# Use explicit parameters if provided
|
|
116
|
+
language["voice"] = voice
|
|
117
|
+
if engine:
|
|
118
|
+
language["engine"] = engine
|
|
119
|
+
if model:
|
|
120
|
+
language["model"] = model
|
|
121
|
+
elif "." in voice and ":" in voice:
|
|
122
|
+
# Parse combined string format: "engine.voice:model"
|
|
123
|
+
try:
|
|
124
|
+
engine_voice, model_part = voice.split(":", 1)
|
|
125
|
+
engine_part, voice_part = engine_voice.split(".", 1)
|
|
126
|
+
|
|
127
|
+
language["voice"] = voice_part
|
|
128
|
+
language["engine"] = engine_part
|
|
129
|
+
language["model"] = model_part
|
|
130
|
+
except ValueError:
|
|
131
|
+
# If parsing fails, use the voice string as-is
|
|
132
|
+
language["voice"] = voice
|
|
133
|
+
else:
|
|
134
|
+
# Simple voice string
|
|
135
|
+
language["voice"] = voice
|
|
136
|
+
|
|
137
|
+
# Add fillers if provided
|
|
138
|
+
if speech_fillers and function_fillers:
|
|
139
|
+
language["speech_fillers"] = speech_fillers
|
|
140
|
+
language["function_fillers"] = function_fillers
|
|
141
|
+
elif speech_fillers or function_fillers:
|
|
142
|
+
# If only one type of fillers is provided, use the deprecated "fillers" field
|
|
143
|
+
fillers = speech_fillers or function_fillers
|
|
144
|
+
language["fillers"] = fillers
|
|
145
|
+
|
|
146
|
+
self._languages.append(language)
|
|
147
|
+
return self
|
|
148
|
+
|
|
149
|
+
def set_languages(self, languages: List[Dict[str, Any]]) -> 'AgentBase':
|
|
150
|
+
"""
|
|
151
|
+
Set all language configurations at once
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
languages: List of language configuration dictionaries
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
Self for method chaining
|
|
158
|
+
"""
|
|
159
|
+
if languages and isinstance(languages, list):
|
|
160
|
+
self._languages = languages
|
|
161
|
+
return self
|
|
162
|
+
|
|
163
|
+
def add_pronunciation(self,
|
|
164
|
+
replace: str,
|
|
165
|
+
with_text: str,
|
|
166
|
+
ignore_case: bool = False) -> 'AgentBase':
|
|
167
|
+
"""
|
|
168
|
+
Add a pronunciation rule to help the AI speak certain words correctly
|
|
169
|
+
|
|
170
|
+
Args:
|
|
171
|
+
replace: The expression to replace
|
|
172
|
+
with_text: The phonetic spelling to use instead
|
|
173
|
+
ignore_case: Whether to ignore case when matching
|
|
174
|
+
|
|
175
|
+
Returns:
|
|
176
|
+
Self for method chaining
|
|
177
|
+
"""
|
|
178
|
+
if replace and with_text:
|
|
179
|
+
rule = {
|
|
180
|
+
"replace": replace,
|
|
181
|
+
"with": with_text
|
|
182
|
+
}
|
|
183
|
+
if ignore_case:
|
|
184
|
+
rule["ignore_case"] = True
|
|
185
|
+
|
|
186
|
+
self._pronounce.append(rule)
|
|
187
|
+
return self
|
|
188
|
+
|
|
189
|
+
def set_pronunciations(self, pronunciations: List[Dict[str, Any]]) -> 'AgentBase':
|
|
190
|
+
"""
|
|
191
|
+
Set all pronunciation rules at once
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
pronunciations: List of pronunciation rule dictionaries
|
|
195
|
+
|
|
196
|
+
Returns:
|
|
197
|
+
Self for method chaining
|
|
198
|
+
"""
|
|
199
|
+
if pronunciations and isinstance(pronunciations, list):
|
|
200
|
+
self._pronounce = pronunciations
|
|
201
|
+
return self
|
|
202
|
+
|
|
203
|
+
def set_param(self, key: str, value: Any) -> 'AgentBase':
|
|
204
|
+
"""
|
|
205
|
+
Set a single AI parameter
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
key: Parameter name
|
|
209
|
+
value: Parameter value
|
|
210
|
+
|
|
211
|
+
Returns:
|
|
212
|
+
Self for method chaining
|
|
213
|
+
"""
|
|
214
|
+
if key:
|
|
215
|
+
self._params[key] = value
|
|
216
|
+
return self
|
|
217
|
+
|
|
218
|
+
def set_params(self, params: Dict[str, Any]) -> 'AgentBase':
|
|
219
|
+
"""
|
|
220
|
+
Set multiple AI parameters at once
|
|
221
|
+
|
|
222
|
+
Args:
|
|
223
|
+
params: Dictionary of parameter name/value pairs
|
|
224
|
+
|
|
225
|
+
Returns:
|
|
226
|
+
Self for method chaining
|
|
227
|
+
"""
|
|
228
|
+
if params and isinstance(params, dict):
|
|
229
|
+
self._params.update(params)
|
|
230
|
+
return self
|
|
231
|
+
|
|
232
|
+
def set_global_data(self, data: Dict[str, Any]) -> 'AgentBase':
|
|
233
|
+
"""
|
|
234
|
+
Set the global data available to the AI throughout the conversation
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
data: Dictionary of global data
|
|
238
|
+
|
|
239
|
+
Returns:
|
|
240
|
+
Self for method chaining
|
|
241
|
+
"""
|
|
242
|
+
if data and isinstance(data, dict):
|
|
243
|
+
self._global_data = data
|
|
244
|
+
return self
|
|
245
|
+
|
|
246
|
+
def update_global_data(self, data: Dict[str, Any]) -> 'AgentBase':
|
|
247
|
+
"""
|
|
248
|
+
Update the global data with new values
|
|
249
|
+
|
|
250
|
+
Args:
|
|
251
|
+
data: Dictionary of global data to update
|
|
252
|
+
|
|
253
|
+
Returns:
|
|
254
|
+
Self for method chaining
|
|
255
|
+
"""
|
|
256
|
+
if data and isinstance(data, dict):
|
|
257
|
+
self._global_data.update(data)
|
|
258
|
+
return self
|
|
259
|
+
|
|
260
|
+
def set_native_functions(self, function_names: List[str]) -> 'AgentBase':
|
|
261
|
+
"""
|
|
262
|
+
Set the list of native functions to enable
|
|
263
|
+
|
|
264
|
+
Args:
|
|
265
|
+
function_names: List of native function names
|
|
266
|
+
|
|
267
|
+
Returns:
|
|
268
|
+
Self for method chaining
|
|
269
|
+
"""
|
|
270
|
+
if function_names and isinstance(function_names, list):
|
|
271
|
+
self.native_functions = [name for name in function_names if isinstance(name, str)]
|
|
272
|
+
return self
|
|
273
|
+
|
|
274
|
+
def set_internal_fillers(self, internal_fillers: Dict[str, Dict[str, List[str]]]) -> 'AgentBase':
|
|
275
|
+
"""
|
|
276
|
+
Set internal fillers for native SWAIG functions
|
|
277
|
+
|
|
278
|
+
Internal fillers provide custom phrases the AI says while executing
|
|
279
|
+
internal/native functions like check_time, wait_for_user, next_step, etc.
|
|
280
|
+
|
|
281
|
+
Args:
|
|
282
|
+
internal_fillers: Dictionary mapping function names to language-specific filler phrases
|
|
283
|
+
Format: {"function_name": {"language_code": ["phrase1", "phrase2"]}}
|
|
284
|
+
Example: {"next_step": {"en-US": ["Moving to the next step...", "Great, let's continue..."]}}
|
|
285
|
+
|
|
286
|
+
Returns:
|
|
287
|
+
Self for method chaining
|
|
288
|
+
|
|
289
|
+
Example:
|
|
290
|
+
agent.set_internal_fillers({
|
|
291
|
+
"next_step": {
|
|
292
|
+
"en-US": ["Moving to the next step...", "Great, let's continue..."],
|
|
293
|
+
"es": ["Pasando al siguiente paso...", "Excelente, continuemos..."]
|
|
294
|
+
},
|
|
295
|
+
"check_time": {
|
|
296
|
+
"en-US": ["Let me check the time...", "Getting the current time..."]
|
|
297
|
+
}
|
|
298
|
+
})
|
|
299
|
+
"""
|
|
300
|
+
if internal_fillers and isinstance(internal_fillers, dict):
|
|
301
|
+
if not hasattr(self, '_internal_fillers'):
|
|
302
|
+
self._internal_fillers = {}
|
|
303
|
+
self._internal_fillers.update(internal_fillers)
|
|
304
|
+
return self
|
|
305
|
+
|
|
306
|
+
def add_internal_filler(self, function_name: str, language_code: str, fillers: List[str]) -> 'AgentBase':
|
|
307
|
+
"""
|
|
308
|
+
Add internal fillers for a specific function and language
|
|
309
|
+
|
|
310
|
+
Args:
|
|
311
|
+
function_name: Name of the internal function (e.g., 'next_step', 'check_time')
|
|
312
|
+
language_code: Language code (e.g., 'en-US', 'es', 'fr')
|
|
313
|
+
fillers: List of filler phrases for this function and language
|
|
314
|
+
|
|
315
|
+
Returns:
|
|
316
|
+
Self for method chaining
|
|
317
|
+
|
|
318
|
+
Example:
|
|
319
|
+
agent.add_internal_filler("next_step", "en-US", ["Moving to the next step...", "Great, let's continue..."])
|
|
320
|
+
"""
|
|
321
|
+
if function_name and language_code and fillers and isinstance(fillers, list):
|
|
322
|
+
if not hasattr(self, '_internal_fillers'):
|
|
323
|
+
self._internal_fillers = {}
|
|
324
|
+
|
|
325
|
+
if function_name not in self._internal_fillers:
|
|
326
|
+
self._internal_fillers[function_name] = {}
|
|
327
|
+
|
|
328
|
+
self._internal_fillers[function_name][language_code] = fillers
|
|
329
|
+
return self
|
|
330
|
+
|
|
331
|
+
def add_function_include(self, url: str, functions: List[str], meta_data: Optional[Dict[str, Any]] = None) -> 'AgentBase':
|
|
332
|
+
"""
|
|
333
|
+
Add a remote function include to the SWAIG configuration
|
|
334
|
+
|
|
335
|
+
Args:
|
|
336
|
+
url: URL to fetch remote functions from
|
|
337
|
+
functions: List of function names to include
|
|
338
|
+
meta_data: Optional metadata to include with the function include
|
|
339
|
+
|
|
340
|
+
Returns:
|
|
341
|
+
Self for method chaining
|
|
342
|
+
"""
|
|
343
|
+
if url and functions and isinstance(functions, list):
|
|
344
|
+
include = {
|
|
345
|
+
"url": url,
|
|
346
|
+
"functions": functions
|
|
347
|
+
}
|
|
348
|
+
if meta_data and isinstance(meta_data, dict):
|
|
349
|
+
include["meta_data"] = meta_data
|
|
350
|
+
|
|
351
|
+
self._function_includes.append(include)
|
|
352
|
+
return self
|
|
353
|
+
|
|
354
|
+
def set_function_includes(self, includes: List[Dict[str, Any]]) -> 'AgentBase':
|
|
355
|
+
"""
|
|
356
|
+
Set the complete list of function includes
|
|
357
|
+
|
|
358
|
+
Args:
|
|
359
|
+
includes: List of include objects, each with url and functions properties
|
|
360
|
+
|
|
361
|
+
Returns:
|
|
362
|
+
Self for method chaining
|
|
363
|
+
"""
|
|
364
|
+
if includes and isinstance(includes, list):
|
|
365
|
+
# Validate each include has required properties
|
|
366
|
+
valid_includes = []
|
|
367
|
+
for include in includes:
|
|
368
|
+
if isinstance(include, dict) and "url" in include and "functions" in include:
|
|
369
|
+
if isinstance(include["functions"], list):
|
|
370
|
+
valid_includes.append(include)
|
|
371
|
+
|
|
372
|
+
self._function_includes = valid_includes
|
|
373
|
+
return self
|
|
374
|
+
|
|
375
|
+
def set_prompt_llm_params(self, **params) -> 'AgentBase':
|
|
376
|
+
"""
|
|
377
|
+
Set LLM parameters for the main prompt.
|
|
378
|
+
|
|
379
|
+
Accepts any parameters which will be passed through to the SignalWire server.
|
|
380
|
+
The server will validate and apply parameters based on the target model's capabilities.
|
|
381
|
+
|
|
382
|
+
Common parameters include:
|
|
383
|
+
model: The AI model to use (gpt-4o-mini, gpt-4.1-mini, gpt-4.1-nano, nova-micro, nova-lite, qwen3-235b-A22b-instruct)
|
|
384
|
+
temperature: Randomness setting. Lower values make output more deterministic.
|
|
385
|
+
top_p: Alternative to temperature. Controls nucleus sampling.
|
|
386
|
+
barge_confidence: ASR confidence to interrupt. Higher values make it harder to interrupt.
|
|
387
|
+
presence_penalty: Topic diversity. Positive values encourage new topics.
|
|
388
|
+
frequency_penalty: Repetition control. Positive values reduce repetition.
|
|
389
|
+
|
|
390
|
+
Note: Parameters are model-specific and will be validated by the server.
|
|
391
|
+
Invalid parameters for the selected model will be handled/ignored by the server.
|
|
392
|
+
|
|
393
|
+
Returns:
|
|
394
|
+
Self for method chaining
|
|
395
|
+
|
|
396
|
+
Example:
|
|
397
|
+
agent.set_prompt_llm_params(
|
|
398
|
+
model="nova-micro", # Using Amazon's nova-micro model
|
|
399
|
+
temperature=0.7,
|
|
400
|
+
top_p=0.9,
|
|
401
|
+
barge_confidence=0.6
|
|
402
|
+
)
|
|
403
|
+
"""
|
|
404
|
+
# Accept any parameters without validation
|
|
405
|
+
if params:
|
|
406
|
+
self._prompt_llm_params.update(params)
|
|
407
|
+
|
|
408
|
+
return self
|
|
409
|
+
|
|
410
|
+
def set_post_prompt_llm_params(self, **params) -> 'AgentBase':
|
|
411
|
+
"""
|
|
412
|
+
Set LLM parameters for the post-prompt.
|
|
413
|
+
|
|
414
|
+
Accepts any parameters which will be passed through to the SignalWire server.
|
|
415
|
+
The server will validate and apply parameters based on the target model's capabilities.
|
|
416
|
+
|
|
417
|
+
Common parameters include:
|
|
418
|
+
model: The AI model to use (gpt-4o-mini, gpt-4.1-mini, gpt-4.1-nano, nova-micro, nova-lite, qwen3-235b-A22b-instruct)
|
|
419
|
+
temperature: Randomness setting. Lower values make output more deterministic.
|
|
420
|
+
top_p: Alternative to temperature. Controls nucleus sampling.
|
|
421
|
+
presence_penalty: Topic diversity. Positive values encourage new topics.
|
|
422
|
+
frequency_penalty: Repetition control. Positive values reduce repetition.
|
|
423
|
+
|
|
424
|
+
Note: Parameters are model-specific and will be validated by the server.
|
|
425
|
+
Invalid parameters for the selected model will be handled/ignored by the server.
|
|
426
|
+
barge_confidence is not applicable to post-prompt.
|
|
427
|
+
|
|
428
|
+
Returns:
|
|
429
|
+
Self for method chaining
|
|
430
|
+
|
|
431
|
+
Example:
|
|
432
|
+
agent.set_post_prompt_llm_params(
|
|
433
|
+
model="gpt-4o-mini",
|
|
434
|
+
temperature=0.5, # More deterministic for post-prompt
|
|
435
|
+
top_p=0.9
|
|
436
|
+
)
|
|
437
|
+
"""
|
|
438
|
+
# Accept any parameters without validation
|
|
439
|
+
if params:
|
|
440
|
+
self._post_prompt_llm_params.update(params)
|
|
441
|
+
|
|
442
|
+
return self
|