signalwire-agents 0.1.23__py3-none-any.whl → 0.1.25__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/agent_server.py +2 -1
- signalwire_agents/cli/config.py +61 -0
- signalwire_agents/cli/core/__init__.py +1 -0
- signalwire_agents/cli/core/agent_loader.py +254 -0
- signalwire_agents/cli/core/argparse_helpers.py +164 -0
- signalwire_agents/cli/core/dynamic_config.py +62 -0
- signalwire_agents/cli/execution/__init__.py +1 -0
- signalwire_agents/cli/execution/datamap_exec.py +437 -0
- signalwire_agents/cli/execution/webhook_exec.py +125 -0
- signalwire_agents/cli/output/__init__.py +1 -0
- signalwire_agents/cli/output/output_formatter.py +132 -0
- signalwire_agents/cli/output/swml_dump.py +177 -0
- signalwire_agents/cli/simulation/__init__.py +1 -0
- signalwire_agents/cli/simulation/data_generation.py +365 -0
- signalwire_agents/cli/simulation/data_overrides.py +187 -0
- signalwire_agents/cli/simulation/mock_env.py +271 -0
- signalwire_agents/cli/test_swaig.py +522 -2539
- signalwire_agents/cli/types.py +72 -0
- signalwire_agents/core/agent/__init__.py +1 -3
- signalwire_agents/core/agent/config/__init__.py +1 -3
- signalwire_agents/core/agent/prompt/manager.py +25 -7
- signalwire_agents/core/agent/tools/decorator.py +2 -0
- signalwire_agents/core/agent/tools/registry.py +8 -0
- signalwire_agents/core/agent_base.py +492 -3053
- signalwire_agents/core/function_result.py +31 -42
- signalwire_agents/core/mixins/__init__.py +28 -0
- signalwire_agents/core/mixins/ai_config_mixin.py +373 -0
- signalwire_agents/core/mixins/auth_mixin.py +287 -0
- signalwire_agents/core/mixins/prompt_mixin.py +345 -0
- signalwire_agents/core/mixins/serverless_mixin.py +368 -0
- signalwire_agents/core/mixins/skill_mixin.py +55 -0
- signalwire_agents/core/mixins/state_mixin.py +219 -0
- signalwire_agents/core/mixins/tool_mixin.py +295 -0
- signalwire_agents/core/mixins/web_mixin.py +1130 -0
- signalwire_agents/core/skill_manager.py +3 -1
- signalwire_agents/core/swaig_function.py +10 -1
- signalwire_agents/core/swml_service.py +140 -58
- signalwire_agents/skills/README.md +452 -0
- signalwire_agents/skills/api_ninjas_trivia/README.md +215 -0
- signalwire_agents/skills/datasphere/README.md +210 -0
- signalwire_agents/skills/datasphere_serverless/README.md +258 -0
- signalwire_agents/skills/datetime/README.md +132 -0
- signalwire_agents/skills/joke/README.md +149 -0
- signalwire_agents/skills/math/README.md +161 -0
- signalwire_agents/skills/native_vector_search/skill.py +33 -13
- signalwire_agents/skills/play_background_file/README.md +218 -0
- signalwire_agents/skills/spider/README.md +236 -0
- signalwire_agents/skills/spider/__init__.py +4 -0
- signalwire_agents/skills/spider/skill.py +479 -0
- signalwire_agents/skills/swml_transfer/README.md +395 -0
- signalwire_agents/skills/swml_transfer/__init__.py +1 -0
- signalwire_agents/skills/swml_transfer/skill.py +257 -0
- signalwire_agents/skills/weather_api/README.md +178 -0
- signalwire_agents/skills/web_search/README.md +163 -0
- signalwire_agents/skills/wikipedia_search/README.md +228 -0
- {signalwire_agents-0.1.23.dist-info → signalwire_agents-0.1.25.dist-info}/METADATA +47 -2
- {signalwire_agents-0.1.23.dist-info → signalwire_agents-0.1.25.dist-info}/RECORD +62 -22
- {signalwire_agents-0.1.23.dist-info → signalwire_agents-0.1.25.dist-info}/entry_points.txt +1 -1
- signalwire_agents/core/agent/config/ephemeral.py +0 -176
- signalwire_agents-0.1.23.data/data/schema.json +0 -5611
- {signalwire_agents-0.1.23.dist-info → signalwire_agents-0.1.25.dist-info}/WHEEL +0 -0
- {signalwire_agents-0.1.23.dist-info → signalwire_agents-0.1.25.dist-info}/licenses/LICENSE +0 -0
- {signalwire_agents-0.1.23.dist-info → signalwire_agents-0.1.25.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,178 @@
|
|
1
|
+
# Weather API Skill
|
2
|
+
|
3
|
+
A configurable skill for getting current weather information from WeatherAPI.com with customizable temperature units and TTS-optimized natural language responses.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
- **Configurable Temperature Units**: Choose between Fahrenheit and Celsius
|
8
|
+
- **TTS-Friendly Responses**: Natural language numbers without abbreviations or symbols
|
9
|
+
- **Real-time Weather Data**: Current conditions via WeatherAPI.com
|
10
|
+
- **DataMap Efficiency**: Serverless webhook execution, no agent processing load
|
11
|
+
- **Error Handling**: Graceful fallback for API failures or invalid locations
|
12
|
+
- **Comprehensive Weather Info**: Temperature, conditions, wind, clouds, feels-like
|
13
|
+
|
14
|
+
## Configuration
|
15
|
+
|
16
|
+
### Basic Structure
|
17
|
+
|
18
|
+
```python
|
19
|
+
agent.add_skill("weather_api", {
|
20
|
+
"tool_name": "get_weather",
|
21
|
+
"api_key": "your_weatherapi_key",
|
22
|
+
"temperature_unit": "fahrenheit" # or "celsius"
|
23
|
+
})
|
24
|
+
```
|
25
|
+
|
26
|
+
### Parameters
|
27
|
+
|
28
|
+
- **tool_name** (string, optional): Custom name for the generated SWAIG function (default: "get_weather")
|
29
|
+
- **api_key** (string, required): Your WeatherAPI.com API key
|
30
|
+
- **temperature_unit** (string, optional): "fahrenheit" or "celsius" (default: "fahrenheit")
|
31
|
+
|
32
|
+
## Usage Examples
|
33
|
+
|
34
|
+
### Fahrenheit Weather (Default)
|
35
|
+
|
36
|
+
```python
|
37
|
+
agent.add_skill("weather_api", {
|
38
|
+
"tool_name": "get_weather",
|
39
|
+
"api_key": "your_weatherapi_key"
|
40
|
+
})
|
41
|
+
```
|
42
|
+
|
43
|
+
**Generated Tool**: `get_weather(location)`
|
44
|
+
**Temperature Format**: "seventy two degrees Fahrenheit"
|
45
|
+
|
46
|
+
### Celsius Weather
|
47
|
+
|
48
|
+
```python
|
49
|
+
agent.add_skill("weather_api", {
|
50
|
+
"tool_name": "get_weather_celsius",
|
51
|
+
"api_key": "your_weatherapi_key",
|
52
|
+
"temperature_unit": "celsius"
|
53
|
+
})
|
54
|
+
```
|
55
|
+
|
56
|
+
**Generated Tool**: `get_weather_celsius(location)`
|
57
|
+
**Temperature Format**: "twenty two degrees Celsius"
|
58
|
+
|
59
|
+
### Custom Tool Name
|
60
|
+
|
61
|
+
```python
|
62
|
+
agent.add_skill("weather_api", {
|
63
|
+
"tool_name": "check_current_weather",
|
64
|
+
"api_key": "your_weatherapi_key",
|
65
|
+
"temperature_unit": "fahrenheit"
|
66
|
+
})
|
67
|
+
```
|
68
|
+
|
69
|
+
**Generated Tool**: `check_current_weather(location)`
|
70
|
+
|
71
|
+
## Generated SWAIG Function
|
72
|
+
|
73
|
+
For the Fahrenheit example above, the skill generates:
|
74
|
+
|
75
|
+
```json
|
76
|
+
{
|
77
|
+
"function": "get_weather",
|
78
|
+
"description": "Get current weather information for any location",
|
79
|
+
"parameters": {
|
80
|
+
"type": "object",
|
81
|
+
"properties": {
|
82
|
+
"location": {
|
83
|
+
"type": "string",
|
84
|
+
"description": "The city, state, country, or location to get weather for"
|
85
|
+
}
|
86
|
+
},
|
87
|
+
"required": ["location"]
|
88
|
+
},
|
89
|
+
"data_map": {
|
90
|
+
"webhook": {
|
91
|
+
"url": "https://api.weatherapi.com/v1/current.json?key=your_api_key&q=%{enc:args.location}&aqi=no",
|
92
|
+
"method": "GET"
|
93
|
+
},
|
94
|
+
"output": {
|
95
|
+
"response": "Tell the user the current weather conditions. Express all temperatures in Fahrenheit using natural language numbers without abbreviations or symbols for clear text-to-speech pronunciation. For example, say 'seventy two degrees Fahrenheit' instead of '72F' or '72°F'. Include the condition, current temperature, wind direction and speed, cloud coverage percentage, and what the temperature feels like. Current conditions: ${current.condition.text}. Temperature: ${current.temp_f} degrees Fahrenheit. Wind: ${current.wind_dir} at ${current.wind_mph} miles per hour. Cloud coverage: ${current.cloud} percent. Feels like: ${current.feelslike_f} degrees Fahrenheit."
|
96
|
+
},
|
97
|
+
"error_keys": ["error"],
|
98
|
+
"fallback_output": {
|
99
|
+
"response": "Sorry, I cannot get weather information right now. Please try again later or check if the location name is correct."
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
```
|
104
|
+
|
105
|
+
## TTS Optimization
|
106
|
+
|
107
|
+
The skill is specifically designed for text-to-speech systems:
|
108
|
+
|
109
|
+
### Natural Language Numbers
|
110
|
+
- ✅ "seventy two degrees Fahrenheit"
|
111
|
+
- ❌ "72F" or "72°F"
|
112
|
+
|
113
|
+
### Full Pronunciation
|
114
|
+
- ✅ "twenty two degrees Celsius"
|
115
|
+
- ❌ "22C" or "22°C"
|
116
|
+
|
117
|
+
### Complete Weather Description
|
118
|
+
- Current conditions description
|
119
|
+
- Temperature in natural language
|
120
|
+
- Wind direction and speed
|
121
|
+
- Cloud coverage percentage
|
122
|
+
- Feels-like temperature
|
123
|
+
|
124
|
+
## Execution Flow
|
125
|
+
|
126
|
+
1. **AI calls function**: `get_weather(location: "New York")`
|
127
|
+
2. **DataMap webhook**: `GET https://api.weatherapi.com/v1/current.json?key=...&q=New%20York&aqi=no`
|
128
|
+
3. **API response**: Weather data with current conditions
|
129
|
+
4. **AI responds**: "Tell the user the current weather conditions. Express all temperatures in Fahrenheit using natural language numbers... Current conditions: Partly cloudy. Temperature: seventy two degrees Fahrenheit. Wind: Southwest at fifteen miles per hour. Cloud coverage: twenty five percent. Feels like: seventy five degrees Fahrenheit."
|
130
|
+
|
131
|
+
## WeatherAPI.com Integration
|
132
|
+
|
133
|
+
The skill integrates with WeatherAPI.com's current weather endpoint:
|
134
|
+
|
135
|
+
- **Endpoint**: `https://api.weatherapi.com/v1/current.json`
|
136
|
+
- **Parameters**: `key`, `q` (location), `aqi=no`
|
137
|
+
- **Response**: Real-time weather data including temperature, conditions, wind, clouds
|
138
|
+
- **Location Support**: Cities, states, countries, coordinates, airports, etc.
|
139
|
+
|
140
|
+
## Temperature Unit Support
|
141
|
+
|
142
|
+
### Fahrenheit Configuration
|
143
|
+
```python
|
144
|
+
"temperature_unit": "fahrenheit"
|
145
|
+
```
|
146
|
+
- Uses `temp_f` and `feelslike_f` fields
|
147
|
+
- Displays as "degrees Fahrenheit"
|
148
|
+
|
149
|
+
### Celsius Configuration
|
150
|
+
```python
|
151
|
+
"temperature_unit": "celsius"
|
152
|
+
```
|
153
|
+
- Uses `temp_c` and `feelslike_c` fields
|
154
|
+
- Displays as "degrees Celsius"
|
155
|
+
|
156
|
+
## Error Handling
|
157
|
+
|
158
|
+
- **Invalid API Key**: Validation during skill initialization
|
159
|
+
- **Invalid Temperature Unit**: Must be "fahrenheit" or "celsius"
|
160
|
+
- **API Failures**: Graceful fallback response for network/API issues
|
161
|
+
- **Invalid Locations**: Fallback suggests checking location name
|
162
|
+
|
163
|
+
## Benefits
|
164
|
+
|
165
|
+
- **TTS Optimized**: Natural language responses perfect for voice agents
|
166
|
+
- **Configurable**: Easy temperature unit switching without code changes
|
167
|
+
- **Efficient**: DataMap webhook execution, no agent processing load
|
168
|
+
- **Reliable**: Real-time data from established weather service
|
169
|
+
- **User Friendly**: Clear error messages and location flexibility
|
170
|
+
- **Professional**: Production-ready with comprehensive error handling
|
171
|
+
|
172
|
+
## Implementation Notes
|
173
|
+
|
174
|
+
- Temperature unit determines which API fields to use (`temp_f`/`temp_c`, `feelslike_f`/`feelslike_c`)
|
175
|
+
- Response includes detailed TTS instructions for natural pronunciation
|
176
|
+
- URL encoding automatically applied to location parameter
|
177
|
+
- Wind speed always reported in miles per hour regardless of temperature unit
|
178
|
+
- No air quality data requested to keep responses focused
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# Web Search Skill
|
2
|
+
|
3
|
+
The web_search skill provides web search capabilities using Google Custom Search API with web scraping functionality. It allows agents to search the internet for current information and extract content from the resulting web pages.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
- Google Custom Search API integration
|
8
|
+
- Web page content scraping and extraction
|
9
|
+
- Configurable number of search results
|
10
|
+
- Configurable delay between requests
|
11
|
+
- Custom no-results messages with query placeholders
|
12
|
+
- **Multiple instance support** - run multiple search engines with different configurations
|
13
|
+
|
14
|
+
## Requirements
|
15
|
+
|
16
|
+
- **Packages**: `beautifulsoup4`, `requests`
|
17
|
+
- **API Access**: Google Custom Search API key and Search Engine ID
|
18
|
+
|
19
|
+
## Parameters
|
20
|
+
|
21
|
+
### Required Parameters
|
22
|
+
|
23
|
+
- `api_key` (string): Google Custom Search API key
|
24
|
+
- `search_engine_id` (string): Google Custom Search Engine ID
|
25
|
+
|
26
|
+
### Optional Parameters
|
27
|
+
|
28
|
+
- `num_results` (integer, default: 1): Number of search results to return (max: 10)
|
29
|
+
- `delay` (float, default: 0): Delay in seconds between web page requests
|
30
|
+
- `tool_name` (string, default: "web_search"): Custom name for the search tool (enables multiple instances)
|
31
|
+
- `no_results_message` (string): Custom message when no results are found
|
32
|
+
- Default: "I couldn't find any results for '{query}'. This might be due to a very specific query or temporary issues. Try rephrasing your search or asking about a different topic."
|
33
|
+
- Use `{query}` as placeholder for the search query
|
34
|
+
|
35
|
+
### Advanced Parameters
|
36
|
+
|
37
|
+
- `swaig_fields` (dict): Additional SWAIG function configuration
|
38
|
+
- `secure` (boolean): Override security settings
|
39
|
+
- `fillers` (dict): Language-specific filler phrases during search
|
40
|
+
- Any other SWAIG function parameters
|
41
|
+
|
42
|
+
## Tools Created
|
43
|
+
|
44
|
+
- **Default**: `web_search` - Search the web for information
|
45
|
+
- **Custom**: Uses the `tool_name` parameter value
|
46
|
+
|
47
|
+
## Usage Examples
|
48
|
+
|
49
|
+
### Basic Usage
|
50
|
+
|
51
|
+
```python
|
52
|
+
# Minimal configuration
|
53
|
+
agent.add_skill("web_search", {
|
54
|
+
"api_key": "your-google-api-key",
|
55
|
+
"search_engine_id": "your-search-engine-id"
|
56
|
+
})
|
57
|
+
```
|
58
|
+
|
59
|
+
### Advanced Configuration
|
60
|
+
|
61
|
+
```python
|
62
|
+
# Comprehensive results with delay
|
63
|
+
agent.add_skill("web_search", {
|
64
|
+
"api_key": "your-google-api-key",
|
65
|
+
"search_engine_id": "your-search-engine-id",
|
66
|
+
"num_results": 5,
|
67
|
+
"delay": 1.0,
|
68
|
+
"no_results_message": "Sorry, I couldn't find information about '{query}'. Try a different search term."
|
69
|
+
})
|
70
|
+
```
|
71
|
+
|
72
|
+
### Multiple Instances
|
73
|
+
|
74
|
+
```python
|
75
|
+
# General web search
|
76
|
+
agent.add_skill("web_search", {
|
77
|
+
"api_key": "your-api-key",
|
78
|
+
"search_engine_id": "general-search-engine-id",
|
79
|
+
"tool_name": "search_general",
|
80
|
+
"num_results": 1
|
81
|
+
})
|
82
|
+
|
83
|
+
# News-specific search
|
84
|
+
agent.add_skill("web_search", {
|
85
|
+
"api_key": "your-api-key",
|
86
|
+
"search_engine_id": "news-search-engine-id",
|
87
|
+
"tool_name": "search_news",
|
88
|
+
"num_results": 3,
|
89
|
+
"delay": 0.5
|
90
|
+
})
|
91
|
+
|
92
|
+
# Quick search for fast answers
|
93
|
+
agent.add_skill("web_search", {
|
94
|
+
"api_key": "your-api-key",
|
95
|
+
"search_engine_id": "quick-search-engine-id",
|
96
|
+
"tool_name": "quick_search",
|
97
|
+
"num_results": 1,
|
98
|
+
"delay": 0
|
99
|
+
})
|
100
|
+
```
|
101
|
+
|
102
|
+
### With Custom Fillers
|
103
|
+
|
104
|
+
```python
|
105
|
+
agent.add_skill("web_search", {
|
106
|
+
"api_key": "your-api-key",
|
107
|
+
"search_engine_id": "your-search-engine-id",
|
108
|
+
"swaig_fields": {
|
109
|
+
"fillers": {
|
110
|
+
"en-US": [
|
111
|
+
"Let me search the web for that...",
|
112
|
+
"Looking that up online...",
|
113
|
+
"Searching the internet now..."
|
114
|
+
],
|
115
|
+
"es-ES": [
|
116
|
+
"Déjame buscar eso en internet...",
|
117
|
+
"Buscando en línea..."
|
118
|
+
]
|
119
|
+
}
|
120
|
+
}
|
121
|
+
})
|
122
|
+
```
|
123
|
+
|
124
|
+
## How It Works
|
125
|
+
|
126
|
+
1. **Search**: Uses Google Custom Search API to find relevant web pages
|
127
|
+
2. **Scrape**: Downloads and extracts readable content from each result page
|
128
|
+
3. **Format**: Presents results with titles, URLs, snippets, and extracted content
|
129
|
+
4. **Filter**: Removes unwanted elements (scripts, styles, navigation) for clean text
|
130
|
+
|
131
|
+
## Multiple Instance Support
|
132
|
+
|
133
|
+
The web_search skill supports multiple instances, allowing you to:
|
134
|
+
|
135
|
+
- Use different Google search engines for different types of content
|
136
|
+
- Have different configurations (number of results, delays) per instance
|
137
|
+
- Create specialized search tools (news, products, support, etc.)
|
138
|
+
- Customize tool names for clarity (`search_news`, `search_products`, etc.)
|
139
|
+
|
140
|
+
Each instance is uniquely identified by its `search_engine_id` and `tool_name` combination.
|
141
|
+
|
142
|
+
## Error Handling
|
143
|
+
|
144
|
+
- **No Results**: Returns custom `no_results_message` with query placeholder
|
145
|
+
- **Network Issues**: Returns friendly error message for timeouts/connectivity issues
|
146
|
+
- **Invalid Pages**: Gracefully handles pages that can't be scraped
|
147
|
+
- **Rate Limiting**: Built-in delay support to respect API limits
|
148
|
+
|
149
|
+
## Best Practices
|
150
|
+
|
151
|
+
1. **For Speed**: Use `num_results: 1` and `delay: 0` for customer service
|
152
|
+
2. **For Research**: Use `num_results: 3-5` and `delay: 0.5-1.0` for comprehensive results
|
153
|
+
3. **For News**: Use a news-specific search engine ID with higher result count
|
154
|
+
4. **Rate Limiting**: Add delays when making frequent searches to respect API quotas
|
155
|
+
5. **Custom Messages**: Tailor `no_results_message` to your agent's personality and use case
|
156
|
+
|
157
|
+
## Getting Google Custom Search Setup
|
158
|
+
|
159
|
+
1. Create a Google Cloud Project
|
160
|
+
2. Enable the Custom Search JSON API
|
161
|
+
3. Create a Custom Search Engine at https://cse.google.com/
|
162
|
+
4. Get your API key from Google Cloud Console
|
163
|
+
5. Get your Search Engine ID from the Custom Search Engine settings
|
@@ -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.
|
@@ -1,9 +1,11 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: signalwire_agents
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.25
|
4
4
|
Summary: SignalWire AI Agents SDK
|
5
5
|
Author-email: SignalWire Team <info@signalwire.com>
|
6
|
+
License: MIT
|
6
7
|
Project-URL: Homepage, https://github.com/signalwire/signalwire-agents
|
8
|
+
Keywords: signalwire,ai,agents,voice,telephony,swaig,swml
|
7
9
|
Classifier: Development Status :: 4 - Beta
|
8
10
|
Classifier: Intended Audience :: Developers
|
9
11
|
Classifier: License :: OSI Approved :: MIT License
|
@@ -26,6 +28,7 @@ Requires-Dist: structlog==25.3.0
|
|
26
28
|
Requires-Dist: uvicorn==0.34.2
|
27
29
|
Requires-Dist: beautifulsoup4==4.12.3
|
28
30
|
Requires-Dist: pytz==2023.3
|
31
|
+
Requires-Dist: lxml>=4.9.0
|
29
32
|
Provides-Extra: search-queryonly
|
30
33
|
Requires-Dist: numpy>=1.24.0; extra == "search-queryonly"
|
31
34
|
Requires-Dist: scikit-learn>=1.3.0; extra == "search-queryonly"
|
@@ -735,7 +738,49 @@ class DynamicAgent(AgentBase):
|
|
735
738
|
- **Localization**: Language and cultural adaptation based on user location
|
736
739
|
- **Dynamic Pricing**: Adjust features and capabilities based on subscription tiers
|
737
740
|
|
738
|
-
|
741
|
+
### Preserving Dynamic State in SWAIG Callbacks
|
742
|
+
|
743
|
+
When using dynamic configuration to add skills or tools based on request parameters, there's a challenge: SWAIG webhook callbacks are separate HTTP requests that won't have the original query parameters. The SDK provides `add_swaig_query_params()` to solve this:
|
744
|
+
|
745
|
+
```python
|
746
|
+
class DynamicAgent(AgentBase):
|
747
|
+
def __init__(self):
|
748
|
+
super().__init__(name="dynamic-agent", route="/agent")
|
749
|
+
self.set_dynamic_config_callback(self.configure_per_request)
|
750
|
+
|
751
|
+
def configure_per_request(self, query_params, body_params, headers, agent):
|
752
|
+
tier = query_params.get('tier', 'basic')
|
753
|
+
region = query_params.get('region', 'us-east')
|
754
|
+
|
755
|
+
if tier == 'premium':
|
756
|
+
# Add premium skills dynamically
|
757
|
+
agent.add_skill('advanced_search', {
|
758
|
+
'api_key': 'your-api-key',
|
759
|
+
'num_results': 5
|
760
|
+
})
|
761
|
+
|
762
|
+
# IMPORTANT: Preserve parameters for SWAIG callbacks
|
763
|
+
agent.add_swaig_query_params({
|
764
|
+
'tier': tier,
|
765
|
+
'region': region
|
766
|
+
})
|
767
|
+
|
768
|
+
# Now when SignalWire calls the SWAIG webhook, these params
|
769
|
+
# will be included, triggering the same dynamic configuration
|
770
|
+
|
771
|
+
# Initial request: GET /agent?tier=premium®ion=eu-west
|
772
|
+
# SWAIG callback: POST /swaig/?tier=premium®ion=eu-west
|
773
|
+
# Result: Premium skills are available in both requests!
|
774
|
+
```
|
775
|
+
|
776
|
+
**Key Points:**
|
777
|
+
|
778
|
+
- **Problem**: Dynamically added skills/tools won't exist during SWAIG callbacks without the original request parameters
|
779
|
+
- **Solution**: Use `add_swaig_query_params()` to include critical parameters in all SWAIG webhook URLs
|
780
|
+
- **Clear State**: Use `clear_swaig_query_params()` if needed to reset parameters between requests
|
781
|
+
- **Token Safety**: The SDK automatically renames security tokens from `token` to `__token` to avoid parameter collisions
|
782
|
+
|
783
|
+
This ensures that any dynamic configuration based on request parameters is consistently applied across the initial SWML request and all subsequent SWAIG function callbacks.
|
739
784
|
|
740
785
|
For detailed documentation and advanced examples, see the [Agent Guide](docs/agent_guide.md#dynamic-agent-configuration).
|
741
786
|
|