signalwire-agents 0.1.49__py3-none-any.whl → 0.1.51__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 +1 -1
- signalwire_agents/core/mixins/ai_config_mixin.py +2 -2
- signalwire_agents/core/skill_base.py +20 -0
- signalwire_agents/schema.json +13 -9
- signalwire_agents/skills/datasphere/skill.py +2 -3
- signalwire_agents/skills/datetime/skill.py +4 -6
- signalwire_agents/skills/math/skill.py +2 -3
- signalwire_agents/skills/mcp_gateway/skill.py +2 -2
- signalwire_agents/skills/native_vector_search/skill.py +35 -13
- signalwire_agents/skills/spider/skill.py +6 -9
- signalwire_agents/skills/web_search/skill.py +50 -30
- signalwire_agents/skills/wikipedia_search/skill.py +2 -3
- {signalwire_agents-0.1.49.dist-info → signalwire_agents-0.1.51.dist-info}/METADATA +1 -1
- {signalwire_agents-0.1.49.dist-info → signalwire_agents-0.1.51.dist-info}/RECORD +18 -18
- {signalwire_agents-0.1.49.dist-info → signalwire_agents-0.1.51.dist-info}/WHEEL +0 -0
- {signalwire_agents-0.1.49.dist-info → signalwire_agents-0.1.51.dist-info}/entry_points.txt +0 -0
- {signalwire_agents-0.1.49.dist-info → signalwire_agents-0.1.51.dist-info}/licenses/LICENSE +0 -0
- {signalwire_agents-0.1.49.dist-info → signalwire_agents-0.1.51.dist-info}/top_level.txt +0 -0
signalwire_agents/__init__.py
CHANGED
@@ -18,7 +18,7 @@ A package for building AI agents using SignalWire's AI and SWML capabilities.
|
|
18
18
|
from .core.logging_config import configure_logging
|
19
19
|
configure_logging()
|
20
20
|
|
21
|
-
__version__ = "0.1.
|
21
|
+
__version__ = "0.1.51"
|
22
22
|
|
23
23
|
# Import core classes for easier access
|
24
24
|
from .core.agent_base import AgentBase
|
@@ -380,7 +380,7 @@ class AIConfigMixin:
|
|
380
380
|
The server will validate and apply parameters based on the target model's capabilities.
|
381
381
|
|
382
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)
|
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
384
|
temperature: Randomness setting. Lower values make output more deterministic.
|
385
385
|
top_p: Alternative to temperature. Controls nucleus sampling.
|
386
386
|
barge_confidence: ASR confidence to interrupt. Higher values make it harder to interrupt.
|
@@ -415,7 +415,7 @@ class AIConfigMixin:
|
|
415
415
|
The server will validate and apply parameters based on the target model's capabilities.
|
416
416
|
|
417
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)
|
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
419
|
temperature: Randomness setting. Lower values make output more deterministic.
|
420
420
|
top_p: Alternative to temperature. Controls nucleus sampling.
|
421
421
|
presence_penalty: Topic diversity. Positive values encourage new topics.
|
@@ -53,6 +53,26 @@ class SkillBase(ABC):
|
|
53
53
|
"""Register SWAIG tools with the agent"""
|
54
54
|
pass
|
55
55
|
|
56
|
+
def define_tool(self, **kwargs) -> None:
|
57
|
+
"""
|
58
|
+
Wrapper method that automatically includes swaig_fields when defining tools.
|
59
|
+
|
60
|
+
This method delegates to self.agent.define_tool() but automatically merges
|
61
|
+
any swaig_fields configured for this skill. Skills should use this method
|
62
|
+
instead of calling self.agent.define_tool() directly.
|
63
|
+
|
64
|
+
Args:
|
65
|
+
**kwargs: All arguments supported by agent.define_tool()
|
66
|
+
(name, description, parameters, handler, etc.)
|
67
|
+
"""
|
68
|
+
# Merge swaig_fields with any explicitly passed fields
|
69
|
+
# Explicit fields take precedence over swaig_fields
|
70
|
+
merged_kwargs = dict(self.swaig_fields)
|
71
|
+
merged_kwargs.update(kwargs)
|
72
|
+
|
73
|
+
# Call the agent's define_tool with merged arguments
|
74
|
+
return self.agent.define_tool(**merged_kwargs)
|
75
|
+
|
56
76
|
|
57
77
|
|
58
78
|
def get_hints(self) -> List[str]:
|
signalwire_agents/schema.json
CHANGED
@@ -1933,9 +1933,13 @@
|
|
1933
1933
|
{
|
1934
1934
|
"type": "string",
|
1935
1935
|
"const": "nova-lite"
|
1936
|
+
},
|
1937
|
+
{
|
1938
|
+
"type": "string",
|
1939
|
+
"const": "qwen3-235b-A22b-instruct"
|
1936
1940
|
}
|
1937
1941
|
],
|
1938
|
-
"description": "The model to use for the AI. Allowed values are `gpt-4o-mini`, `gpt-4.1-mini`, `gpt-4.1-nano`, `nova-micro`, and `
|
1942
|
+
"description": "The model to use for the AI. Allowed values are `gpt-4o-mini`, `gpt-4.1-mini`, `gpt-4.1-nano`, `nova-micro`, `nova-lite`, and `qwen3-235b-A22b-instruct`."
|
1939
1943
|
},
|
1940
1944
|
"ai_volume": {
|
1941
1945
|
"anyOf": [
|
@@ -4017,13 +4021,13 @@
|
|
4017
4021
|
"anyOf": [
|
4018
4022
|
{
|
4019
4023
|
"type": "string",
|
4020
|
-
"enum": ["gpt-4o-mini", "gpt-4.1-mini", "gpt-4.1-nano", "nova-micro", "nova-lite"]
|
4024
|
+
"enum": ["gpt-4o-mini", "gpt-4.1-mini", "gpt-4.1-nano", "nova-micro", "nova-lite", "qwen3-235b-A22b-instruct"]
|
4021
4025
|
},
|
4022
4026
|
{
|
4023
4027
|
"$ref": "#/$defs/SWMLVar"
|
4024
4028
|
}
|
4025
4029
|
],
|
4026
|
-
"description": "The model to use for the post-prompt. Allowed values are `gpt-4o-mini`, `gpt-4.1-mini`, `gpt-4.1-nano`, `nova-micro`, and `
|
4030
|
+
"description": "The model to use for the post-prompt. Allowed values are `gpt-4o-mini`, `gpt-4.1-mini`, `gpt-4.1-nano`, `nova-micro`, `nova-lite`, and `qwen3-235b-A22b-instruct`."
|
4027
4031
|
},
|
4028
4032
|
"text": {
|
4029
4033
|
"type": "string",
|
@@ -4108,13 +4112,13 @@
|
|
4108
4112
|
"anyOf": [
|
4109
4113
|
{
|
4110
4114
|
"type": "string",
|
4111
|
-
"enum": ["gpt-4o-mini", "gpt-4.1-mini", "gpt-4.1-nano", "nova-micro", "nova-lite"]
|
4115
|
+
"enum": ["gpt-4o-mini", "gpt-4.1-mini", "gpt-4.1-nano", "nova-micro", "nova-lite", "qwen3-235b-A22b-instruct"]
|
4112
4116
|
},
|
4113
4117
|
{
|
4114
4118
|
"$ref": "#/$defs/SWMLVar"
|
4115
4119
|
}
|
4116
4120
|
],
|
4117
|
-
"description": "The model to use for the post-prompt. Allowed values are `gpt-4o-mini`, `gpt-4.1-mini`, `gpt-4.1-nano`, `nova-micro`, and `
|
4121
|
+
"description": "The model to use for the post-prompt. Allowed values are `gpt-4o-mini`, `gpt-4.1-mini`, `gpt-4.1-nano`, `nova-micro`, `nova-lite`, and `qwen3-235b-A22b-instruct`."
|
4118
4122
|
},
|
4119
4123
|
"pom": {
|
4120
4124
|
"type": "array",
|
@@ -4202,13 +4206,13 @@
|
|
4202
4206
|
"anyOf": [
|
4203
4207
|
{
|
4204
4208
|
"type": "string",
|
4205
|
-
"enum": ["gpt-4o-mini", "gpt-4.1-mini", "gpt-4.1-nano", "nova-micro", "nova-lite"]
|
4209
|
+
"enum": ["gpt-4o-mini", "gpt-4.1-mini", "gpt-4.1-nano", "nova-micro", "nova-lite", "qwen3-235b-A22b-instruct"]
|
4206
4210
|
},
|
4207
4211
|
{
|
4208
4212
|
"$ref": "#/$defs/SWMLVar"
|
4209
4213
|
}
|
4210
4214
|
],
|
4211
|
-
"description": "The model to use for the prompt. Allowed values are `gpt-4o-mini`, `gpt-4.1-mini`, `gpt-4.1-nano`, `nova-micro`, and `
|
4215
|
+
"description": "The model to use for the prompt. Allowed values are `gpt-4o-mini`, `gpt-4.1-mini`, `gpt-4.1-nano`, `nova-micro`, `nova-lite`, and `qwen3-235b-A22b-instruct`."
|
4212
4216
|
},
|
4213
4217
|
"text": {
|
4214
4218
|
"type": "string",
|
@@ -4297,13 +4301,13 @@
|
|
4297
4301
|
"anyOf": [
|
4298
4302
|
{
|
4299
4303
|
"type": "string",
|
4300
|
-
"enum": ["gpt-4o-mini", "gpt-4.1-mini", "gpt-4.1-nano", "nova-micro", "nova-lite"]
|
4304
|
+
"enum": ["gpt-4o-mini", "gpt-4.1-mini", "gpt-4.1-nano", "nova-micro", "nova-lite", "qwen3-235b-A22b-instruct"]
|
4301
4305
|
},
|
4302
4306
|
{
|
4303
4307
|
"$ref": "#/$defs/SWMLVar"
|
4304
4308
|
}
|
4305
4309
|
],
|
4306
|
-
"description": "The model to use for the prompt. Allowed values are `gpt-4o-mini`, `gpt-4.1-mini`, `gpt-4.1-nano`, `nova-micro`, and `
|
4310
|
+
"description": "The model to use for the prompt. Allowed values are `gpt-4o-mini`, `gpt-4.1-mini`, `gpt-4.1-nano`, `nova-micro`, `nova-lite`, and `qwen3-235b-A22b-instruct`."
|
4307
4311
|
},
|
4308
4312
|
"pom": {
|
4309
4313
|
"type": "array",
|
@@ -159,7 +159,7 @@ class DataSphereSkill(SkillBase):
|
|
159
159
|
|
160
160
|
def register_tools(self) -> None:
|
161
161
|
"""Register knowledge search tool with the agent"""
|
162
|
-
self.
|
162
|
+
self.define_tool(
|
163
163
|
name=self.tool_name,
|
164
164
|
description="Search the knowledge base for information on any topic and return relevant results",
|
165
165
|
parameters={
|
@@ -168,8 +168,7 @@ class DataSphereSkill(SkillBase):
|
|
168
168
|
"description": "The search query - what information you're looking for in the knowledge base"
|
169
169
|
}
|
170
170
|
},
|
171
|
-
handler=self._search_knowledge_handler
|
172
|
-
**self.swaig_fields
|
171
|
+
handler=self._search_knowledge_handler
|
173
172
|
)
|
174
173
|
|
175
174
|
def _search_knowledge_handler(self, args, raw_data):
|
@@ -30,7 +30,7 @@ class DateTimeSkill(SkillBase):
|
|
30
30
|
def register_tools(self) -> None:
|
31
31
|
"""Register datetime tools with the agent"""
|
32
32
|
|
33
|
-
self.
|
33
|
+
self.define_tool(
|
34
34
|
name="get_current_time",
|
35
35
|
description="Get the current time, optionally in a specific timezone",
|
36
36
|
parameters={
|
@@ -39,11 +39,10 @@ class DateTimeSkill(SkillBase):
|
|
39
39
|
"description": "Timezone name (e.g., 'America/New_York', 'Europe/London'). Defaults to UTC."
|
40
40
|
}
|
41
41
|
},
|
42
|
-
handler=self._get_time_handler
|
43
|
-
**self.swaig_fields
|
42
|
+
handler=self._get_time_handler
|
44
43
|
)
|
45
44
|
|
46
|
-
self.
|
45
|
+
self.define_tool(
|
47
46
|
name="get_current_date",
|
48
47
|
description="Get the current date",
|
49
48
|
parameters={
|
@@ -52,8 +51,7 @@ class DateTimeSkill(SkillBase):
|
|
52
51
|
"description": "Timezone name for the date. Defaults to UTC."
|
53
52
|
}
|
54
53
|
},
|
55
|
-
handler=self._get_date_handler
|
56
|
-
**self.swaig_fields
|
54
|
+
handler=self._get_date_handler
|
57
55
|
)
|
58
56
|
|
59
57
|
def _get_time_handler(self, args, raw_data):
|
@@ -29,7 +29,7 @@ class MathSkill(SkillBase):
|
|
29
29
|
def register_tools(self) -> None:
|
30
30
|
"""Register math tools with the agent"""
|
31
31
|
|
32
|
-
self.
|
32
|
+
self.define_tool(
|
33
33
|
name="calculate",
|
34
34
|
description="Perform a mathematical calculation with basic operations (+, -, *, /, %, **)",
|
35
35
|
parameters={
|
@@ -38,8 +38,7 @@ class MathSkill(SkillBase):
|
|
38
38
|
"description": "Mathematical expression to evaluate (e.g., '2 + 3 * 4', '(10 + 5) / 3')"
|
39
39
|
}
|
40
40
|
},
|
41
|
-
handler=self._calculate_handler
|
42
|
-
**self.swaig_fields
|
41
|
+
handler=self._calculate_handler
|
43
42
|
)
|
44
43
|
|
45
44
|
def _calculate_handler(self, args, raw_data):
|
@@ -215,7 +215,7 @@ class MCPGatewaySkill(SkillBase):
|
|
215
215
|
self.logger.error(f"Failed to get tools for service '{service_name}': {e}")
|
216
216
|
|
217
217
|
# Register the hangup hook for session cleanup
|
218
|
-
self.
|
218
|
+
self.define_tool(
|
219
219
|
name="_mcp_gateway_hangup",
|
220
220
|
description="Internal cleanup function for MCP sessions",
|
221
221
|
parameters={},
|
@@ -260,7 +260,7 @@ class MCPGatewaySkill(SkillBase):
|
|
260
260
|
return self._call_mcp_tool(service_name, tool_name, args, raw_data)
|
261
261
|
|
262
262
|
# Register the SWAIG function
|
263
|
-
self.
|
263
|
+
self.define_tool(
|
264
264
|
name=swaig_name,
|
265
265
|
description=f"[{service_name}] {tool_def.get('description', tool_name)}",
|
266
266
|
parameters=swaig_params,
|
@@ -136,6 +136,13 @@ class NativeVectorSearchSkill(SkillBase):
|
|
136
136
|
"default": "",
|
137
137
|
"required": False
|
138
138
|
},
|
139
|
+
"max_content_length": {
|
140
|
+
"type": "integer",
|
141
|
+
"description": "Maximum total response size in characters (distributed across all results)",
|
142
|
+
"default": 32768,
|
143
|
+
"required": False,
|
144
|
+
"minimum": 1000
|
145
|
+
},
|
139
146
|
"response_format_callback": {
|
140
147
|
"type": "callable",
|
141
148
|
"description": "Optional callback function to format/transform the response. Called with (response, agent, query, results, args). Must return a string.",
|
@@ -251,6 +258,7 @@ class NativeVectorSearchSkill(SkillBase):
|
|
251
258
|
)
|
252
259
|
self.response_prefix = self.params.get('response_prefix', '')
|
253
260
|
self.response_postfix = self.params.get('response_postfix', '')
|
261
|
+
self.max_content_length = self.params.get('max_content_length', 32768)
|
254
262
|
self.response_format_callback = self.params.get('response_format_callback')
|
255
263
|
self.keyword_weight = self.params.get('keyword_weight')
|
256
264
|
self.model_name = self.params.get('model_name', 'mini')
|
@@ -274,8 +282,8 @@ class NativeVectorSearchSkill(SkillBase):
|
|
274
282
|
if parsed.path:
|
275
283
|
self.remote_base_url += parsed.path
|
276
284
|
|
277
|
-
# SWAIG fields
|
278
|
-
|
285
|
+
# SWAIG fields are already extracted by SkillBase.__init__()
|
286
|
+
# No need to re-fetch from params - use self.swaig_fields inherited from parent
|
279
287
|
|
280
288
|
# **EARLY REMOTE CHECK - Option 1**
|
281
289
|
# If remote URL is configured, skip all heavy local imports and just validate remote connectivity
|
@@ -460,7 +468,7 @@ class NativeVectorSearchSkill(SkillBase):
|
|
460
468
|
'Search the local knowledge base for information'
|
461
469
|
)
|
462
470
|
|
463
|
-
self.
|
471
|
+
self.define_tool(
|
464
472
|
name=self.tool_name,
|
465
473
|
description=description,
|
466
474
|
parameters={
|
@@ -474,8 +482,7 @@ class NativeVectorSearchSkill(SkillBase):
|
|
474
482
|
"default": self.count
|
475
483
|
}
|
476
484
|
},
|
477
|
-
handler=self._search_handler
|
478
|
-
**self.swaig_fields
|
485
|
+
handler=self._search_handler
|
479
486
|
)
|
480
487
|
|
481
488
|
# Add our tool to the Knowledge Search section
|
@@ -601,21 +608,36 @@ class NativeVectorSearchSkill(SkillBase):
|
|
601
608
|
|
602
609
|
return SwaigFunctionResult(no_results_msg)
|
603
610
|
|
604
|
-
# Format results
|
611
|
+
# Format results with dynamic per-result truncation
|
605
612
|
response_parts = []
|
606
|
-
|
613
|
+
|
607
614
|
# Add response prefix if configured
|
608
615
|
if self.response_prefix:
|
609
616
|
response_parts.append(self.response_prefix)
|
610
|
-
|
617
|
+
|
611
618
|
response_parts.append(f"Found {len(results)} relevant results for '{query}':\n")
|
612
|
-
|
619
|
+
|
620
|
+
# Calculate per-result content budget
|
621
|
+
# Estimate overhead per result: metadata (~200 chars) + formatting (~100 chars)
|
622
|
+
estimated_overhead_per_result = 300
|
623
|
+
# Account for prefix/postfix/header in total overhead
|
624
|
+
prefix_postfix_overhead = len(self.response_prefix) + len(self.response_postfix) + 100
|
625
|
+
total_overhead = (len(results) * estimated_overhead_per_result) + prefix_postfix_overhead
|
626
|
+
available_for_content = self.max_content_length - total_overhead
|
627
|
+
|
628
|
+
# Ensure minimum of 500 chars per result
|
629
|
+
per_result_limit = max(500, available_for_content // len(results)) if len(results) > 0 else 1000
|
630
|
+
|
613
631
|
for i, result in enumerate(results, 1):
|
614
632
|
filename = result['metadata']['filename']
|
615
633
|
section = result['metadata'].get('section', '')
|
616
634
|
score = result['score']
|
617
635
|
content = result['content']
|
618
|
-
|
636
|
+
|
637
|
+
# Truncate content to per-result limit
|
638
|
+
if len(content) > per_result_limit:
|
639
|
+
content = content[:per_result_limit] + "..."
|
640
|
+
|
619
641
|
# Get tags from either top level or metadata
|
620
642
|
tags = result.get('tags', [])
|
621
643
|
if not tags and 'metadata' in result['metadata'] and 'tags' in result['metadata']['metadata']:
|
@@ -624,16 +646,16 @@ class NativeVectorSearchSkill(SkillBase):
|
|
624
646
|
elif not tags and 'tags' in result['metadata']:
|
625
647
|
# Check in metadata directly
|
626
648
|
tags = result['metadata']['tags']
|
627
|
-
|
649
|
+
|
628
650
|
result_text = f"**Result {i}** (from {filename}"
|
629
651
|
if section:
|
630
652
|
result_text += f", section: {section}"
|
631
653
|
if tags:
|
632
654
|
result_text += f", tags: {', '.join(tags)}"
|
633
655
|
result_text += f", relevance: {score:.2f})\n{content}\n"
|
634
|
-
|
656
|
+
|
635
657
|
response_parts.append(result_text)
|
636
|
-
|
658
|
+
|
637
659
|
# Add response postfix if configured
|
638
660
|
if self.response_postfix:
|
639
661
|
response_parts.append(self.response_postfix)
|
@@ -223,7 +223,7 @@ class SpiderSkill(SkillBase):
|
|
223
223
|
tool_prefix = f"{tool_prefix}_"
|
224
224
|
|
225
225
|
# Register scrape_url tool
|
226
|
-
self.
|
226
|
+
self.define_tool(
|
227
227
|
name=f"{tool_prefix}scrape_url",
|
228
228
|
description="Extract text content from a single web page",
|
229
229
|
parameters={
|
@@ -233,12 +233,11 @@ class SpiderSkill(SkillBase):
|
|
233
233
|
}
|
234
234
|
},
|
235
235
|
required=["url"],
|
236
|
-
handler=self._scrape_url_handler
|
237
|
-
**self.swaig_fields
|
236
|
+
handler=self._scrape_url_handler
|
238
237
|
)
|
239
238
|
|
240
239
|
# Register crawl_site tool
|
241
|
-
self.
|
240
|
+
self.define_tool(
|
242
241
|
name=f"{tool_prefix}crawl_site",
|
243
242
|
description="Crawl multiple pages starting from a URL",
|
244
243
|
parameters={
|
@@ -248,12 +247,11 @@ class SpiderSkill(SkillBase):
|
|
248
247
|
}
|
249
248
|
},
|
250
249
|
required=["start_url"],
|
251
|
-
handler=self._crawl_site_handler
|
252
|
-
**self.swaig_fields
|
250
|
+
handler=self._crawl_site_handler
|
253
251
|
)
|
254
252
|
|
255
253
|
# Register extract_structured_data tool
|
256
|
-
self.
|
254
|
+
self.define_tool(
|
257
255
|
name=f"{tool_prefix}extract_structured_data",
|
258
256
|
description="Extract specific data from a web page using selectors",
|
259
257
|
parameters={
|
@@ -263,8 +261,7 @@ class SpiderSkill(SkillBase):
|
|
263
261
|
}
|
264
262
|
},
|
265
263
|
required=["url"],
|
266
|
-
handler=self._extract_structured_handler
|
267
|
-
**self.swaig_fields
|
264
|
+
handler=self._extract_structured_handler
|
268
265
|
)
|
269
266
|
|
270
267
|
def _fetch_url(self, url: str) -> Optional[requests.Response]:
|
@@ -21,7 +21,7 @@ from signalwire_agents.core.function_result import SwaigFunctionResult
|
|
21
21
|
class GoogleSearchScraper:
|
22
22
|
"""Google Search and Web Scraping functionality"""
|
23
23
|
|
24
|
-
def __init__(self, api_key: str, search_engine_id: str, max_content_length: int =
|
24
|
+
def __init__(self, api_key: str, search_engine_id: str, max_content_length: int = 32768):
|
25
25
|
self.api_key = api_key
|
26
26
|
self.search_engine_id = search_engine_id
|
27
27
|
self.max_content_length = max_content_length
|
@@ -62,63 +62,84 @@ class GoogleSearchScraper:
|
|
62
62
|
except Exception as e:
|
63
63
|
return []
|
64
64
|
|
65
|
-
def extract_text_from_url(self, url: str, timeout: int = 10) -> str:
|
66
|
-
"""Scrape a URL and extract readable text content
|
65
|
+
def extract_text_from_url(self, url: str, content_limit: int = None, timeout: int = 10) -> str:
|
66
|
+
"""Scrape a URL and extract readable text content
|
67
|
+
|
68
|
+
Args:
|
69
|
+
url: URL to scrape
|
70
|
+
content_limit: Maximum characters to return (uses self.max_content_length if not provided)
|
71
|
+
timeout: Request timeout in seconds
|
72
|
+
"""
|
67
73
|
try:
|
68
74
|
response = self.session.get(url, timeout=timeout)
|
69
75
|
response.raise_for_status()
|
70
|
-
|
76
|
+
|
71
77
|
soup = BeautifulSoup(response.content, 'html.parser')
|
72
|
-
|
78
|
+
|
73
79
|
# Remove unwanted elements
|
74
80
|
for script in soup(["script", "style", "nav", "footer", "header", "aside"]):
|
75
81
|
script.decompose()
|
76
|
-
|
82
|
+
|
77
83
|
text = soup.get_text()
|
78
|
-
|
84
|
+
|
79
85
|
# Clean up the text
|
80
86
|
lines = (line.strip() for line in text.splitlines())
|
81
87
|
chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
|
82
88
|
text = ' '.join(chunk for chunk in chunks if chunk)
|
83
|
-
|
89
|
+
|
84
90
|
# Limit text length
|
85
|
-
if
|
86
|
-
|
87
|
-
|
91
|
+
limit = content_limit if content_limit is not None else self.max_content_length
|
92
|
+
if len(text) > limit:
|
93
|
+
text = text[:limit]
|
94
|
+
|
88
95
|
return text
|
89
|
-
|
96
|
+
|
90
97
|
except Exception as e:
|
91
98
|
return ""
|
92
99
|
|
93
100
|
def search_and_scrape(self, query: str, num_results: int = 3, delay: float = 0.5) -> str:
|
94
|
-
"""Main function: search Google and scrape the resulting pages
|
101
|
+
"""Main function: search Google and scrape the resulting pages
|
102
|
+
|
103
|
+
Dynamically calculates per-result content limit based on total max_content_length
|
104
|
+
and number of results to ensure total response stays within bounds.
|
105
|
+
"""
|
95
106
|
search_results = self.search_google(query, num_results)
|
96
|
-
|
107
|
+
|
97
108
|
if not search_results:
|
98
109
|
return f"No search results found for query: {query}"
|
99
|
-
|
110
|
+
|
111
|
+
# Calculate per-result content budget
|
112
|
+
# Reserve ~300 chars per result for overhead (titles, URLs, snippets, formatting)
|
113
|
+
estimated_overhead_per_result = 300
|
114
|
+
total_overhead = num_results * estimated_overhead_per_result
|
115
|
+
available_for_content = self.max_content_length - total_overhead
|
116
|
+
|
117
|
+
# Ensure we have at least 1000 chars per result
|
118
|
+
per_result_limit = max(1000, available_for_content // num_results)
|
119
|
+
|
100
120
|
all_text = []
|
101
|
-
|
121
|
+
|
102
122
|
for i, result in enumerate(search_results, 1):
|
103
123
|
text_content = f"=== RESULT {i} ===\n"
|
104
124
|
text_content += f"Title: {result['title']}\n"
|
105
125
|
text_content += f"URL: {result['url']}\n"
|
106
126
|
text_content += f"Snippet: {result['snippet']}\n"
|
107
127
|
text_content += f"Content:\n"
|
108
|
-
|
109
|
-
|
110
|
-
|
128
|
+
|
129
|
+
# Pass the calculated per-result limit
|
130
|
+
page_text = self.extract_text_from_url(result['url'], content_limit=per_result_limit)
|
131
|
+
|
111
132
|
if page_text:
|
112
133
|
text_content += page_text
|
113
134
|
else:
|
114
135
|
text_content += "Failed to extract content from this page."
|
115
|
-
|
136
|
+
|
116
137
|
text_content += f"\n{'='*50}\n\n"
|
117
138
|
all_text.append(text_content)
|
118
|
-
|
139
|
+
|
119
140
|
if i < len(search_results):
|
120
141
|
time.sleep(delay)
|
121
|
-
|
142
|
+
|
122
143
|
return '\n'.join(all_text)
|
123
144
|
|
124
145
|
|
@@ -163,7 +184,7 @@ class WebSearchSkill(SkillBase):
|
|
163
184
|
# Set default parameters
|
164
185
|
self.default_num_results = self.params.get('num_results', 1)
|
165
186
|
self.default_delay = self.params.get('delay', 0)
|
166
|
-
self.max_content_length = self.params.get('max_content_length',
|
187
|
+
self.max_content_length = self.params.get('max_content_length', 32768)
|
167
188
|
self.no_results_message = self.params.get('no_results_message',
|
168
189
|
"I couldn't find any results for '{query}'. "
|
169
190
|
"This might be due to a very specific query or temporary issues. "
|
@@ -184,7 +205,7 @@ class WebSearchSkill(SkillBase):
|
|
184
205
|
|
185
206
|
def register_tools(self) -> None:
|
186
207
|
"""Register web search tool with the agent"""
|
187
|
-
self.
|
208
|
+
self.define_tool(
|
188
209
|
name=self.tool_name,
|
189
210
|
description="Search the web for information on any topic and return detailed results with content from multiple sources",
|
190
211
|
parameters={
|
@@ -193,8 +214,7 @@ class WebSearchSkill(SkillBase):
|
|
193
214
|
"description": "The search query - what you want to find information about"
|
194
215
|
}
|
195
216
|
},
|
196
|
-
handler=self._web_search_handler
|
197
|
-
**self.swaig_fields
|
217
|
+
handler=self._web_search_handler
|
198
218
|
)
|
199
219
|
|
200
220
|
def _web_search_handler(self, args, raw_data):
|
@@ -308,10 +328,10 @@ class WebSearchSkill(SkillBase):
|
|
308
328
|
},
|
309
329
|
"max_content_length": {
|
310
330
|
"type": "integer",
|
311
|
-
"description": "Maximum
|
312
|
-
"default":
|
331
|
+
"description": "Maximum total response size in characters (distributed across all results)",
|
332
|
+
"default": 32768,
|
313
333
|
"required": False,
|
314
|
-
"min":
|
334
|
+
"min": 1000
|
315
335
|
},
|
316
336
|
"no_results_message": {
|
317
337
|
"type": "string",
|
@@ -321,4 +341,4 @@ class WebSearchSkill(SkillBase):
|
|
321
341
|
}
|
322
342
|
})
|
323
343
|
|
324
|
-
return schema
|
344
|
+
return schema
|
@@ -84,7 +84,7 @@ class WikipediaSearchSkill(SkillBase):
|
|
84
84
|
"""
|
85
85
|
Register the SWAIG tool for Wikipedia search.
|
86
86
|
"""
|
87
|
-
self.
|
87
|
+
self.define_tool(
|
88
88
|
name="search_wiki",
|
89
89
|
description="Search Wikipedia for information about a topic and get article summaries",
|
90
90
|
parameters={
|
@@ -93,8 +93,7 @@ class WikipediaSearchSkill(SkillBase):
|
|
93
93
|
"description": "The search term or topic to look up on Wikipedia"
|
94
94
|
}
|
95
95
|
},
|
96
|
-
handler=self._search_wiki_handler
|
97
|
-
**self.swaig_fields
|
96
|
+
handler=self._search_wiki_handler
|
98
97
|
)
|
99
98
|
|
100
99
|
def _search_wiki_handler(self, args, raw_data):
|
@@ -1,6 +1,6 @@
|
|
1
|
-
signalwire_agents/__init__.py,sha256=
|
1
|
+
signalwire_agents/__init__.py,sha256=UjnzNxxWDqRTwGXX51kBT1yUilX39ZI7cQfkmD_aHCg,5031
|
2
2
|
signalwire_agents/agent_server.py,sha256=x9HyWia8D3r6KMqY-Q4DtNVivfJWLTx8B-KzUI8okuA,26880
|
3
|
-
signalwire_agents/schema.json,sha256=
|
3
|
+
signalwire_agents/schema.json,sha256=D0Ui-VdLKNdMO8aYQBX_2NM3_JPnuhdVzhbLAPAWG1c,240423
|
4
4
|
signalwire_agents/agents/bedrock.py,sha256=J582gooNtxtep4xdVOfyDzRtHp_XrurPMS93xf2Xod0,10836
|
5
5
|
signalwire_agents/cli/__init__.py,sha256=XbxAQFaCIdGXIXJiriVBWoFPOJsC401u21588nO4TG8,388
|
6
6
|
signalwire_agents/cli/build_search.py,sha256=Yh5hNM0ur88UMuKo5ZDoN_bAzBGpj2RG1Ys1_3xlfUc,54144
|
@@ -33,7 +33,7 @@ signalwire_agents/core/function_result.py,sha256=4CcbxwstlSRUQtbCty2evewvNZP35dW
|
|
33
33
|
signalwire_agents/core/logging_config.py,sha256=x4d_RAjBjVpJOFA2vXnPP2dNr13BZHz091J5rGpC77Y,13142
|
34
34
|
signalwire_agents/core/pom_builder.py,sha256=ywuiIfP8BeLBPo_G4X1teZlG6zTCMkW71CZnmyoDTAQ,6636
|
35
35
|
signalwire_agents/core/security_config.py,sha256=iAnAzKEJQiXL6mMpDaYm3Sjkxwm4x2N9HD6DeWSI8yI,12536
|
36
|
-
signalwire_agents/core/skill_base.py,sha256=
|
36
|
+
signalwire_agents/core/skill_base.py,sha256=kCgzvlA9uu3CblLAigYuM-0LL-n0xEEoXV-JmNn-Beo,7795
|
37
37
|
signalwire_agents/core/skill_manager.py,sha256=D4erpz0tmSYLqyfeteNNIY0VRWDtX0rDw3n7Z_f0W5U,10493
|
38
38
|
signalwire_agents/core/swaig_function.py,sha256=KnUQ2g99kDSzOzD1PJ0Iqs8DeeZ6jDIIN54C5MA4TWw,7521
|
39
39
|
signalwire_agents/core/swml_builder.py,sha256=tJBFDAVTENEfjGLp2h9_AKOYt5O9FrSYLI-nZZVwM1E,15604
|
@@ -53,7 +53,7 @@ signalwire_agents/core/agent/tools/__init__.py,sha256=eOcmyeGm6qogT3wsBx7QvdjmTb
|
|
53
53
|
signalwire_agents/core/agent/tools/decorator.py,sha256=pC6j1114GwVBd2U3h23I9gKLtu8AgeiuWV0lUzz682U,2961
|
54
54
|
signalwire_agents/core/agent/tools/registry.py,sha256=HScbKKwpJqFZ_odmeFklSQ0p0EMasEyKSxNwX568OPo,8054
|
55
55
|
signalwire_agents/core/mixins/__init__.py,sha256=NsFpfF7TDP_lNR0Riw4Nbvt4fDbv_A3OoVbBqRrtXQM,652
|
56
|
-
signalwire_agents/core/mixins/ai_config_mixin.py,sha256=
|
56
|
+
signalwire_agents/core/mixins/ai_config_mixin.py,sha256=In7SrVlKoRaGsDIXEDNGsrEqCjotmcQr_XA563VWABQ,16265
|
57
57
|
signalwire_agents/core/mixins/auth_mixin.py,sha256=Y9kR423-76U_pKL7KXzseeXX2a-4WxNWyo3odS7TDQM,9879
|
58
58
|
signalwire_agents/core/mixins/prompt_mixin.py,sha256=bEsuw9J2F_upFYI02KyC7o2eGZjwOKQ352rmJBZirAM,13729
|
59
59
|
signalwire_agents/core/mixins/serverless_mixin.py,sha256=QIIbl_-16XFJi5aqrWpNzORbyCJQmhaplWXnW6U9i68,16137
|
@@ -86,31 +86,31 @@ signalwire_agents/skills/api_ninjas_trivia/__init__.py,sha256=zN305bBQkzlJyUNsPU
|
|
86
86
|
signalwire_agents/skills/api_ninjas_trivia/skill.py,sha256=ajJm0Vd07Oz3h0sHP0rRyckAXAbFRtcP7ws9GiAhfjw,8626
|
87
87
|
signalwire_agents/skills/datasphere/README.md,sha256=7G5t0V04SlnJ39U-3zOoIOfkNFrVEo-s45lCUlYmJGo,7351
|
88
88
|
signalwire_agents/skills/datasphere/__init__.py,sha256=SJJlmeMSeezjINPgkuWN1XzDPN_Z3GzZ_StzO1BtxQs,257
|
89
|
-
signalwire_agents/skills/datasphere/skill.py,sha256=
|
89
|
+
signalwire_agents/skills/datasphere/skill.py,sha256=OcDgmFSvIA3qy6a24E_fIgXrPKGRnLRHtPh9JeJ5YOY,12643
|
90
90
|
signalwire_agents/skills/datasphere_serverless/README.md,sha256=FErV97NEdYD_N1wZxkLqy6DSml5B9mCJmEgCUdGxh6A,9299
|
91
91
|
signalwire_agents/skills/datasphere_serverless/__init__.py,sha256=jpMNDcGiXsVbSCVUrc_AwLARqEtVu4dPYZPJSJ-K3rc,261
|
92
92
|
signalwire_agents/skills/datasphere_serverless/skill.py,sha256=i57VkMo2gU5YE9Z2lIxFfZtYkvkwMpnek49eSSfMFS0,9882
|
93
93
|
signalwire_agents/skills/datetime/README.md,sha256=95SzVz-Pcm9MPqZ4D3sSYKMwdpsDNwwCpWFRK027-Pc,4534
|
94
94
|
signalwire_agents/skills/datetime/__init__.py,sha256=Irajm2sUhmQVFgais-J-q-3d58tNnJ4nbLmnphr90nI,234
|
95
|
-
signalwire_agents/skills/datetime/skill.py,sha256
|
95
|
+
signalwire_agents/skills/datetime/skill.py,sha256=-MnycSmhK2JWwuHAStxz0mHNuMIvvWCW-I9La44WDts,4292
|
96
96
|
signalwire_agents/skills/joke/README.md,sha256=xUa2_0Pk9neli-UJxI4BPt3Fb1_5Xa3m8RuDlrkfBao,3594
|
97
97
|
signalwire_agents/skills/joke/__init__.py,sha256=8Rc5_nj30bdga2n9H9JSI2WzMn40pjApd-y-tk5WIkI,244
|
98
98
|
signalwire_agents/skills/joke/skill.py,sha256=BKPA50iht8I_mVBJ-PIQHjJJz1m0V2w5J69AfVMx23o,4092
|
99
99
|
signalwire_agents/skills/math/README.md,sha256=Nrv7PxkFPSxdnAN6856Fp1CfvsUwdncpRFFDERxmMe0,5335
|
100
100
|
signalwire_agents/skills/math/__init__.py,sha256=F7emZqBpAAkqJZxA3RNTzRSAXE5e2xu8PtFOPHebfKo,230
|
101
|
-
signalwire_agents/skills/math/skill.py,sha256
|
101
|
+
signalwire_agents/skills/math/skill.py,sha256=pfwlljnN_UoT9rzkggzPrgGWuoZ_wnovrph-aLG4ULY,3761
|
102
102
|
signalwire_agents/skills/mcp_gateway/README.md,sha256=t-71TTWlEvjgWLTcT3v4kMw9zlrKXTAC_sCjb1haNew,5826
|
103
103
|
signalwire_agents/skills/mcp_gateway/__init__.py,sha256=zLgOa7s0sIQphTNJjvasIAW7llxAApez7moC_e1tzP0,236
|
104
|
-
signalwire_agents/skills/mcp_gateway/skill.py,sha256=
|
104
|
+
signalwire_agents/skills/mcp_gateway/skill.py,sha256=bOdfBFsboRWSVoRA5X9vcmkH9OJIQxUllhMzhqHV1XI,17155
|
105
105
|
signalwire_agents/skills/native_vector_search/README.md,sha256=eFVRoDwZlZwbBXUKyKrvfC6AL4T8MXj0B-IgIdBZF70,5526
|
106
106
|
signalwire_agents/skills/native_vector_search/__init__.py,sha256=RofpN3Sd-vyWeUCTYH2dRVrl7h6YuyG5OK772UQ-KFk,220
|
107
|
-
signalwire_agents/skills/native_vector_search/skill.py,sha256=
|
107
|
+
signalwire_agents/skills/native_vector_search/skill.py,sha256=SwJ3fkFbAdW-zkbhTkzdj_0VJGXm-j2bRxE89CLu4B8,37403
|
108
108
|
signalwire_agents/skills/play_background_file/README.md,sha256=omJ_jY5Co6Mk-gJt_hoSl40wemmTbzae3DBll6HL0B4,7026
|
109
109
|
signalwire_agents/skills/play_background_file/__init__.py,sha256=iETc6e-0Cai3RUTQWhg9BieWi3NF3_DWWBKdYXcd4ok,273
|
110
110
|
signalwire_agents/skills/play_background_file/skill.py,sha256=HgPc2FIvXKJHZ7gO2QEzQe6-uUBPrw_6sRJJpU83GTY,8822
|
111
111
|
signalwire_agents/skills/spider/README.md,sha256=yBa09JzgLikG3STbDNbRCKUM3l3XU5-D923I2g8CTVc,6909
|
112
112
|
signalwire_agents/skills/spider/__init__.py,sha256=bZcCGLX5Cz18qY8rOvAAync6BRtketxaU19l6YcA_iI,285
|
113
|
-
signalwire_agents/skills/spider/skill.py,sha256=
|
113
|
+
signalwire_agents/skills/spider/skill.py,sha256=_gdw_fJO8wZhs1yx-JGdY8Tf-605NjOG-KH44-Js9Cc,23020
|
114
114
|
signalwire_agents/skills/swml_transfer/README.md,sha256=2Y6CH5Bm9kI5IYCLczIQIYlaYUq6VX_S4Irct2CQMmQ,14681
|
115
115
|
signalwire_agents/skills/swml_transfer/__init__.py,sha256=YyfxRpbgT4ZpEjGolwffKqjUzX4VqDNLdqfSoA0D0IY,238
|
116
116
|
signalwire_agents/skills/swml_transfer/skill.py,sha256=_qzJRd9P5VN8flTDe9N-9cvsLU0sN7XuY5yjk-DNlv8,15363
|
@@ -119,10 +119,10 @@ signalwire_agents/skills/weather_api/__init__.py,sha256=WCS--GFBX8straIZPuGAmTDZ
|
|
119
119
|
signalwire_agents/skills/weather_api/skill.py,sha256=LNJItYzgRSZYNYcH7Z37BOjjPy3aaM0OjMRnAxiUhOI,7204
|
120
120
|
signalwire_agents/skills/web_search/README.md,sha256=Y95cxEScMzhmslUJF8u_Nh15FbEBuus4P-E8_kk2an0,5438
|
121
121
|
signalwire_agents/skills/web_search/__init__.py,sha256=kv4CzmF1lldRZcL_HivieslP7gtTFvxcfprKG4n6b-Q,236
|
122
|
-
signalwire_agents/skills/web_search/skill.py,sha256=
|
122
|
+
signalwire_agents/skills/web_search/skill.py,sha256=h1zrAUFhC5Ul2BaKQY4Fn05Pob8AG-9eaSwE3ko-g3Y,13459
|
123
123
|
signalwire_agents/skills/wikipedia_search/README.md,sha256=KFIQ8XhqrTG8NRs72dIbjJacy2DlYEXLtxgy23gyRi4,7585
|
124
124
|
signalwire_agents/skills/wikipedia_search/__init__.py,sha256=yJ6iYTSyJC96mwwUsI_FneFhDBcLYD4xEerBKlWLTb8,375
|
125
|
-
signalwire_agents/skills/wikipedia_search/skill.py,sha256=
|
125
|
+
signalwire_agents/skills/wikipedia_search/skill.py,sha256=peNxT3GHMJY5OFQ-weneO83NpSstGjcmrTN_ENzUsEo,7910
|
126
126
|
signalwire_agents/utils/__init__.py,sha256=1KVsHzwgfktSXHe3vqSRGImjtIE58szwD2FHHoFBtvY,601
|
127
127
|
signalwire_agents/utils/pom_utils.py,sha256=4Mr7baQ_xR_hfJ72YxQRAT_GFa663YjFX_PumJ35Xds,191
|
128
128
|
signalwire_agents/utils/schema_utils.py,sha256=i4okv_O9bUApwT_jJf4Yoij3bLCrGrW3DC-vzSy2RuY,16392
|
@@ -130,9 +130,9 @@ signalwire_agents/utils/token_generators.py,sha256=4Mr7baQ_xR_hfJ72YxQRAT_GFa663
|
|
130
130
|
signalwire_agents/utils/validators.py,sha256=4Mr7baQ_xR_hfJ72YxQRAT_GFa663YjFX_PumJ35Xds,191
|
131
131
|
signalwire_agents/web/__init__.py,sha256=XE_pSTY9Aalzr7J7wqFth1Zr3cccQHPPcF5HWNrOpz8,383
|
132
132
|
signalwire_agents/web/web_service.py,sha256=a2PSHJgX1tlZr0Iz1A1UouZjXEePJAZL632evvLVM38,21071
|
133
|
-
signalwire_agents-0.1.
|
134
|
-
signalwire_agents-0.1.
|
135
|
-
signalwire_agents-0.1.
|
136
|
-
signalwire_agents-0.1.
|
137
|
-
signalwire_agents-0.1.
|
138
|
-
signalwire_agents-0.1.
|
133
|
+
signalwire_agents-0.1.51.dist-info/licenses/LICENSE,sha256=NYvAsB-rTcSvG9cqHt9EUHAWLiA9YzM4Qfz-mPdvDR0,1067
|
134
|
+
signalwire_agents-0.1.51.dist-info/METADATA,sha256=ymb59Haj4uPAm9HMELHJvK7E_pCzndyeZcEiSZ1bg-w,41596
|
135
|
+
signalwire_agents-0.1.51.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
136
|
+
signalwire_agents-0.1.51.dist-info/entry_points.txt,sha256=ZDT65zfTO_YyDzi_hwQbCxIhrUfu_t8RpNXMMXlUPWI,144
|
137
|
+
signalwire_agents-0.1.51.dist-info/top_level.txt,sha256=kDGS6ZYv84K9P5Kyg9_S8P_pbUXoHkso0On_DB5bbWc,18
|
138
|
+
signalwire_agents-0.1.51.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|