webagents 0.2.2__py3-none-any.whl → 0.2.3__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.
- webagents/__init__.py +9 -0
- webagents/agents/core/base_agent.py +865 -69
- webagents/agents/core/handoffs.py +14 -6
- webagents/agents/skills/base.py +33 -2
- webagents/agents/skills/core/llm/litellm/skill.py +906 -27
- webagents/agents/skills/core/memory/vector_memory/skill.py +8 -16
- webagents/agents/skills/ecosystem/openai/__init__.py +6 -0
- webagents/agents/skills/ecosystem/openai/skill.py +867 -0
- webagents/agents/skills/ecosystem/replicate/README.md +440 -0
- webagents/agents/skills/ecosystem/replicate/__init__.py +10 -0
- webagents/agents/skills/ecosystem/replicate/skill.py +517 -0
- webagents/agents/skills/examples/__init__.py +6 -0
- webagents/agents/skills/examples/music_player.py +329 -0
- webagents/agents/skills/robutler/handoff/__init__.py +6 -0
- webagents/agents/skills/robutler/handoff/skill.py +191 -0
- webagents/agents/skills/robutler/nli/skill.py +180 -24
- webagents/agents/skills/robutler/payments/exceptions.py +27 -7
- webagents/agents/skills/robutler/payments/skill.py +64 -14
- webagents/agents/skills/robutler/storage/files/skill.py +2 -2
- webagents/agents/tools/decorators.py +243 -47
- webagents/agents/widgets/__init__.py +6 -0
- webagents/agents/widgets/renderer.py +150 -0
- webagents/server/core/app.py +130 -15
- webagents/server/core/models.py +1 -1
- webagents/utils/logging.py +13 -1
- {webagents-0.2.2.dist-info → webagents-0.2.3.dist-info}/METADATA +8 -25
- {webagents-0.2.2.dist-info → webagents-0.2.3.dist-info}/RECORD +30 -20
- webagents/agents/skills/ecosystem/openai_agents/__init__.py +0 -0
- {webagents-0.2.2.dist-info → webagents-0.2.3.dist-info}/WHEEL +0 -0
- {webagents-0.2.2.dist-info → webagents-0.2.3.dist-info}/entry_points.txt +0 -0
- {webagents-0.2.2.dist-info → webagents-0.2.3.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,440 @@
|
|
1
|
+
# Replicate Skill for WebAgents
|
2
|
+
|
3
|
+
Advanced machine learning model execution via Replicate's API. This skill allows you to securely manage Replicate API credentials and run any public model on the Replicate platform.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
- 🔐 **Secure credential storage** via auth and KV skills
|
8
|
+
- 🤖 **Run ML models** with any input data type
|
9
|
+
- 📋 **List models** from specific owners or browse popular models
|
10
|
+
- 📊 **Monitor predictions** in real-time with status tracking
|
11
|
+
- 🛑 **Cancel predictions** to save compute costs
|
12
|
+
- 🔍 **Model discovery** with detailed parameter information
|
13
|
+
- 🔒 **Per-user isolation** with authentication
|
14
|
+
- 🛡️ **API token validation** during setup
|
15
|
+
|
16
|
+
## Prerequisites
|
17
|
+
|
18
|
+
1. **Replicate account** (free or paid)
|
19
|
+
2. **Replicate API token** (generated from Replicate account settings)
|
20
|
+
3. **WebAgents framework** with auth and kv skills enabled
|
21
|
+
|
22
|
+
## Quick Start
|
23
|
+
|
24
|
+
### 1. Set up Replicate API credentials
|
25
|
+
|
26
|
+
```python
|
27
|
+
# The agent will use the replicate_setup tool when asked
|
28
|
+
response = await agent.run([
|
29
|
+
{"role": "user", "content": "Set up Replicate with token r8_your_token_here"}
|
30
|
+
])
|
31
|
+
```
|
32
|
+
|
33
|
+
### 2. Discover available models
|
34
|
+
|
35
|
+
```python
|
36
|
+
# Browse models from a specific owner
|
37
|
+
response = await agent.run([
|
38
|
+
{"role": "user", "content": "List Stability AI models on Replicate"}
|
39
|
+
])
|
40
|
+
```
|
41
|
+
|
42
|
+
### 3. Get model information
|
43
|
+
|
44
|
+
```python
|
45
|
+
# Get detailed info about a model
|
46
|
+
response = await agent.run([
|
47
|
+
{"role": "user", "content": "Tell me about the stability-ai/stable-diffusion model"}
|
48
|
+
])
|
49
|
+
```
|
50
|
+
|
51
|
+
### 4. Run a prediction
|
52
|
+
|
53
|
+
```python
|
54
|
+
# Run image generation
|
55
|
+
response = await agent.run([
|
56
|
+
{"role": "user", "content": "Generate an image of a sunset over the ocean using Stable Diffusion"}
|
57
|
+
])
|
58
|
+
```
|
59
|
+
|
60
|
+
## Tools Reference
|
61
|
+
|
62
|
+
### `replicate_setup(api_token)`
|
63
|
+
Set up Replicate API credentials securely.
|
64
|
+
|
65
|
+
**Parameters:**
|
66
|
+
- `api_token` (str): Your Replicate API token from account settings
|
67
|
+
|
68
|
+
**Returns:**
|
69
|
+
- Success message with connection verification
|
70
|
+
- Error message if API token is invalid
|
71
|
+
|
72
|
+
**Example:**
|
73
|
+
```
|
74
|
+
✅ Replicate credentials saved successfully!
|
75
|
+
🔑 API token configured
|
76
|
+
📊 Connection to Replicate API verified
|
77
|
+
```
|
78
|
+
|
79
|
+
### `replicate_list_models(owner=None)`
|
80
|
+
List available models on Replicate.
|
81
|
+
|
82
|
+
**Parameters:**
|
83
|
+
- `owner` (str, optional): Filter models by owner (e.g., "stability-ai")
|
84
|
+
|
85
|
+
**Returns:**
|
86
|
+
- List of models with names, descriptions, and visibility
|
87
|
+
- Empty message if no models found
|
88
|
+
|
89
|
+
**Example:**
|
90
|
+
```
|
91
|
+
🤖 Available Models from stability-ai:
|
92
|
+
|
93
|
+
🌍 **stability-ai/stable-diffusion**
|
94
|
+
📝 Generate images from text prompts
|
95
|
+
|
96
|
+
🌍 **stability-ai/stable-video-diffusion**
|
97
|
+
📝 Generate videos from images
|
98
|
+
|
99
|
+
💡 Use replicate_run_prediction(model, input_data) to run a model
|
100
|
+
```
|
101
|
+
|
102
|
+
### `replicate_get_model_info(model)`
|
103
|
+
Get detailed information about a specific model.
|
104
|
+
|
105
|
+
**Parameters:**
|
106
|
+
- `model` (str): Model name in format "owner/model-name"
|
107
|
+
|
108
|
+
**Returns:**
|
109
|
+
- Detailed model information including parameters and schema
|
110
|
+
- Error message if model not found
|
111
|
+
|
112
|
+
**Example:**
|
113
|
+
```
|
114
|
+
🤖 Model Information: stability-ai/stable-diffusion
|
115
|
+
🌍 Visibility: public
|
116
|
+
📝 Description: Generate images from text prompts
|
117
|
+
🆔 Latest Version: v1.2.3
|
118
|
+
📅 Created: 2024-01-15T10:30:00Z
|
119
|
+
|
120
|
+
📋 Input Parameters:
|
121
|
+
⚠️ prompt (string): Text description of the image
|
122
|
+
📝 width (integer): Width of the output image
|
123
|
+
📝 height (integer): Height of the output image
|
124
|
+
|
125
|
+
💡 Use replicate_run_prediction() to run this model
|
126
|
+
```
|
127
|
+
|
128
|
+
### `replicate_run_prediction(model, input_data)`
|
129
|
+
Run a prediction with a Replicate model.
|
130
|
+
|
131
|
+
**Parameters:**
|
132
|
+
- `model` (str): Model name in format "owner/model-name"
|
133
|
+
- `input_data` (dict): Input parameters for the model
|
134
|
+
|
135
|
+
**Returns:**
|
136
|
+
- Success message with prediction ID and initial status
|
137
|
+
- Error message if model not found or input invalid
|
138
|
+
|
139
|
+
**Example:**
|
140
|
+
```
|
141
|
+
🚀 Prediction started successfully!
|
142
|
+
🆔 Prediction ID: pred_abc123def456
|
143
|
+
🤖 Model: stability-ai/stable-diffusion
|
144
|
+
📊 Status: starting
|
145
|
+
⏳ Use replicate_get_prediction() to check status and get results
|
146
|
+
```
|
147
|
+
|
148
|
+
### `replicate_get_prediction(prediction_id)`
|
149
|
+
Get prediction status and results.
|
150
|
+
|
151
|
+
**Parameters:**
|
152
|
+
- `prediction_id` (str): The prediction ID returned from replicate_run_prediction
|
153
|
+
|
154
|
+
**Returns:**
|
155
|
+
- Detailed prediction status report with results if completed
|
156
|
+
- Error message if prediction not found
|
157
|
+
|
158
|
+
**Example:**
|
159
|
+
```
|
160
|
+
📊 Prediction Status Report
|
161
|
+
🆔 Prediction ID: pred_abc123def456
|
162
|
+
🤖 Model: stability-ai/stable-diffusion
|
163
|
+
✅ Status: succeeded
|
164
|
+
🕐 Created: 2024-01-15T10:30:00Z
|
165
|
+
▶️ Started: 2024-01-15T10:30:05Z
|
166
|
+
🏁 Completed: 2024-01-15T10:32:15Z
|
167
|
+
📋 Output: https://replicate.delivery/pbxt/abc123.png
|
168
|
+
```
|
169
|
+
|
170
|
+
### `replicate_cancel_prediction(prediction_id)`
|
171
|
+
Cancel a running prediction.
|
172
|
+
|
173
|
+
**Parameters:**
|
174
|
+
- `prediction_id` (str): The prediction ID to cancel
|
175
|
+
|
176
|
+
**Returns:**
|
177
|
+
- Success message if canceled
|
178
|
+
- Error message if prediction cannot be canceled
|
179
|
+
|
180
|
+
**Example:**
|
181
|
+
```
|
182
|
+
✅ Prediction pred_abc123def456 canceled successfully
|
183
|
+
```
|
184
|
+
|
185
|
+
## Setup Guide
|
186
|
+
|
187
|
+
### Getting your Replicate API Token
|
188
|
+
|
189
|
+
1. Sign up for a [Replicate account](https://replicate.com)
|
190
|
+
2. Go to **Account Settings** → **API tokens**
|
191
|
+
3. Click **Create token**
|
192
|
+
4. Give it a name (e.g., "WebAgent Integration")
|
193
|
+
5. Copy the generated token (starts with `r8_`)
|
194
|
+
|
195
|
+
### Replicate Pricing
|
196
|
+
|
197
|
+
- **Free tier**: Limited compute credits per month
|
198
|
+
- **Pay-per-use**: Charged based on compute time and model complexity
|
199
|
+
- **Different models** have different pricing (check model pages)
|
200
|
+
|
201
|
+
## Usage Examples
|
202
|
+
|
203
|
+
### Simple Text Generation
|
204
|
+
|
205
|
+
```python
|
206
|
+
# Setup agent with Replicate skill
|
207
|
+
agent = BaseAgent(
|
208
|
+
name="ai-assistant",
|
209
|
+
instructions="You are an AI assistant that can run machine learning models.",
|
210
|
+
model="openai/gpt-4o-mini",
|
211
|
+
skills={
|
212
|
+
"replicate": ReplicateSkill(),
|
213
|
+
"auth": AuthSkill(),
|
214
|
+
"kv": KVSkill()
|
215
|
+
}
|
216
|
+
)
|
217
|
+
|
218
|
+
# Setup credentials (one-time)
|
219
|
+
response = await agent.run([
|
220
|
+
{"role": "user", "content": "Set up Replicate with my API token r8_your_token_here"}
|
221
|
+
])
|
222
|
+
|
223
|
+
# Generate text
|
224
|
+
response = await agent.run([
|
225
|
+
{"role": "user", "content": "Generate a haiku about AI using the LLaMA model"}
|
226
|
+
])
|
227
|
+
```
|
228
|
+
|
229
|
+
### Image Generation Workflow
|
230
|
+
|
231
|
+
```python
|
232
|
+
# Generate an image
|
233
|
+
response = await agent.run([
|
234
|
+
{"role": "user", "content": "Create an image of a cyberpunk cityscape using Stable Diffusion"}
|
235
|
+
])
|
236
|
+
|
237
|
+
# Check generation status
|
238
|
+
response = await agent.run([
|
239
|
+
{"role": "user", "content": "Check the status of my last image generation"}
|
240
|
+
])
|
241
|
+
```
|
242
|
+
|
243
|
+
### Audio Processing
|
244
|
+
|
245
|
+
```python
|
246
|
+
# Transcribe audio
|
247
|
+
response = await agent.run([
|
248
|
+
{"role": "user", "content": "Transcribe this audio file: https://example.com/audio.mp3"}
|
249
|
+
])
|
250
|
+
```
|
251
|
+
|
252
|
+
### Model Discovery
|
253
|
+
|
254
|
+
```python
|
255
|
+
# Discover available models
|
256
|
+
response = await agent.run([
|
257
|
+
{"role": "user", "content": "Show me what image generation models are available from Stability AI"}
|
258
|
+
])
|
259
|
+
|
260
|
+
# Get model details
|
261
|
+
response = await agent.run([
|
262
|
+
{"role": "user", "content": "Tell me more about the stable-video-diffusion model"}
|
263
|
+
])
|
264
|
+
```
|
265
|
+
|
266
|
+
### Conversation Examples
|
267
|
+
|
268
|
+
#### Setting up Replicate
|
269
|
+
|
270
|
+
**User:** "I want to use Replicate models. My API token is r8_abc123def456"
|
271
|
+
|
272
|
+
**Assistant:** "I'll set up Replicate for you with that API token."
|
273
|
+
|
274
|
+
*[Agent uses replicate_setup tool]*
|
275
|
+
|
276
|
+
**Assistant:** "✅ Replicate credentials saved successfully! 🔑 API token configured 📊 Connection to Replicate API verified"
|
277
|
+
|
278
|
+
#### Generating an Image
|
279
|
+
|
280
|
+
**User:** "Generate an image of a dragon flying over mountains"
|
281
|
+
|
282
|
+
**Assistant:** "I'll create that image for you using Stable Diffusion."
|
283
|
+
|
284
|
+
*[Agent uses replicate_run_prediction tool with stability-ai/stable-diffusion]*
|
285
|
+
|
286
|
+
**Assistant:** "🚀 Prediction started successfully! 🆔 Prediction ID: pred_abc123def456 🤖 Model: stability-ai/stable-diffusion 📊 Status: starting. I'll check on the progress for you."
|
287
|
+
|
288
|
+
*[Agent uses replicate_get_prediction tool]*
|
289
|
+
|
290
|
+
**Assistant:** "✅ Your image is ready! Here's your dragon flying over mountains: https://replicate.delivery/pbxt/abc123.png"
|
291
|
+
|
292
|
+
#### Model Discovery
|
293
|
+
|
294
|
+
**User:** "What AI models are available for video generation?"
|
295
|
+
|
296
|
+
**Assistant:** "Let me check what video models are available on Replicate."
|
297
|
+
|
298
|
+
*[Agent uses replicate_list_models and replicate_get_model_info tools]*
|
299
|
+
|
300
|
+
**Assistant:** "I found several video generation models:
|
301
|
+
|
302
|
+
🌍 **stability-ai/stable-video-diffusion** - Generate videos from images
|
303
|
+
🌍 **anotherjesse/zeroscope-v2-xl** - Text-to-video generation
|
304
|
+
|
305
|
+
Would you like me to generate a video using one of these models?"
|
306
|
+
|
307
|
+
## Error Handling
|
308
|
+
|
309
|
+
The skill provides clear error messages for common scenarios:
|
310
|
+
|
311
|
+
- **❌ Authentication required** - User not authenticated
|
312
|
+
- **❌ API token is required** - Empty or missing API token
|
313
|
+
- **❌ Invalid API token** - API token rejected by Replicate
|
314
|
+
- **❌ Model not found** - Invalid model name or model doesn't exist
|
315
|
+
- **❌ Invalid input data** - Input doesn't match model requirements
|
316
|
+
- **❌ Prediction not found** - Invalid prediction ID
|
317
|
+
- **❌ Cannot cancel prediction** - Prediction already completed or canceled
|
318
|
+
|
319
|
+
## Security
|
320
|
+
|
321
|
+
- **API tokens** are stored securely using the KV skill with per-user namespacing
|
322
|
+
- **User isolation** ensures each user can only access their own credentials
|
323
|
+
- **Authentication required** for all operations
|
324
|
+
- **Automatic validation** of API tokens during setup
|
325
|
+
- **Memory fallback** available if KV skill unavailable
|
326
|
+
|
327
|
+
## Architecture
|
328
|
+
|
329
|
+
```
|
330
|
+
WebAgent
|
331
|
+
├── Auth Skill (user context)
|
332
|
+
├── KV Skill (secure storage)
|
333
|
+
└── Replicate Skill
|
334
|
+
├── Credential Management
|
335
|
+
├── API Communication
|
336
|
+
├── Model Discovery
|
337
|
+
├── Prediction Management
|
338
|
+
└── Status Monitoring
|
339
|
+
```
|
340
|
+
|
341
|
+
## Dependencies
|
342
|
+
|
343
|
+
- `auth` skill - For user authentication and context
|
344
|
+
- `kv` skill - For secure credential storage
|
345
|
+
- `httpx` - For HTTP API communication
|
346
|
+
- `json` - For data serialization
|
347
|
+
- `datetime` - For timestamp handling
|
348
|
+
|
349
|
+
## Troubleshooting
|
350
|
+
|
351
|
+
### "Authentication required"
|
352
|
+
Ensure your agent has proper authentication configured and the user is logged in.
|
353
|
+
|
354
|
+
### "Invalid API token"
|
355
|
+
- Verify the API token is correct and starts with `r8_`
|
356
|
+
- Check if the token has been revoked in your Replicate account
|
357
|
+
- Ensure you copied the full token without extra spaces
|
358
|
+
|
359
|
+
### "API token doesn't have required permissions"
|
360
|
+
- Check if your Replicate account has API access enabled
|
361
|
+
- Verify the token has necessary permissions
|
362
|
+
- Contact Replicate support if issues persist
|
363
|
+
|
364
|
+
### "Model not found"
|
365
|
+
- Ask the agent to list available models first
|
366
|
+
- Check if the model name format is correct (owner/model-name)
|
367
|
+
- Verify the model exists and is public (or you have access)
|
368
|
+
|
369
|
+
### "Invalid input data"
|
370
|
+
- Ask the agent to get model information to see required parameters
|
371
|
+
- Check the model's documentation on Replicate
|
372
|
+
- Ensure input data types match the model's schema
|
373
|
+
|
374
|
+
### "Prediction taking too long"
|
375
|
+
- Some models can take several minutes to complete
|
376
|
+
- Ask the agent to check prediction status periodically
|
377
|
+
- Consider canceling and trying a smaller/faster model
|
378
|
+
|
379
|
+
### "Prediction failed"
|
380
|
+
- Check the error message in the prediction status
|
381
|
+
- Verify your input data is valid
|
382
|
+
- Check if you have sufficient credits in your Replicate account
|
383
|
+
|
384
|
+
## Limitations
|
385
|
+
|
386
|
+
- Supports Replicate REST API v1 endpoints
|
387
|
+
- Limited to public models (unless you have private model access)
|
388
|
+
- Rate limited by Replicate's API limits
|
389
|
+
- Prediction results depend on model availability and performance
|
390
|
+
- Some models may have usage restrictions or require special permissions
|
391
|
+
|
392
|
+
## Model Categories
|
393
|
+
|
394
|
+
Replicate hosts various types of models:
|
395
|
+
|
396
|
+
### Text Models
|
397
|
+
- **Language models**: GPT, LLaMA, Claude alternatives
|
398
|
+
- **Chat models**: Conversational AI models
|
399
|
+
- **Code generation**: Programming assistance models
|
400
|
+
|
401
|
+
### Image Models
|
402
|
+
- **Text-to-image**: Stable Diffusion, DALL-E alternatives
|
403
|
+
- **Image-to-image**: Style transfer, upscaling, editing
|
404
|
+
- **Image analysis**: Object detection, classification
|
405
|
+
|
406
|
+
### Audio Models
|
407
|
+
- **Speech-to-text**: Whisper, transcription models
|
408
|
+
- **Text-to-speech**: Voice synthesis models
|
409
|
+
- **Audio generation**: Music, sound effects
|
410
|
+
|
411
|
+
### Video Models
|
412
|
+
- **Text-to-video**: Video generation from prompts
|
413
|
+
- **Video-to-video**: Style transfer, editing
|
414
|
+
- **Video analysis**: Object tracking, classification
|
415
|
+
|
416
|
+
### Multimodal Models
|
417
|
+
- **Vision-language**: CLIP, image captioning
|
418
|
+
- **Audio-visual**: Video understanding models
|
419
|
+
|
420
|
+
## Integration Tips
|
421
|
+
|
422
|
+
1. **Monitor costs** - Check model pricing before running expensive predictions
|
423
|
+
2. **Use appropriate models** - Choose the right model size for your task
|
424
|
+
3. **Cache results** - Store outputs to avoid re-running identical predictions
|
425
|
+
4. **Cancel unused predictions** - Save costs by canceling long-running predictions
|
426
|
+
5. **Test models first** - Try models with simple inputs before complex tasks
|
427
|
+
|
428
|
+
## Contributing
|
429
|
+
|
430
|
+
To extend this skill:
|
431
|
+
|
432
|
+
1. Add new tools following the existing pattern
|
433
|
+
2. Update tests in `tests/test_replicate_skill.py`
|
434
|
+
3. Update this documentation
|
435
|
+
4. Ensure proper error handling and user feedback
|
436
|
+
5. Test with various model types and scenarios
|
437
|
+
|
438
|
+
## License
|
439
|
+
|
440
|
+
Part of the WebAgents framework. See main project license.
|