signalwire-agents 0.1.6__py3-none-any.whl → 1.0.7__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.
Files changed (140) hide show
  1. signalwire_agents/__init__.py +130 -4
  2. signalwire_agents/agent_server.py +438 -32
  3. signalwire_agents/agents/bedrock.py +296 -0
  4. signalwire_agents/cli/__init__.py +18 -0
  5. signalwire_agents/cli/build_search.py +1367 -0
  6. signalwire_agents/cli/config.py +80 -0
  7. signalwire_agents/cli/core/__init__.py +10 -0
  8. signalwire_agents/cli/core/agent_loader.py +470 -0
  9. signalwire_agents/cli/core/argparse_helpers.py +179 -0
  10. signalwire_agents/cli/core/dynamic_config.py +71 -0
  11. signalwire_agents/cli/core/service_loader.py +303 -0
  12. signalwire_agents/cli/execution/__init__.py +10 -0
  13. signalwire_agents/cli/execution/datamap_exec.py +446 -0
  14. signalwire_agents/cli/execution/webhook_exec.py +134 -0
  15. signalwire_agents/cli/init_project.py +1225 -0
  16. signalwire_agents/cli/output/__init__.py +10 -0
  17. signalwire_agents/cli/output/output_formatter.py +255 -0
  18. signalwire_agents/cli/output/swml_dump.py +186 -0
  19. signalwire_agents/cli/simulation/__init__.py +10 -0
  20. signalwire_agents/cli/simulation/data_generation.py +374 -0
  21. signalwire_agents/cli/simulation/data_overrides.py +200 -0
  22. signalwire_agents/cli/simulation/mock_env.py +282 -0
  23. signalwire_agents/cli/swaig_test_wrapper.py +52 -0
  24. signalwire_agents/cli/test_swaig.py +809 -0
  25. signalwire_agents/cli/types.py +81 -0
  26. signalwire_agents/core/__init__.py +2 -2
  27. signalwire_agents/core/agent/__init__.py +12 -0
  28. signalwire_agents/core/agent/config/__init__.py +12 -0
  29. signalwire_agents/core/agent/deployment/__init__.py +9 -0
  30. signalwire_agents/core/agent/deployment/handlers/__init__.py +9 -0
  31. signalwire_agents/core/agent/prompt/__init__.py +14 -0
  32. signalwire_agents/core/agent/prompt/manager.py +306 -0
  33. signalwire_agents/core/agent/routing/__init__.py +9 -0
  34. signalwire_agents/core/agent/security/__init__.py +9 -0
  35. signalwire_agents/core/agent/swml/__init__.py +9 -0
  36. signalwire_agents/core/agent/tools/__init__.py +15 -0
  37. signalwire_agents/core/agent/tools/decorator.py +97 -0
  38. signalwire_agents/core/agent/tools/registry.py +210 -0
  39. signalwire_agents/core/agent_base.py +959 -2166
  40. signalwire_agents/core/auth_handler.py +233 -0
  41. signalwire_agents/core/config_loader.py +259 -0
  42. signalwire_agents/core/contexts.py +707 -0
  43. signalwire_agents/core/data_map.py +487 -0
  44. signalwire_agents/core/function_result.py +1150 -1
  45. signalwire_agents/core/logging_config.py +376 -0
  46. signalwire_agents/core/mixins/__init__.py +28 -0
  47. signalwire_agents/core/mixins/ai_config_mixin.py +442 -0
  48. signalwire_agents/core/mixins/auth_mixin.py +287 -0
  49. signalwire_agents/core/mixins/prompt_mixin.py +358 -0
  50. signalwire_agents/core/mixins/serverless_mixin.py +368 -0
  51. signalwire_agents/core/mixins/skill_mixin.py +55 -0
  52. signalwire_agents/core/mixins/state_mixin.py +153 -0
  53. signalwire_agents/core/mixins/tool_mixin.py +230 -0
  54. signalwire_agents/core/mixins/web_mixin.py +1134 -0
  55. signalwire_agents/core/security/session_manager.py +174 -86
  56. signalwire_agents/core/security_config.py +333 -0
  57. signalwire_agents/core/skill_base.py +200 -0
  58. signalwire_agents/core/skill_manager.py +244 -0
  59. signalwire_agents/core/swaig_function.py +33 -9
  60. signalwire_agents/core/swml_builder.py +212 -12
  61. signalwire_agents/core/swml_handler.py +43 -13
  62. signalwire_agents/core/swml_renderer.py +123 -297
  63. signalwire_agents/core/swml_service.py +277 -260
  64. signalwire_agents/prefabs/concierge.py +6 -2
  65. signalwire_agents/prefabs/info_gatherer.py +149 -33
  66. signalwire_agents/prefabs/receptionist.py +14 -22
  67. signalwire_agents/prefabs/survey.py +6 -2
  68. signalwire_agents/schema.json +9218 -5489
  69. signalwire_agents/search/__init__.py +137 -0
  70. signalwire_agents/search/document_processor.py +1223 -0
  71. signalwire_agents/search/index_builder.py +804 -0
  72. signalwire_agents/search/migration.py +418 -0
  73. signalwire_agents/search/models.py +30 -0
  74. signalwire_agents/search/pgvector_backend.py +752 -0
  75. signalwire_agents/search/query_processor.py +502 -0
  76. signalwire_agents/search/search_engine.py +1264 -0
  77. signalwire_agents/search/search_service.py +574 -0
  78. signalwire_agents/skills/README.md +452 -0
  79. signalwire_agents/skills/__init__.py +23 -0
  80. signalwire_agents/skills/api_ninjas_trivia/README.md +215 -0
  81. signalwire_agents/skills/api_ninjas_trivia/__init__.py +12 -0
  82. signalwire_agents/skills/api_ninjas_trivia/skill.py +237 -0
  83. signalwire_agents/skills/datasphere/README.md +210 -0
  84. signalwire_agents/skills/datasphere/__init__.py +12 -0
  85. signalwire_agents/skills/datasphere/skill.py +310 -0
  86. signalwire_agents/skills/datasphere_serverless/README.md +258 -0
  87. signalwire_agents/skills/datasphere_serverless/__init__.py +10 -0
  88. signalwire_agents/skills/datasphere_serverless/skill.py +237 -0
  89. signalwire_agents/skills/datetime/README.md +132 -0
  90. signalwire_agents/skills/datetime/__init__.py +10 -0
  91. signalwire_agents/skills/datetime/skill.py +126 -0
  92. signalwire_agents/skills/joke/README.md +149 -0
  93. signalwire_agents/skills/joke/__init__.py +10 -0
  94. signalwire_agents/skills/joke/skill.py +109 -0
  95. signalwire_agents/skills/math/README.md +161 -0
  96. signalwire_agents/skills/math/__init__.py +10 -0
  97. signalwire_agents/skills/math/skill.py +105 -0
  98. signalwire_agents/skills/mcp_gateway/README.md +230 -0
  99. signalwire_agents/skills/mcp_gateway/__init__.py +10 -0
  100. signalwire_agents/skills/mcp_gateway/skill.py +421 -0
  101. signalwire_agents/skills/native_vector_search/README.md +210 -0
  102. signalwire_agents/skills/native_vector_search/__init__.py +10 -0
  103. signalwire_agents/skills/native_vector_search/skill.py +820 -0
  104. signalwire_agents/skills/play_background_file/README.md +218 -0
  105. signalwire_agents/skills/play_background_file/__init__.py +12 -0
  106. signalwire_agents/skills/play_background_file/skill.py +242 -0
  107. signalwire_agents/skills/registry.py +459 -0
  108. signalwire_agents/skills/spider/README.md +236 -0
  109. signalwire_agents/skills/spider/__init__.py +13 -0
  110. signalwire_agents/skills/spider/skill.py +598 -0
  111. signalwire_agents/skills/swml_transfer/README.md +395 -0
  112. signalwire_agents/skills/swml_transfer/__init__.py +10 -0
  113. signalwire_agents/skills/swml_transfer/skill.py +359 -0
  114. signalwire_agents/skills/weather_api/README.md +178 -0
  115. signalwire_agents/skills/weather_api/__init__.py +12 -0
  116. signalwire_agents/skills/weather_api/skill.py +191 -0
  117. signalwire_agents/skills/web_search/README.md +163 -0
  118. signalwire_agents/skills/web_search/__init__.py +10 -0
  119. signalwire_agents/skills/web_search/skill.py +739 -0
  120. signalwire_agents/skills/wikipedia_search/README.md +228 -0
  121. signalwire_agents/{core/state → skills/wikipedia_search}/__init__.py +5 -4
  122. signalwire_agents/skills/wikipedia_search/skill.py +210 -0
  123. signalwire_agents/utils/__init__.py +14 -0
  124. signalwire_agents/utils/schema_utils.py +111 -44
  125. signalwire_agents/web/__init__.py +17 -0
  126. signalwire_agents/web/web_service.py +559 -0
  127. signalwire_agents-1.0.7.data/data/share/man/man1/sw-agent-init.1 +307 -0
  128. signalwire_agents-1.0.7.data/data/share/man/man1/sw-search.1 +483 -0
  129. signalwire_agents-1.0.7.data/data/share/man/man1/swaig-test.1 +308 -0
  130. signalwire_agents-1.0.7.dist-info/METADATA +992 -0
  131. signalwire_agents-1.0.7.dist-info/RECORD +142 -0
  132. {signalwire_agents-0.1.6.dist-info → signalwire_agents-1.0.7.dist-info}/WHEEL +1 -1
  133. signalwire_agents-1.0.7.dist-info/entry_points.txt +4 -0
  134. signalwire_agents/core/state/file_state_manager.py +0 -219
  135. signalwire_agents/core/state/state_manager.py +0 -101
  136. signalwire_agents-0.1.6.data/data/schema.json +0 -5611
  137. signalwire_agents-0.1.6.dist-info/METADATA +0 -199
  138. signalwire_agents-0.1.6.dist-info/RECORD +0 -34
  139. {signalwire_agents-0.1.6.dist-info → signalwire_agents-1.0.7.dist-info}/licenses/LICENSE +0 -0
  140. {signalwire_agents-0.1.6.dist-info → signalwire_agents-1.0.7.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,228 @@
1
+ # Wikipedia Search Skill
2
+
3
+ The Wikipedia Search skill provides agents with the ability to search Wikipedia articles and retrieve factual information. This skill uses the Wikipedia API to search for articles and return their introductory content, making it perfect for answering factual questions about people, places, concepts, and more.
4
+
5
+ ## Features
6
+
7
+ - **Free Wikipedia API**: No API keys or credentials required
8
+ - **Article Summaries**: Returns introductory content from Wikipedia articles
9
+ - **Multiple Results**: Can return multiple article summaries for broader topics
10
+ - **Customizable Messages**: Custom no-results messages with query placeholders
11
+ - **Error Handling**: Graceful handling of network errors and API issues
12
+ - **Speech Recognition**: Includes hints for better voice recognition accuracy
13
+
14
+ ## Requirements
15
+
16
+ - **Python Packages**: `requests` (automatically installed with SignalWire Agents)
17
+ - **API Keys**: None required - uses free Wikipedia API
18
+ - **Environment Variables**: None required
19
+
20
+ ## Parameters
21
+
22
+ | Parameter | Type | Default | Description |
23
+ |-----------|------|---------|-------------|
24
+ | `num_results` | int | 1 | Number of Wikipedia articles to return (minimum: 1) |
25
+ | `no_results_message` | str | Auto-generated | Custom message when no results found. Use `{query}` as placeholder |
26
+ | `swaig_fields` | dict | {} | Additional SWAIG function configuration (fillers, etc.) |
27
+
28
+ ## Tools Created
29
+
30
+ This skill creates one SWAIG tool:
31
+
32
+ ### `search_wiki`
33
+ - **Description**: Search Wikipedia for information about a topic and get article summaries
34
+ - **Parameters**:
35
+ - `query` (string, required): The search term or topic to look up on Wikipedia
36
+
37
+ ## Usage Examples
38
+
39
+ ### Basic Usage
40
+
41
+ ```python
42
+ from signalwire_agents import AgentBase
43
+
44
+ agent = AgentBase("Wikipedia Assistant")
45
+
46
+ # Add Wikipedia search with default settings
47
+ agent.add_skill("wikipedia_search")
48
+ ```
49
+
50
+ ### Custom Configuration
51
+
52
+ ```python
53
+ # Custom number of results and no-results message
54
+ agent.add_skill("wikipedia_search", {
55
+ "num_results": 2, # Return up to 2 articles
56
+ "no_results_message": "Sorry, I couldn't find any Wikipedia articles about '{query}'. Try different keywords or check the spelling."
57
+ })
58
+ ```
59
+
60
+ ### With SWAIG Fields (Fillers)
61
+
62
+ ```python
63
+ # Add custom fillers for better user experience
64
+ agent.add_skill("wikipedia_search", {
65
+ "num_results": 1,
66
+ "swaig_fields": {
67
+ "fillers": {
68
+ "en-US": [
69
+ "Let me check Wikipedia for that...",
70
+ "Searching Wikipedia...",
71
+ "Looking that up on Wikipedia...",
72
+ "Checking the encyclopedia..."
73
+ ]
74
+ }
75
+ }
76
+ })
77
+ ```
78
+
79
+ ### Advanced Configuration
80
+
81
+ ```python
82
+ # Full configuration example
83
+ agent.add_skill("wikipedia_search", {
84
+ "num_results": 3,
85
+ "no_results_message": "I searched Wikipedia but couldn't find information about '{query}'. You might want to try rephrasing your question or searching for related topics.",
86
+ "swaig_fields": {
87
+ "fillers": {
88
+ "en-US": [
89
+ "Searching Wikipedia for factual information...",
90
+ "Let me look that up in the encyclopedia...",
91
+ "Checking Wikipedia's knowledge base..."
92
+ ]
93
+ },
94
+ "meta": {
95
+ "description": "Search Wikipedia for reliable, factual information"
96
+ }
97
+ }
98
+ })
99
+ ```
100
+
101
+ ## Multiple Instance Support
102
+
103
+ **This skill does NOT support multiple instances.** You can only load one instance of the Wikipedia search skill per agent. This is because:
104
+
105
+ - Wikipedia search is a general-purpose tool that doesn't need specialization
106
+ - The tool name `search_wiki` is fixed and meaningful
107
+ - Multiple instances would create confusion without added benefit
108
+
109
+ If you need different Wikipedia search behaviors, use the `num_results` parameter to control the scope of results.
110
+
111
+ ## API Details
112
+
113
+ The skill uses the Wikipedia API with two steps:
114
+
115
+ 1. **Search**: Uses the `action=query&list=search` endpoint to find matching articles
116
+ 2. **Extract**: Uses the `action=query&prop=extracts` endpoint to get article summaries
117
+
118
+ ### Search Process
119
+
120
+ ```
121
+ 1. Search for articles matching the query
122
+ → GET https://en.wikipedia.org/w/api.php?action=query&list=search&format=json&srsearch={query}&srlimit={num_results}
123
+
124
+ 2. For each result, get the article extract
125
+ → GET https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exintro&explaintext&format=json&titles={title}
126
+
127
+ 3. Format and return the results
128
+ ```
129
+
130
+ ## Response Format
131
+
132
+ ### Single Result
133
+ ```
134
+ **Article Title**
135
+
136
+ Article content summary...
137
+ ```
138
+
139
+ ### Multiple Results
140
+ ```
141
+ **First Article Title**
142
+
143
+ First article content summary...
144
+
145
+ ==================================================
146
+
147
+ **Second Article Title**
148
+
149
+ Second article content summary...
150
+ ```
151
+
152
+ ## Error Handling
153
+
154
+ The skill handles various error conditions gracefully:
155
+
156
+ - **No Results**: Returns the custom `no_results_message` with the query
157
+ - **Network Errors**: Returns "Error accessing Wikipedia: {error details}"
158
+ - **API Errors**: Returns "Error searching Wikipedia: {error details}"
159
+ - **Empty Extracts**: Returns "No summary available for this article"
160
+
161
+ ## Speech Recognition Hints
162
+
163
+ The skill provides these hints to improve voice recognition:
164
+
165
+ - "Wikipedia"
166
+ - "wiki"
167
+ - "search Wikipedia"
168
+ - "look up"
169
+ - "tell me about"
170
+ - "what is"
171
+ - "who is"
172
+ - "information about"
173
+ - "facts about"
174
+
175
+ ## Best Practices
176
+
177
+ ### Query Optimization
178
+ - Use specific terms for better results
179
+ - Try both full names and common names (e.g., "Einstein" vs "Albert Einstein")
180
+ - For disambiguation, be more specific (e.g., "Python programming language" vs "Python")
181
+
182
+ ### Result Management
183
+ - Use `num_results: 1` for specific factual queries
184
+ - Use `num_results: 2-3` for broader topics that might have multiple relevant articles
185
+ - Avoid very high numbers as it can overwhelm users
186
+
187
+ ### Error Messages
188
+ - Customize `no_results_message` to match your agent's personality
189
+ - Include suggestions for alternative searches
190
+ - Use the `{query}` placeholder to reference what the user searched for
191
+
192
+ ### Integration Tips
193
+ - Combine with web search for comprehensive information gathering
194
+ - Use for factual verification of claims
195
+ - Great for educational and reference applications
196
+
197
+ ## Example Conversations
198
+
199
+ **User**: "Tell me about quantum physics"
200
+ **Agent**: *Searching Wikipedia...* "Here's what I found about quantum physics: **Quantum mechanics** - Quantum mechanics is a fundamental theory that describes the behavior of nature at and below the scale of atoms..."
201
+
202
+ **User**: "Who was Marie Curie?"
203
+ **Agent**: *Let me check Wikipedia for that...* "**Marie Curie** - Marie Salomea Skłodowska-Curie was a Polish and naturalized-French physicist and chemist who conducted pioneering research on radioactivity..."
204
+
205
+ ## Troubleshooting
206
+
207
+ ### Common Issues
208
+
209
+ 1. **Skill not loading**: Ensure `requests` package is installed
210
+ 2. **No results for valid topics**: Try different search terms or check spelling
211
+ 3. **Network timeouts**: The skill has a 10-second timeout for API calls
212
+
213
+ ### Debug Information
214
+
215
+ The skill logs initialization and search activities:
216
+ ```
217
+ Wikipedia search skill initialized with {num_results} max results
218
+ ```
219
+
220
+ Enable debug logging to see detailed API interactions and error information.
221
+
222
+ ## Related Skills
223
+
224
+ - **web_search**: For current information and broader web content
225
+ - **datasphere**: For searching custom knowledge bases
226
+ - **datetime**: For current date/time context in historical queries
227
+
228
+ The Wikipedia skill is perfect for factual, encyclopedic information, while web search is better for current events and specific products/services.
@@ -8,10 +8,11 @@ See LICENSE file in the project root for full license information.
8
8
  """
9
9
 
10
10
  """
11
- State management for SignalWire AI Agents
11
+ Wikipedia Search Skill
12
+
13
+ This skill provides Wikipedia search capabilities using the Wikipedia API.
12
14
  """
13
15
 
14
- from .state_manager import StateManager
15
- from .file_state_manager import FileStateManager
16
+ from .skill import WikipediaSearchSkill
16
17
 
17
- __all__ = ['StateManager', 'FileStateManager']
18
+ __all__ = ['WikipediaSearchSkill']
@@ -0,0 +1,210 @@
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
+ """
11
+ Wikipedia Search Skill
12
+
13
+ Provides Wikipedia search capabilities using the Wikipedia API.
14
+ """
15
+
16
+ import requests
17
+ from urllib.parse import quote
18
+ from typing import Dict, Any, Optional
19
+ from signalwire_agents.core.skill_base import SkillBase
20
+
21
+
22
+ class WikipediaSearchSkill(SkillBase):
23
+ """
24
+ Skill for searching Wikipedia articles and retrieving content.
25
+
26
+ This skill uses the Wikipedia API to search for articles and retrieve
27
+ their introductory content, similar to getting a summary of a topic.
28
+ """
29
+
30
+ # Skill metadata
31
+ SKILL_NAME = "wikipedia_search"
32
+ SKILL_DESCRIPTION = "Search Wikipedia for information about a topic and get article summaries"
33
+ SKILL_VERSION = "1.0.0"
34
+ REQUIRED_PACKAGES = ["requests"]
35
+ REQUIRED_ENV_VARS = [] # No environment variables required
36
+
37
+ # Does not support multiple instances
38
+ SUPPORTS_MULTIPLE_INSTANCES = False
39
+
40
+ @classmethod
41
+ def get_parameter_schema(cls) -> Dict[str, Dict[str, Any]]:
42
+ """Get parameter schema for Wikipedia search skill"""
43
+ schema = super().get_parameter_schema()
44
+ schema.update({
45
+ "num_results": {
46
+ "type": "integer",
47
+ "description": "Maximum number of Wikipedia articles to return",
48
+ "default": 1,
49
+ "required": False,
50
+ "minimum": 1,
51
+ "maximum": 5
52
+ },
53
+ "no_results_message": {
54
+ "type": "string",
55
+ "description": "Custom message when no Wikipedia articles are found",
56
+ "default": "I couldn't find any Wikipedia articles for '{query}'. Try rephrasing your search or using different keywords.",
57
+ "required": False
58
+ }
59
+ })
60
+ return schema
61
+
62
+ def setup(self) -> bool:
63
+ """
64
+ Setup the Wikipedia search skill.
65
+
66
+ Returns:
67
+ True if setup successful, False otherwise
68
+ """
69
+ # Extract configuration from params
70
+ self.num_results = max(1, self.params.get('num_results', 1)) # Ensure at least 1 result
71
+ self.no_results_message = self.params.get('no_results_message') or (
72
+ "I couldn't find any Wikipedia articles for '{query}'. "
73
+ "Try rephrasing your search or using different keywords."
74
+ )
75
+
76
+ # Validate that requests package is available
77
+ if not self.validate_packages():
78
+ return False
79
+
80
+ self.logger.info(f"Wikipedia search skill initialized with {self.num_results} max results")
81
+ return True
82
+
83
+ def register_tools(self) -> None:
84
+ """
85
+ Register the SWAIG tool for Wikipedia search.
86
+ """
87
+ self.define_tool(
88
+ name="search_wiki",
89
+ description="Search Wikipedia for information about a topic and get article summaries",
90
+ parameters={
91
+ "query": {
92
+ "type": "string",
93
+ "description": "The search term or topic to look up on Wikipedia"
94
+ }
95
+ },
96
+ handler=self._search_wiki_handler
97
+ )
98
+
99
+ def _search_wiki_handler(self, args, raw_data):
100
+ """Handler for search_wiki tool"""
101
+ from signalwire_agents.core.function_result import SwaigFunctionResult
102
+
103
+ query = args.get("query", "").strip()
104
+ if not query:
105
+ return SwaigFunctionResult("Please provide a search query for Wikipedia.")
106
+
107
+ result = self.search_wiki(query)
108
+ return SwaigFunctionResult(result)
109
+
110
+ def search_wiki(self, query: str) -> str:
111
+ """
112
+ Search Wikipedia for articles matching the query.
113
+
114
+ Args:
115
+ query: The search term to look up
116
+
117
+ Returns:
118
+ String containing the Wikipedia article content or error message
119
+ """
120
+ try:
121
+ # Step 1: Search for articles matching the query
122
+ search_url = (
123
+ "https://en.wikipedia.org/w/api.php"
124
+ "?action=query&list=search&format=json"
125
+ f"&srsearch={quote(query)}"
126
+ f"&srlimit={self.num_results}"
127
+ )
128
+
129
+ response = requests.get(search_url, timeout=10)
130
+ response.raise_for_status()
131
+ search_data = response.json()
132
+
133
+ # Check if we got any search results
134
+ search_results = search_data.get('query', {}).get('search', [])
135
+ if not search_results:
136
+ return self.no_results_message.format(query=query)
137
+
138
+ # Step 2: Get article extracts for each result
139
+ articles = []
140
+ for i, result in enumerate(search_results[:self.num_results]):
141
+ title = result['title']
142
+
143
+ # Get the page extract
144
+ extract_url = (
145
+ "https://en.wikipedia.org/w/api.php"
146
+ "?action=query&prop=extracts&exintro&explaintext&format=json"
147
+ f"&titles={quote(title)}"
148
+ )
149
+
150
+ extract_response = requests.get(extract_url, timeout=10)
151
+ extract_response.raise_for_status()
152
+ extract_data = extract_response.json()
153
+
154
+ # Get the first (and only) page from the response
155
+ pages = extract_data.get('query', {}).get('pages', {})
156
+ if pages:
157
+ page = next(iter(pages.values()))
158
+ extract = page.get('extract', '').strip()
159
+
160
+ if extract:
161
+ # Format the article with title and content
162
+ articles.append(f"**{title}**\n\n{extract}")
163
+ else:
164
+ # Handle case where extract is empty
165
+ articles.append(f"**{title}**\n\nNo summary available for this article.")
166
+
167
+ if not articles:
168
+ return self.no_results_message.format(query=query)
169
+
170
+ # Join multiple articles with separators
171
+ if len(articles) == 1:
172
+ return articles[0]
173
+ else:
174
+ return "\n\n" + "="*50 + "\n\n".join(articles)
175
+
176
+ except requests.exceptions.RequestException as e:
177
+ return f"Error accessing Wikipedia: {str(e)}"
178
+ except Exception as e:
179
+ return f"Error searching Wikipedia: {str(e)}"
180
+
181
+ def get_prompt_sections(self) -> list:
182
+ """
183
+ Return additional context for the agent prompt.
184
+
185
+ Returns:
186
+ List of prompt sections to add to the agent
187
+ """
188
+ return [{
189
+ "title": "Wikipedia Search",
190
+ "body": f"You can search Wikipedia for factual information using search_wiki. This will return up to {self.num_results} Wikipedia article summaries.",
191
+ "bullets": [
192
+ "Use search_wiki for factual, encyclopedic information",
193
+ "Great for answering questions about people, places, concepts, and history",
194
+ "Returns reliable, well-sourced information from Wikipedia articles"
195
+ ]
196
+ }]
197
+
198
+ def get_hints(self) -> list:
199
+ """
200
+ Return speech recognition hints for better accuracy.
201
+
202
+ Returns:
203
+ List of words/phrases to help with speech recognition
204
+ """
205
+ # Currently no hints provided, but you could add them like:
206
+ # return [
207
+ # "Wikipedia", "wiki", "search Wikipedia", "look up", "tell me about",
208
+ # "what is", "who is", "information about", "facts about"
209
+ # ]
210
+ return []
@@ -7,3 +7,17 @@ Licensed under the MIT License.
7
7
  See LICENSE file in the project root for full license information.
8
8
  """
9
9
 
10
+ from .schema_utils import SchemaUtils
11
+ from signalwire_agents.core.logging_config import get_execution_mode
12
+
13
+ def is_serverless_mode() -> bool:
14
+ """
15
+ Check if running in any serverless environment.
16
+
17
+ Returns:
18
+ bool: True if in serverless mode, False if in server mode
19
+ """
20
+ return get_execution_mode() != 'server'
21
+
22
+ __all__ = ["SchemaUtils", "get_execution_mode", "is_serverless_mode"]
23
+