pollax 1.0.0__tar.gz
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.
- pollax-1.0.0/PKG-INFO +388 -0
- pollax-1.0.0/README.md +355 -0
- pollax-1.0.0/pollax/__init__.py +43 -0
- pollax-1.0.0/pollax/client.py +188 -0
- pollax-1.0.0/pollax/errors.py +38 -0
- pollax-1.0.0/pollax/models.py +149 -0
- pollax-1.0.0/pollax/resources/__init__.py +23 -0
- pollax-1.0.0/pollax/resources/agents.py +196 -0
- pollax-1.0.0/pollax/resources/analytics.py +35 -0
- pollax-1.0.0/pollax/resources/api_keys.py +31 -0
- pollax-1.0.0/pollax/resources/calls.py +75 -0
- pollax-1.0.0/pollax/resources/campaigns.py +64 -0
- pollax-1.0.0/pollax/resources/integrations.py +37 -0
- pollax-1.0.0/pollax/resources/knowledge.py +60 -0
- pollax-1.0.0/pollax/resources/phone_numbers.py +51 -0
- pollax-1.0.0/pollax/resources/voice_cloning.py +44 -0
- pollax-1.0.0/pollax.egg-info/PKG-INFO +388 -0
- pollax-1.0.0/pollax.egg-info/SOURCES.txt +21 -0
- pollax-1.0.0/pollax.egg-info/dependency_links.txt +1 -0
- pollax-1.0.0/pollax.egg-info/requires.txt +10 -0
- pollax-1.0.0/pollax.egg-info/top_level.txt +1 -0
- pollax-1.0.0/pyproject.toml +67 -0
- pollax-1.0.0/setup.cfg +4 -0
pollax-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pollax
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official Python SDK for the Pollax AI Voice Platform
|
|
5
|
+
Author-email: Pollax <support@pollax.ai>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://pollax.ai
|
|
8
|
+
Project-URL: Documentation, https://docs.pollax.ai
|
|
9
|
+
Project-URL: Repository, https://github.com/pollax/pollax-python
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/pollax/pollax-python/issues
|
|
11
|
+
Keywords: pollax,ai,voice,calling,telephony,speech
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
Requires-Dist: httpx>=0.24.0
|
|
25
|
+
Requires-Dist: pydantic>=2.0.0
|
|
26
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
30
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: ruff>=0.0.270; extra == "dev"
|
|
33
|
+
|
|
34
|
+
# Pollax Python SDK
|
|
35
|
+
|
|
36
|
+
Official Python client library for the Pollax AI Voice Platform.
|
|
37
|
+
|
|
38
|
+
[](https://pypi.org/project/pollax/)
|
|
39
|
+
[](https://pypi.org/project/pollax/)
|
|
40
|
+
[](https://github.com/pollax/pollax-python/blob/main/LICENSE)
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install pollax
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quick Start
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from pollax import Pollax
|
|
52
|
+
|
|
53
|
+
# Initialize client
|
|
54
|
+
client = Pollax(api_key="sk_live_your_api_key_here")
|
|
55
|
+
|
|
56
|
+
# Create an AI agent
|
|
57
|
+
agent = client.agents.create(
|
|
58
|
+
name="Customer Support Agent",
|
|
59
|
+
system_prompt="You are a helpful customer support agent for Acme Corp.",
|
|
60
|
+
voice_id="alloy",
|
|
61
|
+
model="gpt-4",
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# Make a call
|
|
65
|
+
call = client.calls.create(
|
|
66
|
+
agent_id=agent.id,
|
|
67
|
+
to_number="+1234567890",
|
|
68
|
+
from_number="+0987654321",
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
print(f"Call initiated: {call.call_sid}")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Features
|
|
75
|
+
|
|
76
|
+
- Full type hints with Pydantic models
|
|
77
|
+
- Async/await support
|
|
78
|
+
- Automatic retry logic with exponential backoff
|
|
79
|
+
- Comprehensive error handling
|
|
80
|
+
- Context manager support
|
|
81
|
+
- Python 3.8+ support
|
|
82
|
+
|
|
83
|
+
## Usage
|
|
84
|
+
|
|
85
|
+
### Client Initialization
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from pollax import Pollax
|
|
89
|
+
|
|
90
|
+
# Basic initialization
|
|
91
|
+
client = Pollax(api_key="sk_live_...")
|
|
92
|
+
|
|
93
|
+
# With custom configuration
|
|
94
|
+
client = Pollax(
|
|
95
|
+
api_key="sk_live_...",
|
|
96
|
+
base_url="https://api.pollax.ai",
|
|
97
|
+
timeout=30.0,
|
|
98
|
+
max_retries=3,
|
|
99
|
+
tenant_id="org_123",
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# Using context manager (recommended)
|
|
103
|
+
with Pollax(api_key="sk_live_...") as client:
|
|
104
|
+
agents = client.agents.list()
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Agents
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
# Create an agent
|
|
111
|
+
agent = client.agents.create(
|
|
112
|
+
name="Support Agent",
|
|
113
|
+
system_prompt="You are a helpful assistant",
|
|
114
|
+
voice_provider="elevenlabs",
|
|
115
|
+
voice_id="voice_abc123",
|
|
116
|
+
model="gpt-4",
|
|
117
|
+
temperature=0.7,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
# List agents
|
|
121
|
+
agents = client.agents.list(is_active=True)
|
|
122
|
+
|
|
123
|
+
# Get a specific agent
|
|
124
|
+
agent = client.agents.retrieve("agent_123")
|
|
125
|
+
|
|
126
|
+
# Update an agent
|
|
127
|
+
agent = client.agents.update(
|
|
128
|
+
"agent_123",
|
|
129
|
+
name="New Name",
|
|
130
|
+
is_active=False,
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
# Delete an agent
|
|
134
|
+
client.agents.delete("agent_123")
|
|
135
|
+
|
|
136
|
+
# Test an agent
|
|
137
|
+
response = client.agents.test("agent_123", "Hello, how can you help?")
|
|
138
|
+
print(response)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Calls
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
# Create a call
|
|
145
|
+
call = client.calls.create(
|
|
146
|
+
agent_id="agent_123",
|
|
147
|
+
to_number="+1234567890",
|
|
148
|
+
from_number="+0987654321",
|
|
149
|
+
metadata={"customer_id": "cust_456"},
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
# List calls
|
|
153
|
+
calls = client.calls.list(
|
|
154
|
+
agent_id="agent_123",
|
|
155
|
+
status="completed",
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
# Get call details
|
|
159
|
+
call = client.calls.retrieve("CA123456")
|
|
160
|
+
|
|
161
|
+
# End a call
|
|
162
|
+
client.calls.end("CA123456")
|
|
163
|
+
|
|
164
|
+
# Transfer a call
|
|
165
|
+
client.calls.transfer("CA123456", to_number="+1111111111")
|
|
166
|
+
|
|
167
|
+
# Get call transcript
|
|
168
|
+
transcript = client.calls.get_transcript("CA123456")
|
|
169
|
+
print(transcript)
|
|
170
|
+
|
|
171
|
+
# Get call recording
|
|
172
|
+
recording = client.calls.get_recording("CA123456")
|
|
173
|
+
print(recording["url"])
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Campaigns
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
# Create a campaign
|
|
180
|
+
campaign = client.campaigns.create(
|
|
181
|
+
name="Q1 Outreach Campaign",
|
|
182
|
+
agent_id="agent_123",
|
|
183
|
+
contacts=[
|
|
184
|
+
{"name": "John Doe", "phone": "+1234567890"},
|
|
185
|
+
{"name": "Jane Smith", "phone": "+0987654321"},
|
|
186
|
+
],
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
# Start campaign
|
|
190
|
+
client.campaigns.start("campaign_123")
|
|
191
|
+
|
|
192
|
+
# Pause campaign
|
|
193
|
+
client.campaigns.pause("campaign_123")
|
|
194
|
+
|
|
195
|
+
# Get campaign stats
|
|
196
|
+
stats = client.campaigns.get_stats("campaign_123")
|
|
197
|
+
print(f"Success rate: {stats['success_rate']}")
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Knowledge Base
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
# Upload a document
|
|
204
|
+
with open("manual.pdf", "rb") as f:
|
|
205
|
+
doc = client.knowledge.upload(
|
|
206
|
+
name="Product Manual",
|
|
207
|
+
file=f,
|
|
208
|
+
doc_type="pdf",
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
# Upload from text
|
|
212
|
+
doc = client.knowledge.upload(
|
|
213
|
+
name="FAQ",
|
|
214
|
+
content="Q: How do I reset my password? A: Click forgot password...",
|
|
215
|
+
doc_type="txt",
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
# Search knowledge base
|
|
219
|
+
results = client.knowledge.search(
|
|
220
|
+
query="How do I reset my password?",
|
|
221
|
+
limit=5,
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
for result in results["results"]:
|
|
225
|
+
print(f"Score: {result['score']}")
|
|
226
|
+
print(f"Content: {result['content']}")
|
|
227
|
+
|
|
228
|
+
# Delete a document
|
|
229
|
+
client.knowledge.delete("doc_123")
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Analytics
|
|
233
|
+
|
|
234
|
+
```python
|
|
235
|
+
# Get dashboard statistics
|
|
236
|
+
stats = client.analytics.get_stats()
|
|
237
|
+
print(f"Total calls: {stats.total_calls}")
|
|
238
|
+
print(f"Active agents: {stats.active_agents}")
|
|
239
|
+
print(f"Success rate: {stats.success_rate}")
|
|
240
|
+
|
|
241
|
+
# Get call volume over time
|
|
242
|
+
volume = client.analytics.get_call_volume(period="7d")
|
|
243
|
+
|
|
244
|
+
# Get agent performance
|
|
245
|
+
performance = client.analytics.get_agent_performance("agent_123")
|
|
246
|
+
|
|
247
|
+
# Export data
|
|
248
|
+
data = client.analytics.export(
|
|
249
|
+
start_date="2024-01-01",
|
|
250
|
+
end_date="2024-01-31",
|
|
251
|
+
format="csv",
|
|
252
|
+
)
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Integrations
|
|
256
|
+
|
|
257
|
+
```python
|
|
258
|
+
# Create an integration
|
|
259
|
+
integration = client.integrations.create(
|
|
260
|
+
name="Salesforce CRM",
|
|
261
|
+
integration_type="salesforce",
|
|
262
|
+
config={
|
|
263
|
+
"client_id": "...",
|
|
264
|
+
"client_secret": "...",
|
|
265
|
+
},
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
# List integrations
|
|
269
|
+
integrations = client.integrations.list()
|
|
270
|
+
|
|
271
|
+
# Delete integration
|
|
272
|
+
client.integrations.delete("int_123")
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Phone Numbers
|
|
276
|
+
|
|
277
|
+
```python
|
|
278
|
+
# Search available numbers
|
|
279
|
+
numbers = client.phone_numbers.search(
|
|
280
|
+
country_code="US",
|
|
281
|
+
area_code="415",
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
# Purchase a number
|
|
285
|
+
number = client.phone_numbers.purchase("+14155551234")
|
|
286
|
+
|
|
287
|
+
# Release a number
|
|
288
|
+
client.phone_numbers.release("num_123")
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Voice Cloning
|
|
292
|
+
|
|
293
|
+
```python
|
|
294
|
+
# Create a custom voice
|
|
295
|
+
with open("sample1.wav", "rb") as f1, open("sample2.wav", "rb") as f2:
|
|
296
|
+
voice = client.voice_cloning.create(
|
|
297
|
+
name="Custom Voice",
|
|
298
|
+
description="My custom voice profile",
|
|
299
|
+
audio_files=[f1, f2],
|
|
300
|
+
provider="elevenlabs",
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
# List voices
|
|
304
|
+
voices = client.voice_cloning.list()
|
|
305
|
+
|
|
306
|
+
# Delete voice
|
|
307
|
+
client.voice_cloning.delete("voice_123")
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Error Handling
|
|
311
|
+
|
|
312
|
+
```python
|
|
313
|
+
from pollax import (
|
|
314
|
+
Pollax,
|
|
315
|
+
PollaxError,
|
|
316
|
+
AuthenticationError,
|
|
317
|
+
NotFoundError,
|
|
318
|
+
RateLimitError,
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
client = Pollax(api_key="sk_live_...")
|
|
322
|
+
|
|
323
|
+
try:
|
|
324
|
+
agent = client.agents.retrieve("agent_123")
|
|
325
|
+
except AuthenticationError:
|
|
326
|
+
print("Invalid API key")
|
|
327
|
+
except NotFoundError:
|
|
328
|
+
print("Agent not found")
|
|
329
|
+
except RateLimitError:
|
|
330
|
+
print("Rate limit exceeded, try again later")
|
|
331
|
+
except PollaxError as e:
|
|
332
|
+
print(f"API error: {e.message}")
|
|
333
|
+
print(f"Status code: {e.status_code}")
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Type Safety
|
|
337
|
+
|
|
338
|
+
The SDK uses Pydantic for data validation and type safety:
|
|
339
|
+
|
|
340
|
+
```python
|
|
341
|
+
from pollax import Pollax
|
|
342
|
+
from pollax.models import Agent, Call
|
|
343
|
+
|
|
344
|
+
client = Pollax(api_key="sk_live_...")
|
|
345
|
+
|
|
346
|
+
# Full type hints
|
|
347
|
+
agent: Agent = client.agents.create(
|
|
348
|
+
name="Support Agent",
|
|
349
|
+
system_prompt="You are helpful",
|
|
350
|
+
model="gpt-4",
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
# IDE autocomplete works perfectly
|
|
354
|
+
print(agent.id)
|
|
355
|
+
print(agent.name)
|
|
356
|
+
print(agent.created_at)
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## Development
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
# Clone repository
|
|
363
|
+
git clone https://github.com/pollax/pollax-python
|
|
364
|
+
cd pollax-python
|
|
365
|
+
|
|
366
|
+
# Install dependencies
|
|
367
|
+
pip install -e ".[dev]"
|
|
368
|
+
|
|
369
|
+
# Run tests
|
|
370
|
+
pytest
|
|
371
|
+
|
|
372
|
+
# Format code
|
|
373
|
+
black pollax tests
|
|
374
|
+
|
|
375
|
+
# Type checking
|
|
376
|
+
mypy pollax
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## License
|
|
380
|
+
|
|
381
|
+
MIT
|
|
382
|
+
|
|
383
|
+
## Support
|
|
384
|
+
|
|
385
|
+
- 📧 Email: support@pollax.ai
|
|
386
|
+
- 💬 [Discord Community](https://discord.gg/pollax)
|
|
387
|
+
- 🐛 [Report Issues](https://github.com/pollax/pollax-python/issues)
|
|
388
|
+
- 📖 [Documentation](https://docs.pollax.ai)
|