roovy-sdk 0.1.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.
- roovy_sdk-0.1.0/.gitignore +75 -0
- roovy_sdk-0.1.0/LICENSE +21 -0
- roovy_sdk-0.1.0/PKG-INFO +279 -0
- roovy_sdk-0.1.0/README.md +246 -0
- roovy_sdk-0.1.0/pyproject.toml +77 -0
- roovy_sdk-0.1.0/src/roovy_sdk/__init__.py +87 -0
- roovy_sdk-0.1.0/src/roovy_sdk/client.py +218 -0
- roovy_sdk-0.1.0/src/roovy_sdk/prompt.py +412 -0
- roovy_sdk-0.1.0/src/roovy_sdk/py.typed +1 -0
- roovy_sdk-0.1.0/src/roovy_sdk/schema.py +411 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.installed.cfg
|
|
25
|
+
*.egg
|
|
26
|
+
|
|
27
|
+
# PyInstaller
|
|
28
|
+
*.manifest
|
|
29
|
+
*.spec
|
|
30
|
+
|
|
31
|
+
# Installer logs
|
|
32
|
+
pip-log.txt
|
|
33
|
+
pip-delete-this-directory.txt
|
|
34
|
+
|
|
35
|
+
# Unit test / coverage reports
|
|
36
|
+
htmlcov/
|
|
37
|
+
.tox/
|
|
38
|
+
.nox/
|
|
39
|
+
.coverage
|
|
40
|
+
.coverage.*
|
|
41
|
+
.cache
|
|
42
|
+
nosetests.xml
|
|
43
|
+
coverage.xml
|
|
44
|
+
*.cover
|
|
45
|
+
*.py,cover
|
|
46
|
+
.hypothesis/
|
|
47
|
+
.pytest_cache/
|
|
48
|
+
|
|
49
|
+
# Translations
|
|
50
|
+
*.mo
|
|
51
|
+
*.pot
|
|
52
|
+
|
|
53
|
+
# Environments
|
|
54
|
+
.env
|
|
55
|
+
.venv
|
|
56
|
+
env/
|
|
57
|
+
venv/
|
|
58
|
+
ENV/
|
|
59
|
+
env.bak/
|
|
60
|
+
venv.bak/
|
|
61
|
+
|
|
62
|
+
# IDEs
|
|
63
|
+
.idea/
|
|
64
|
+
.vscode/
|
|
65
|
+
*.swp
|
|
66
|
+
*.swo
|
|
67
|
+
*~
|
|
68
|
+
|
|
69
|
+
# mypy
|
|
70
|
+
.mypy_cache/
|
|
71
|
+
.dmypy.json
|
|
72
|
+
dmypy.json
|
|
73
|
+
|
|
74
|
+
# ruff
|
|
75
|
+
.ruff_cache/
|
roovy_sdk-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Yash Desai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
roovy_sdk-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: roovy-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for generating WhatsApp Flows using LLMs
|
|
5
|
+
Project-URL: Homepage, https://github.com/yashdesai/roovy-sdk
|
|
6
|
+
Project-URL: Documentation, https://github.com/yashdesai/roovy-sdk#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/yashdesai/roovy-sdk
|
|
8
|
+
Project-URL: Issues, https://github.com/yashdesai/roovy-sdk/issues
|
|
9
|
+
Author-email: Yash Desai <contact@yashddesai.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,chatbot,llm,meta,openai,whatsapp,whatsapp-flows
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Requires-Dist: openai>=1.0.0
|
|
26
|
+
Requires-Dist: pydantic>=2.0.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# Roovy SDK
|
|
35
|
+
|
|
36
|
+
A Python SDK for generating WhatsApp Flows using LLMs. Generate valid,
|
|
37
|
+
schema-compliant WhatsApp Flow JSON from natural language descriptions.
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- 🚀 **Simple API** - Generate WhatsApp Flows with a single function call
|
|
42
|
+
- ✅ **Schema Validation** - Built-in Pydantic models ensure valid output
|
|
43
|
+
- 🔄 **Auto-Retry** - Automatic retries with error feedback for better results
|
|
44
|
+
- 📡 **Streaming Support** - Stream responses for real-time feedback
|
|
45
|
+
- 🔌 **Provider Agnostic** - Works with OpenAI, Groq, Ollama, or any
|
|
46
|
+
OpenAI-compatible API
|
|
47
|
+
- 📝 **Type Safe** - Full type hints and Pydantic models
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install roovy-sdk
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from roovy_sdk import RoovyClient
|
|
59
|
+
|
|
60
|
+
# Initialize with your preferred provider
|
|
61
|
+
client = RoovyClient(
|
|
62
|
+
api_key="your-api-key",
|
|
63
|
+
base_url="https://api.openai.com/v1", # or any OpenAI-compatible endpoint
|
|
64
|
+
model="gpt-4o",
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# Generate a WhatsApp Flow from natural language
|
|
68
|
+
flow = client.generate(
|
|
69
|
+
"Create a customer feedback form with name, email, rating (1-5 stars), and comments"
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# Access the validated flow
|
|
73
|
+
print(flow.model_dump_json(indent=2, by_alias=True))
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Configuration
|
|
77
|
+
|
|
78
|
+
### Using Environment Variables
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
import os
|
|
82
|
+
from roovy_sdk import RoovyClient
|
|
83
|
+
|
|
84
|
+
# Set environment variables
|
|
85
|
+
os.environ["ROOVY_API_KEY"] = "your-api-key"
|
|
86
|
+
os.environ["ROOVY_BASE_URL"] = "https://api.openai.com/v1"
|
|
87
|
+
os.environ["ROOVY_MODEL"] = "gpt-4o"
|
|
88
|
+
|
|
89
|
+
# Client will use environment variables automatically
|
|
90
|
+
client = RoovyClient()
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Provider Examples
|
|
94
|
+
|
|
95
|
+
**OpenAI:**
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
client = RoovyClient(
|
|
99
|
+
api_key="sk-...",
|
|
100
|
+
base_url="https://api.openai.com/v1",
|
|
101
|
+
model="gpt-4o",
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Groq:**
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
client = RoovyClient(
|
|
109
|
+
api_key="gsk_...",
|
|
110
|
+
base_url="https://api.groq.com/openai/v1",
|
|
111
|
+
model="llama-3.3-70b-versatile",
|
|
112
|
+
)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Ollama (local):**
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
client = RoovyClient(
|
|
119
|
+
api_key="ollama", # any non-empty string
|
|
120
|
+
base_url="http://localhost:11434/v1",
|
|
121
|
+
model="llama3.2",
|
|
122
|
+
)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Advanced Usage
|
|
126
|
+
|
|
127
|
+
### Streaming Generation
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
def on_chunk(chunk: str):
|
|
131
|
+
print(chunk, end="", flush=True)
|
|
132
|
+
|
|
133
|
+
flow = client.generate_stream(
|
|
134
|
+
"Create a booking form for a concert",
|
|
135
|
+
on_chunk=on_chunk,
|
|
136
|
+
)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Custom Retry Settings
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
flow = client.generate(
|
|
143
|
+
"Create a survey form",
|
|
144
|
+
max_retries=5,
|
|
145
|
+
temperature=0.3,
|
|
146
|
+
)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Custom System Prompt
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
flow = client.generate(
|
|
153
|
+
"Create a registration form",
|
|
154
|
+
system_prompt="You are a WhatsApp Flows expert...",
|
|
155
|
+
)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Direct Schema Access
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from roovy_sdk.schema import (
|
|
162
|
+
WhatsAppFlow,
|
|
163
|
+
Screen,
|
|
164
|
+
TextInput,
|
|
165
|
+
Footer,
|
|
166
|
+
validate_flow,
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
# Build flows programmatically
|
|
170
|
+
screen = Screen(
|
|
171
|
+
id="WELCOME",
|
|
172
|
+
title="Welcome",
|
|
173
|
+
layout=SingleColumnLayout(
|
|
174
|
+
type="SingleColumnLayout",
|
|
175
|
+
children=[
|
|
176
|
+
TextHeading(type="TextHeading", text="Hello!"),
|
|
177
|
+
]
|
|
178
|
+
)
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
# Validate any JSON against the schema
|
|
182
|
+
result = validate_flow({"version": "7.2", "screens": [...]})
|
|
183
|
+
if result["success"]:
|
|
184
|
+
flow = result["data"]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Schema Reference
|
|
188
|
+
|
|
189
|
+
The SDK includes complete Pydantic models for all WhatsApp Flow components:
|
|
190
|
+
|
|
191
|
+
### Text Components
|
|
192
|
+
|
|
193
|
+
- `TextHeading` - Main headings
|
|
194
|
+
- `TextSubheading` - Subheadings
|
|
195
|
+
- `TextBody` - Body text
|
|
196
|
+
- `TextCaption` - Small captions
|
|
197
|
+
|
|
198
|
+
### Input Components
|
|
199
|
+
|
|
200
|
+
- `TextInput` - Single-line text input
|
|
201
|
+
- `TextArea` - Multi-line text input
|
|
202
|
+
- `Dropdown` - Dropdown selector
|
|
203
|
+
- `RadioButtonsGroup` - Radio button selection
|
|
204
|
+
- `ChipsSelector` - Multi-select chips
|
|
205
|
+
- `CheckboxGroup` - Checkbox group
|
|
206
|
+
- `OptIn` - Opt-in checkbox
|
|
207
|
+
|
|
208
|
+
### Date/Media Components
|
|
209
|
+
|
|
210
|
+
- `CalendarPicker` - Calendar date picker
|
|
211
|
+
- `DatePicker` - Simple date picker
|
|
212
|
+
- `PhotoPicker` - Photo upload
|
|
213
|
+
- `DocumentPicker` - Document upload
|
|
214
|
+
- `Image` - Display images
|
|
215
|
+
|
|
216
|
+
### Navigation Components
|
|
217
|
+
|
|
218
|
+
- `Footer` - Screen footer with action
|
|
219
|
+
- `Button` - Action button
|
|
220
|
+
- `EmbeddedLink` - Inline link
|
|
221
|
+
|
|
222
|
+
### Conditional Components
|
|
223
|
+
|
|
224
|
+
- `If` - Conditional rendering
|
|
225
|
+
- `Switch` - Switch/case rendering
|
|
226
|
+
|
|
227
|
+
### Container Components
|
|
228
|
+
|
|
229
|
+
- `Form` - Form container
|
|
230
|
+
- `SingleColumnLayout` - Screen layout
|
|
231
|
+
|
|
232
|
+
## API Reference
|
|
233
|
+
|
|
234
|
+
### `RoovyClient`
|
|
235
|
+
|
|
236
|
+
```python
|
|
237
|
+
RoovyClient(
|
|
238
|
+
api_key: str | None = None, # API key (or ROOVY_API_KEY env var)
|
|
239
|
+
base_url: str | None = None, # Base URL (or ROOVY_BASE_URL env var)
|
|
240
|
+
model: str | None = None, # Model name (or ROOVY_MODEL env var)
|
|
241
|
+
)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### `client.generate()`
|
|
245
|
+
|
|
246
|
+
```python
|
|
247
|
+
client.generate(
|
|
248
|
+
prompt: str, # Natural language description
|
|
249
|
+
*,
|
|
250
|
+
max_retries: int = 3, # Number of retry attempts
|
|
251
|
+
temperature: float = 0.2, # LLM temperature
|
|
252
|
+
system_prompt: str | None = None, # Custom system prompt
|
|
253
|
+
) -> WhatsAppFlow
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### `client.generate_stream()`
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
client.generate_stream(
|
|
260
|
+
prompt: str, # Natural language description
|
|
261
|
+
on_chunk: Callable[[str], None] | None = None, # Chunk callback
|
|
262
|
+
*,
|
|
263
|
+
temperature: float = 0.2, # LLM temperature
|
|
264
|
+
system_prompt: str | None = None, # Custom system prompt
|
|
265
|
+
) -> WhatsAppFlow
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### `validate_flow()`
|
|
269
|
+
|
|
270
|
+
```python
|
|
271
|
+
from roovy_sdk import validate_flow
|
|
272
|
+
|
|
273
|
+
result = validate_flow(flow_dict)
|
|
274
|
+
# Returns: {"success": True, "data": WhatsAppFlow} or {"success": False, "error": ValidationError}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## License
|
|
278
|
+
|
|
279
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Roovy SDK
|
|
2
|
+
|
|
3
|
+
A Python SDK for generating WhatsApp Flows using LLMs. Generate valid,
|
|
4
|
+
schema-compliant WhatsApp Flow JSON from natural language descriptions.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- 🚀 **Simple API** - Generate WhatsApp Flows with a single function call
|
|
9
|
+
- ✅ **Schema Validation** - Built-in Pydantic models ensure valid output
|
|
10
|
+
- 🔄 **Auto-Retry** - Automatic retries with error feedback for better results
|
|
11
|
+
- 📡 **Streaming Support** - Stream responses for real-time feedback
|
|
12
|
+
- 🔌 **Provider Agnostic** - Works with OpenAI, Groq, Ollama, or any
|
|
13
|
+
OpenAI-compatible API
|
|
14
|
+
- 📝 **Type Safe** - Full type hints and Pydantic models
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install roovy-sdk
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from roovy_sdk import RoovyClient
|
|
26
|
+
|
|
27
|
+
# Initialize with your preferred provider
|
|
28
|
+
client = RoovyClient(
|
|
29
|
+
api_key="your-api-key",
|
|
30
|
+
base_url="https://api.openai.com/v1", # or any OpenAI-compatible endpoint
|
|
31
|
+
model="gpt-4o",
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# Generate a WhatsApp Flow from natural language
|
|
35
|
+
flow = client.generate(
|
|
36
|
+
"Create a customer feedback form with name, email, rating (1-5 stars), and comments"
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# Access the validated flow
|
|
40
|
+
print(flow.model_dump_json(indent=2, by_alias=True))
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
### Using Environment Variables
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import os
|
|
49
|
+
from roovy_sdk import RoovyClient
|
|
50
|
+
|
|
51
|
+
# Set environment variables
|
|
52
|
+
os.environ["ROOVY_API_KEY"] = "your-api-key"
|
|
53
|
+
os.environ["ROOVY_BASE_URL"] = "https://api.openai.com/v1"
|
|
54
|
+
os.environ["ROOVY_MODEL"] = "gpt-4o"
|
|
55
|
+
|
|
56
|
+
# Client will use environment variables automatically
|
|
57
|
+
client = RoovyClient()
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Provider Examples
|
|
61
|
+
|
|
62
|
+
**OpenAI:**
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
client = RoovyClient(
|
|
66
|
+
api_key="sk-...",
|
|
67
|
+
base_url="https://api.openai.com/v1",
|
|
68
|
+
model="gpt-4o",
|
|
69
|
+
)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Groq:**
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
client = RoovyClient(
|
|
76
|
+
api_key="gsk_...",
|
|
77
|
+
base_url="https://api.groq.com/openai/v1",
|
|
78
|
+
model="llama-3.3-70b-versatile",
|
|
79
|
+
)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Ollama (local):**
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
client = RoovyClient(
|
|
86
|
+
api_key="ollama", # any non-empty string
|
|
87
|
+
base_url="http://localhost:11434/v1",
|
|
88
|
+
model="llama3.2",
|
|
89
|
+
)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Advanced Usage
|
|
93
|
+
|
|
94
|
+
### Streaming Generation
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
def on_chunk(chunk: str):
|
|
98
|
+
print(chunk, end="", flush=True)
|
|
99
|
+
|
|
100
|
+
flow = client.generate_stream(
|
|
101
|
+
"Create a booking form for a concert",
|
|
102
|
+
on_chunk=on_chunk,
|
|
103
|
+
)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Custom Retry Settings
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
flow = client.generate(
|
|
110
|
+
"Create a survey form",
|
|
111
|
+
max_retries=5,
|
|
112
|
+
temperature=0.3,
|
|
113
|
+
)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Custom System Prompt
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
flow = client.generate(
|
|
120
|
+
"Create a registration form",
|
|
121
|
+
system_prompt="You are a WhatsApp Flows expert...",
|
|
122
|
+
)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Direct Schema Access
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from roovy_sdk.schema import (
|
|
129
|
+
WhatsAppFlow,
|
|
130
|
+
Screen,
|
|
131
|
+
TextInput,
|
|
132
|
+
Footer,
|
|
133
|
+
validate_flow,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
# Build flows programmatically
|
|
137
|
+
screen = Screen(
|
|
138
|
+
id="WELCOME",
|
|
139
|
+
title="Welcome",
|
|
140
|
+
layout=SingleColumnLayout(
|
|
141
|
+
type="SingleColumnLayout",
|
|
142
|
+
children=[
|
|
143
|
+
TextHeading(type="TextHeading", text="Hello!"),
|
|
144
|
+
]
|
|
145
|
+
)
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
# Validate any JSON against the schema
|
|
149
|
+
result = validate_flow({"version": "7.2", "screens": [...]})
|
|
150
|
+
if result["success"]:
|
|
151
|
+
flow = result["data"]
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Schema Reference
|
|
155
|
+
|
|
156
|
+
The SDK includes complete Pydantic models for all WhatsApp Flow components:
|
|
157
|
+
|
|
158
|
+
### Text Components
|
|
159
|
+
|
|
160
|
+
- `TextHeading` - Main headings
|
|
161
|
+
- `TextSubheading` - Subheadings
|
|
162
|
+
- `TextBody` - Body text
|
|
163
|
+
- `TextCaption` - Small captions
|
|
164
|
+
|
|
165
|
+
### Input Components
|
|
166
|
+
|
|
167
|
+
- `TextInput` - Single-line text input
|
|
168
|
+
- `TextArea` - Multi-line text input
|
|
169
|
+
- `Dropdown` - Dropdown selector
|
|
170
|
+
- `RadioButtonsGroup` - Radio button selection
|
|
171
|
+
- `ChipsSelector` - Multi-select chips
|
|
172
|
+
- `CheckboxGroup` - Checkbox group
|
|
173
|
+
- `OptIn` - Opt-in checkbox
|
|
174
|
+
|
|
175
|
+
### Date/Media Components
|
|
176
|
+
|
|
177
|
+
- `CalendarPicker` - Calendar date picker
|
|
178
|
+
- `DatePicker` - Simple date picker
|
|
179
|
+
- `PhotoPicker` - Photo upload
|
|
180
|
+
- `DocumentPicker` - Document upload
|
|
181
|
+
- `Image` - Display images
|
|
182
|
+
|
|
183
|
+
### Navigation Components
|
|
184
|
+
|
|
185
|
+
- `Footer` - Screen footer with action
|
|
186
|
+
- `Button` - Action button
|
|
187
|
+
- `EmbeddedLink` - Inline link
|
|
188
|
+
|
|
189
|
+
### Conditional Components
|
|
190
|
+
|
|
191
|
+
- `If` - Conditional rendering
|
|
192
|
+
- `Switch` - Switch/case rendering
|
|
193
|
+
|
|
194
|
+
### Container Components
|
|
195
|
+
|
|
196
|
+
- `Form` - Form container
|
|
197
|
+
- `SingleColumnLayout` - Screen layout
|
|
198
|
+
|
|
199
|
+
## API Reference
|
|
200
|
+
|
|
201
|
+
### `RoovyClient`
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
RoovyClient(
|
|
205
|
+
api_key: str | None = None, # API key (or ROOVY_API_KEY env var)
|
|
206
|
+
base_url: str | None = None, # Base URL (or ROOVY_BASE_URL env var)
|
|
207
|
+
model: str | None = None, # Model name (or ROOVY_MODEL env var)
|
|
208
|
+
)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### `client.generate()`
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
client.generate(
|
|
215
|
+
prompt: str, # Natural language description
|
|
216
|
+
*,
|
|
217
|
+
max_retries: int = 3, # Number of retry attempts
|
|
218
|
+
temperature: float = 0.2, # LLM temperature
|
|
219
|
+
system_prompt: str | None = None, # Custom system prompt
|
|
220
|
+
) -> WhatsAppFlow
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### `client.generate_stream()`
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
client.generate_stream(
|
|
227
|
+
prompt: str, # Natural language description
|
|
228
|
+
on_chunk: Callable[[str], None] | None = None, # Chunk callback
|
|
229
|
+
*,
|
|
230
|
+
temperature: float = 0.2, # LLM temperature
|
|
231
|
+
system_prompt: str | None = None, # Custom system prompt
|
|
232
|
+
) -> WhatsAppFlow
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### `validate_flow()`
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
from roovy_sdk import validate_flow
|
|
239
|
+
|
|
240
|
+
result = validate_flow(flow_dict)
|
|
241
|
+
# Returns: {"success": True, "data": WhatsAppFlow} or {"success": False, "error": ValidationError}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "roovy-sdk"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python SDK for generating WhatsApp Flows using LLMs"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Yash Desai", email = "contact@yashddesai.com" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"whatsapp",
|
|
17
|
+
"whatsapp-flows",
|
|
18
|
+
"llm",
|
|
19
|
+
"ai",
|
|
20
|
+
"chatbot",
|
|
21
|
+
"meta",
|
|
22
|
+
"openai",
|
|
23
|
+
]
|
|
24
|
+
classifiers = [
|
|
25
|
+
"Development Status :: 4 - Beta",
|
|
26
|
+
"Intended Audience :: Developers",
|
|
27
|
+
"License :: OSI Approved :: MIT License",
|
|
28
|
+
"Operating System :: OS Independent",
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Programming Language :: Python :: 3.9",
|
|
31
|
+
"Programming Language :: Python :: 3.10",
|
|
32
|
+
"Programming Language :: Python :: 3.11",
|
|
33
|
+
"Programming Language :: Python :: 3.12",
|
|
34
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
35
|
+
"Typing :: Typed",
|
|
36
|
+
]
|
|
37
|
+
dependencies = [
|
|
38
|
+
"openai>=1.0.0",
|
|
39
|
+
"pydantic>=2.0.0",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[project.optional-dependencies]
|
|
43
|
+
dev = [
|
|
44
|
+
"pytest>=7.0.0",
|
|
45
|
+
"pytest-asyncio>=0.21.0",
|
|
46
|
+
"ruff>=0.1.0",
|
|
47
|
+
"mypy>=1.0.0",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
Homepage = "https://github.com/yashdesai/roovy-sdk"
|
|
52
|
+
Documentation = "https://github.com/yashdesai/roovy-sdk#readme"
|
|
53
|
+
Repository = "https://github.com/yashdesai/roovy-sdk"
|
|
54
|
+
Issues = "https://github.com/yashdesai/roovy-sdk/issues"
|
|
55
|
+
|
|
56
|
+
[tool.hatch.build.targets.wheel]
|
|
57
|
+
packages = ["src/roovy_sdk"]
|
|
58
|
+
|
|
59
|
+
[tool.hatch.build.targets.sdist]
|
|
60
|
+
include = [
|
|
61
|
+
"/src",
|
|
62
|
+
"/README.md",
|
|
63
|
+
"/LICENSE",
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
[tool.ruff]
|
|
67
|
+
line-length = 88
|
|
68
|
+
target-version = "py39"
|
|
69
|
+
|
|
70
|
+
[tool.ruff.lint]
|
|
71
|
+
select = ["E", "F", "I", "N", "W", "UP"]
|
|
72
|
+
|
|
73
|
+
[tool.mypy]
|
|
74
|
+
python_version = "3.9"
|
|
75
|
+
strict = true
|
|
76
|
+
warn_return_any = true
|
|
77
|
+
warn_unused_ignores = true
|