soprano-sdk 0.1.92__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.
@@ -0,0 +1,419 @@
1
+ Metadata-Version: 2.4
2
+ Name: soprano-sdk
3
+ Version: 0.1.92
4
+ Summary: YAML-driven workflow engine with AI agent integration for building conversational SOPs
5
+ Author: Arvind Thangamani
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Keywords: agent,ai,conversational,langgraph,sop,soprano,workflow
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Requires-Python: >=3.12
15
+ Requires-Dist: agno>=2.0.7
16
+ Requires-Dist: crewai>=0.186.1
17
+ Requires-Dist: jsonschema>=4.0.0
18
+ Requires-Dist: langchain-community>=0.4.1
19
+ Requires-Dist: langchain-core>=0.3.67
20
+ Requires-Dist: langchain-openai>=1.0.3
21
+ Requires-Dist: langchain>=1.0.7
22
+ Requires-Dist: langfuse>=3.10.1
23
+ Requires-Dist: langgraph==1.0.2
24
+ Requires-Dist: openai>=1.92.1
25
+ Requires-Dist: pydantic-ai>=1.22.0
26
+ Requires-Dist: pydantic>=2.0.0
27
+ Requires-Dist: pyyaml>=6.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: gradio>=5.46.0; extra == 'dev'
30
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
31
+ Provides-Extra: persistence
32
+ Requires-Dist: langgraph-checkpoint-mongodb>=0.2.0; extra == 'persistence'
33
+ Requires-Dist: pymongo>=4.0.0; extra == 'persistence'
34
+ Provides-Extra: supervisors
35
+ Requires-Dist: crewai>=0.1.0; extra == 'supervisors'
36
+ Requires-Dist: langchain-openai>=0.3.34; extra == 'supervisors'
37
+ Description-Content-Type: text/markdown
38
+
39
+ # Conversational SOP Framework
40
+
41
+ A YAML-driven workflow engine with AI agent integration for building conversational Standard Operating Procedures (SOPs).
42
+
43
+ ## Features
44
+
45
+ - **YAML Configuration**: Define workflows declaratively using YAML
46
+ - **AI Agent Integration**: Built-in support for conversational data collection using OpenAI models
47
+ - **State Management**: Powered by LangGraph for robust workflow execution
48
+ - **External Context Injection**: Support for pre-populated fields from external orchestrators
49
+ - **Pattern Matching**: Flexible transition logic based on patterns and conditions
50
+ - **Visualization**: Generate workflow graphs as images or Mermaid diagrams
51
+
52
+ ## Installation
53
+
54
+ ```bash
55
+ pip install conversational-sop-framework
56
+ ```
57
+
58
+ Or using uv:
59
+
60
+ ```bash
61
+ uv add conversational-sop-framework
62
+ ```
63
+
64
+ ## Quick Start
65
+
66
+ ### 1. Define a Workflow in YAML
67
+
68
+ ```yaml
69
+ name: "User Greeting Workflow"
70
+ description: "Collects user information and provides a personalized greeting"
71
+ version: "1.0"
72
+
73
+ data:
74
+ - name: name
75
+ type: text
76
+ description: "User's name"
77
+ - name: age
78
+ type: number
79
+ description: "User's age in years"
80
+
81
+ steps:
82
+ - id: get_name
83
+ action: collect_input_with_agent
84
+ field: name
85
+ max_attempts: 3
86
+ agent:
87
+ name: "NameCollector"
88
+ model: "gpt-4o-mini"
89
+ instructions: |
90
+ Your goal is to capture the user's name.
91
+ Start with a friendly greeting and ask for their name.
92
+ Once you have a clear name, respond with: 'NAME_CAPTURED: [name]'
93
+ transitions:
94
+ - pattern: "NAME_CAPTURED:"
95
+ next: get_age
96
+ - pattern: "NAME_FAILED:"
97
+ next: end_failed
98
+
99
+ - id: get_age
100
+ action: collect_input_with_agent
101
+ field: age
102
+ max_attempts: 3
103
+ agent:
104
+ name: "AgeCollector"
105
+ model: "gpt-4o-mini"
106
+ instructions: |
107
+ Ask for the user's age.
108
+ Once you have a valid age, respond with: 'AGE_CAPTURED: [age]'
109
+ transitions:
110
+ - pattern: "AGE_CAPTURED:"
111
+ next: end_success
112
+ - pattern: "AGE_FAILED:"
113
+ next: end_failed
114
+
115
+ outcomes:
116
+ - id: end_success
117
+ type: success
118
+ message: "Hello {name}! You are {age} years old."
119
+
120
+ - id: end_failed
121
+ type: failure
122
+ message: "Sorry, I couldn't complete the workflow."
123
+ ```
124
+
125
+ ### 2. Load and Execute the Workflow
126
+
127
+ ```python
128
+ from conversational_sop import load_workflow
129
+ from langgraph.types import Command
130
+ import uuid
131
+
132
+ # Load workflow
133
+ graph, engine = load_workflow("greeting_workflow.yaml")
134
+
135
+ # Setup execution
136
+ thread_id = str(uuid.uuid4())
137
+ config = {"configurable": {"thread_id": thread_id}}
138
+
139
+ # Start workflow
140
+ result = graph.invoke({}, config=config)
141
+
142
+ # Interaction loop
143
+ while True:
144
+ if "__interrupt__" in result and result["__interrupt__"]:
145
+ # Get prompt from workflow
146
+ prompt = result["__interrupt__"][0].value
147
+ print(f"Bot: {prompt}")
148
+
149
+ # Get user input
150
+ user_input = input("You: ")
151
+
152
+ # Resume workflow with user input
153
+ result = graph.invoke(Command(resume=user_input), config=config)
154
+ else:
155
+ # Workflow completed
156
+ message = engine.get_outcome_message(result)
157
+ print(f"Bot: {message}")
158
+ break
159
+ ```
160
+
161
+ ### 3. External Context Injection
162
+
163
+ You can inject external context into workflows:
164
+
165
+ ```python
166
+ # Pre-populate fields from external orchestrator
167
+ result = graph.invoke({
168
+ "name": "Alice",
169
+ "age": 30
170
+ }, config=config)
171
+
172
+ # Workflow will automatically skip collection steps
173
+ # and proceed to validation/processing
174
+ ```
175
+
176
+ ### 4. Persistence
177
+
178
+ The library supports pluggable persistence through LangGraph's checkpointer system.
179
+
180
+ #### In-Memory (Default)
181
+
182
+ ```python
183
+ # No persistence - state lost when process ends
184
+ graph, engine = load_workflow("workflow.yaml")
185
+ ```
186
+
187
+ #### MongoDB Persistence
188
+
189
+ ```python
190
+ from conversational_sop import load_workflow
191
+ from langgraph.checkpoint.mongodb import MongoDBSaver
192
+ from pymongo import MongoClient
193
+
194
+ # Setup MongoDB persistence (local)
195
+ client = MongoClient("mongodb://localhost:27017")
196
+ checkpointer = MongoDBSaver(client=client, db_name="workflows")
197
+
198
+ # Or MongoDB Atlas (cloud)
199
+ client = MongoClient("mongodb+srv://user:pass@cluster.mongodb.net")
200
+ checkpointer = MongoDBSaver(client=client, db_name="workflows")
201
+
202
+ # Load workflow with persistence
203
+ graph, engine = load_workflow("workflow.yaml", checkpointer=checkpointer)
204
+
205
+ # Execute with thread_id for state tracking
206
+ config = {"configurable": {"thread_id": "user-123-return"}}
207
+ result = graph.invoke({}, config=config)
208
+
209
+ # Later, resume using same thread_id
210
+ result = graph.invoke(Command(resume="continue"), config=config)
211
+ ```
212
+
213
+ #### Thread ID Strategies
214
+
215
+ Choose a thread_id strategy based on your use case:
216
+
217
+ | Strategy | Thread ID Pattern | Best For |
218
+ |----------|-------------------|----------|
219
+ | **Entity-Based** | `f"return_{order_id}"` | One workflow per business entity |
220
+ | **Conversation** | `str(uuid.uuid4())` | Multiple concurrent workflows |
221
+ | **User+Workflow** | `f"{user_id}_{workflow_type}"` | One workflow type per user |
222
+ | **Session-Based** | `session_id` | Web apps with sessions |
223
+
224
+ **Examples**: See `examples/persistence/` for detailed examples of each strategy.
225
+
226
+ ## Workflow Actions
227
+
228
+ ### collect_input_with_agent
229
+
230
+ Collects user input using an AI agent with conversation history.
231
+
232
+ ```yaml
233
+ - id: collect_field
234
+ action: collect_input_with_agent
235
+ field: field_name
236
+ max_attempts: 5
237
+ agent:
238
+ name: "CollectorAgent"
239
+ model: "gpt-4o-mini"
240
+ instructions: |
241
+ Instructions for the agent...
242
+ transitions:
243
+ - pattern: "SUCCESS:"
244
+ next: next_step
245
+ - pattern: "FAILED:"
246
+ next: failure_outcome
247
+ ```
248
+
249
+ ### call_function
250
+
251
+ Calls a Python function with workflow state.
252
+
253
+ ```yaml
254
+ - id: process_data
255
+ action: call_function
256
+ function: "my_module.my_function"
257
+ inputs:
258
+ field1: "{field_name}"
259
+ field2: "static_value"
260
+ output: result_field
261
+ transitions:
262
+ - condition: true
263
+ next: success_step
264
+ - condition: false
265
+ next: failure_step
266
+ ```
267
+
268
+ ## Examples
269
+
270
+ See the `examples/` directory for complete workflow examples:
271
+
272
+ - `greeting_workflow.yaml` - Simple user greeting workflow
273
+ - `return_workflow.yaml` - Customer return processing workflow
274
+ - Function modules with business logic (`greeting_functions.py`, `return_functions.py`)
275
+ - `persistence/` - Persistence strategy examples (entity-based, conversation-based, SQLite demo)
276
+
277
+ ## Running Workflows
278
+
279
+ ### CLI Demo
280
+
281
+ ```bash
282
+ # Basic usage (in-memory)
283
+ python scripts/workflow_demo.py examples/greeting_workflow.yaml
284
+
285
+ # With MongoDB persistence (local)
286
+ python scripts/workflow_demo.py examples/greeting_workflow.yaml --mongodb mongodb://localhost:27017
287
+
288
+ # Resume existing workflow
289
+ python scripts/workflow_demo.py examples/greeting_workflow.yaml --mongodb mongodb://localhost:27017 --thread-id abc-123
290
+
291
+ # With MongoDB Atlas
292
+ python scripts/workflow_demo.py examples/greeting_workflow.yaml --mongodb mongodb+srv://user:pass@cluster.mongodb.net
293
+ ```
294
+
295
+ ### Gradio UI
296
+
297
+ ```bash
298
+ # Basic usage (in-memory)
299
+ python scripts/workflow_demo_ui.py examples/greeting_workflow.yaml
300
+
301
+ # With MongoDB persistence
302
+ python scripts/workflow_demo_ui.py examples/greeting_workflow.yaml --mongodb mongodb://localhost:27017
303
+
304
+ # With MongoDB Atlas
305
+ python scripts/workflow_demo_ui.py examples/greeting_workflow.yaml --mongodb mongodb+srv://user:pass@cluster.mongodb.net
306
+ ```
307
+
308
+ ### Persistence Examples
309
+
310
+ ```bash
311
+ cd examples/persistence
312
+
313
+ # Entity-based (order ID as thread ID)
314
+ python entity_based.py ORDER-123
315
+
316
+ # Conversation-based (UUID with supervisor pattern)
317
+ python conversation_based.py ../return_workflow.yaml --order-id ORDER-456
318
+
319
+ # MongoDB demo with pause/resume
320
+ python mongodb_demo.py
321
+
322
+ # Use MongoDB Atlas
323
+ python mongodb_demo.py --mongodb mongodb+srv://user:pass@cluster.mongodb.net
324
+ ```
325
+
326
+ ### Visualize Workflow
327
+
328
+ ```bash
329
+ python scripts/visualize_workflow.py examples/greeting_workflow.yaml
330
+ ```
331
+
332
+ ## Development
333
+
334
+ ### Setup
335
+
336
+ ```bash
337
+ git clone https://github.com/dnivra26/conversational_sop_framework.git
338
+ cd conversational_sop_framework
339
+ uv sync --dev
340
+ ```
341
+
342
+ ### Run Tests
343
+
344
+ ```bash
345
+ python tests/test_external_values.py
346
+ ```
347
+
348
+ ## Architecture
349
+
350
+ - **conversational_sop/**: Core library package
351
+ - `engine.py`: Workflow engine implementation
352
+ - `__init__.py`: Public API exports
353
+
354
+ - **examples/**: Example workflows and persistence patterns
355
+ - Workflow YAML definitions
356
+ - Function modules with business logic
357
+ - `persistence/`: Different persistence strategy examples
358
+
359
+ - **scripts/**: Utility tools for running and visualizing workflows
360
+ - `workflow_demo.py`: CLI runner with persistence support
361
+ - `workflow_demo_ui.py`: Gradio UI with thread management
362
+ - `visualize_workflow.py`: Workflow graph generator
363
+
364
+ - **tests/**: Test suite
365
+ - **legacy/**: Previous implementations (FSM, direct LangGraph)
366
+
367
+ ## Requirements
368
+
369
+ ### Core Dependencies
370
+
371
+ - Python >= 3.12
372
+ - agno >= 2.0.7
373
+ - langgraph >= 0.6.8
374
+ - openai >= 1.108.1
375
+ - pyyaml >= 6.0
376
+
377
+ ### Optional Dependencies
378
+
379
+ For MongoDB persistence:
380
+ ```bash
381
+ # Using pip
382
+ pip install langgraph-checkpoint-mongodb pymongo
383
+
384
+ # Using uv (recommended)
385
+ uv add langgraph-checkpoint-mongodb pymongo --optional persistence
386
+
387
+ # Or install library with persistence support
388
+ pip install conversational-sop-framework[persistence]
389
+ ```
390
+
391
+ For development (includes Gradio UI and tests):
392
+ ```bash
393
+ pip install conversational-sop-framework[dev]
394
+ # or
395
+ uv sync --dev
396
+ ```
397
+
398
+ ## License
399
+
400
+ MIT
401
+
402
+ ## Contributing
403
+
404
+ Contributions are welcome! Please open an issue or submit a pull request.
405
+
406
+ ## To Do
407
+
408
+ - ✅ Database persistence (SqliteSaver, PostgresSaver supported)
409
+ - ✅ Pluggable checkpointer system
410
+ - ✅ Thread ID strategies and examples
411
+ - Additional action types (webhook, conditional branching, parallel execution)
412
+ - More workflow examples (customer onboarding, support ticketing, approval flows)
413
+ - Workflow testing utilities
414
+ - Metrics and monitoring hooks
415
+
416
+ ## Links
417
+
418
+ - [GitHub Repository](https://github.com/dnivra26/conversational_sop_framework)
419
+ - [Issues](https://github.com/dnivra26/conversational_sop_framework/issues)
@@ -0,0 +1,4 @@
1
+ soprano_sdk-0.1.92.dist-info/METADATA,sha256=M7Qd_OCp1HwILC72i4YuGrQT4V4aowwEOtSLHM_lAxQ,11318
2
+ soprano_sdk-0.1.92.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
3
+ soprano_sdk-0.1.92.dist-info/licenses/LICENSE,sha256=A1aBauSjPNtVehOXJe3WuvdU2xvM9H8XmigFMm6665s,1073
4
+ soprano_sdk-0.1.92.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Arvind Thangamani
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.