tuner-pipecat-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.
- tuner_pipecat_sdk-0.1.0/.github/workflows/ci.yml +31 -0
- tuner_pipecat_sdk-0.1.0/.gitignore +15 -0
- tuner_pipecat_sdk-0.1.0/LICENSE +21 -0
- tuner_pipecat_sdk-0.1.0/PKG-INFO +174 -0
- tuner_pipecat_sdk-0.1.0/README.md +107 -0
- tuner_pipecat_sdk-0.1.0/docs/api.md +47 -0
- tuner_pipecat_sdk-0.1.0/docs/getting-started.md +102 -0
- tuner_pipecat_sdk-0.1.0/docs/integration.md +37 -0
- tuner_pipecat_sdk-0.1.0/examples/README.md +56 -0
- tuner_pipecat_sdk-0.1.0/examples/appointment_booking/.env.example +12 -0
- tuner_pipecat_sdk-0.1.0/examples/appointment_booking/README.md +67 -0
- tuner_pipecat_sdk-0.1.0/examples/appointment_booking/appointment_booking.py +462 -0
- tuner_pipecat_sdk-0.1.0/examples/appointment_booking/pyproject.toml +13 -0
- tuner_pipecat_sdk-0.1.0/examples/appointment_booking/uv.lock +3622 -0
- tuner_pipecat_sdk-0.1.0/examples/customer_support/.env.example +12 -0
- tuner_pipecat_sdk-0.1.0/examples/customer_support/README.md +64 -0
- tuner_pipecat_sdk-0.1.0/examples/customer_support/customer_support.py +398 -0
- tuner_pipecat_sdk-0.1.0/examples/customer_support/pyproject.toml +13 -0
- tuner_pipecat_sdk-0.1.0/examples/customer_support/uv.lock +3622 -0
- tuner_pipecat_sdk-0.1.0/examples/pizza_order/.env.example +12 -0
- tuner_pipecat_sdk-0.1.0/examples/pizza_order/README.md +68 -0
- tuner_pipecat_sdk-0.1.0/examples/pizza_order/pizza_order.py +340 -0
- tuner_pipecat_sdk-0.1.0/examples/pizza_order/pyproject.toml +13 -0
- tuner_pipecat_sdk-0.1.0/examples/pizza_order/uv.lock +3629 -0
- tuner_pipecat_sdk-0.1.0/pyproject.toml +113 -0
- tuner_pipecat_sdk-0.1.0/setup_guide.md +60 -0
- tuner_pipecat_sdk-0.1.0/src/tuner_pipecat_sdk/__init__.py +20 -0
- tuner_pipecat_sdk-0.1.0/src/tuner_pipecat_sdk/accumulator.py +303 -0
- tuner_pipecat_sdk-0.1.0/src/tuner_pipecat_sdk/client.py +66 -0
- tuner_pipecat_sdk-0.1.0/src/tuner_pipecat_sdk/config.py +31 -0
- tuner_pipecat_sdk-0.1.0/src/tuner_pipecat_sdk/models.py +118 -0
- tuner_pipecat_sdk-0.1.0/src/tuner_pipecat_sdk/observer.py +163 -0
- tuner_pipecat_sdk-0.1.0/src/tuner_pipecat_sdk/payload_builder.py +53 -0
- tuner_pipecat_sdk-0.1.0/src/tuner_pipecat_sdk/py.typed +1 -0
- tuner_pipecat_sdk-0.1.0/src/tuner_pipecat_sdk/tool_timing_registry.py +23 -0
- tuner_pipecat_sdk-0.1.0/src/tuner_pipecat_sdk/transcript_enricher.py +368 -0
- tuner_pipecat_sdk-0.1.0/tests/__init__.py +1 -0
- tuner_pipecat_sdk-0.1.0/tests/conftest.py +34 -0
- tuner_pipecat_sdk-0.1.0/tests/test_accumulator_frames.py +238 -0
- tuner_pipecat_sdk-0.1.0/tests/test_accumulator_payload.py +205 -0
- tuner_pipecat_sdk-0.1.0/tests/test_accumulator_timing.py +54 -0
- tuner_pipecat_sdk-0.1.0/tests/test_accumulator_transcript.py +355 -0
- tuner_pipecat_sdk-0.1.0/tests/test_client.py +109 -0
- tuner_pipecat_sdk-0.1.0/tests/test_config.py +91 -0
- tuner_pipecat_sdk-0.1.0/tests/test_flow_integration.py +126 -0
- tuner_pipecat_sdk-0.1.0/tests/test_metrics_frame.py +89 -0
- tuner_pipecat_sdk-0.1.0/tests/test_models.py +226 -0
- tuner_pipecat_sdk-0.1.0/tests/test_observer.py +195 -0
- tuner_pipecat_sdk-0.1.0/uv.lock +3040 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
name: Run tests
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v5
|
|
21
|
+
with:
|
|
22
|
+
enable-cache: true
|
|
23
|
+
|
|
24
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
25
|
+
run: uv python install ${{ matrix.python-version }}
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: uv sync --extra test
|
|
29
|
+
|
|
30
|
+
- name: Run tests
|
|
31
|
+
run: uv run pytest
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tuner Team
|
|
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.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tuner-pipecat-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pipecat FrameProcessor that observes pipecat-flows calls and sends structured data to the Tuner API.
|
|
5
|
+
Project-URL: Homepage, https://github.com/usetuner/tuner-pipecat-sdk-python
|
|
6
|
+
Project-URL: Documentation, https://github.com/usetuner/tuner-pipecat-sdk-python/tree/main/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/usetuner/tuner-pipecat-sdk-python
|
|
8
|
+
Project-URL: Issues, https://github.com/usetuner/tuner-pipecat-sdk-python/issues
|
|
9
|
+
Author: Tuner Team
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 Tuner Team
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Keywords: agent,observability,pipecat,sdk,voice
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
41
|
+
Classifier: Typing :: Typed
|
|
42
|
+
Requires-Python: <3.14,>=3.10
|
|
43
|
+
Requires-Dist: httpx>=0.27
|
|
44
|
+
Requires-Dist: loguru~=0.7.2
|
|
45
|
+
Requires-Dist: pipecat-ai>=0.0.105
|
|
46
|
+
Requires-Dist: pydantic>=2.0
|
|
47
|
+
Provides-Extra: dev
|
|
48
|
+
Requires-Dist: hatch>=1.12; extra == 'dev'
|
|
49
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
50
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
|
|
51
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
52
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
53
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
54
|
+
Requires-Dist: twine>=5.0; extra == 'dev'
|
|
55
|
+
Provides-Extra: lint
|
|
56
|
+
Requires-Dist: ruff>=0.6; extra == 'lint'
|
|
57
|
+
Provides-Extra: publish
|
|
58
|
+
Requires-Dist: hatch>=1.12; extra == 'publish'
|
|
59
|
+
Requires-Dist: twine>=5.0; extra == 'publish'
|
|
60
|
+
Provides-Extra: test
|
|
61
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'test'
|
|
62
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'test'
|
|
63
|
+
Requires-Dist: pytest>=8.0; extra == 'test'
|
|
64
|
+
Provides-Extra: type
|
|
65
|
+
Requires-Dist: mypy>=1.10; extra == 'type'
|
|
66
|
+
Description-Content-Type: text/markdown
|
|
67
|
+
|
|
68
|
+
# tuner-pipecat-sdk
|
|
69
|
+
|
|
70
|
+
`tuner-pipecat-sdk` is a lightweight observer SDK for [`pipecat-flows`](https://github.com/pipecat-ai/pipecat-flows).
|
|
71
|
+
It captures flow transitions, latency signals, transcript segments, and usage metadata,
|
|
72
|
+
then sends a structured `CallPayload` to the Tuner API when a call ends.
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## Requirements
|
|
77
|
+
|
|
78
|
+
- Python **3.10–3.13**.
|
|
79
|
+
- **Do not use Python 3.14** for installs yet: Pipecat pulls **`onnxruntime~=1.23.2`** and **`numba`** without 3.14 wheels → errors like *No matching distribution found for onnxruntime*.
|
|
80
|
+
- This SDK depends on **`pipecat-ai>=0.0.105`**.
|
|
81
|
+
|
|
82
|
+
## Installation
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pip install tuner-pipecat-sdk
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
## Quick Start Example
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
import uuid
|
|
93
|
+
from tuner_pipecat_sdk import FlowsObserver
|
|
94
|
+
|
|
95
|
+
observer = FlowsObserver(
|
|
96
|
+
api_key="YOUR_TUNER_API_KEY",
|
|
97
|
+
workspace_id=42,
|
|
98
|
+
agent_id="my-agent",
|
|
99
|
+
call_id=str(uuid.uuid4()),
|
|
100
|
+
base_url="https://app.usetuner.ai",
|
|
101
|
+
asr_model="deepgram/nova-3",
|
|
102
|
+
llm_model="gpt-4o-mini",
|
|
103
|
+
tts_model="cartesia/sonic",
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# Required: attach the flow manager before running the pipeline
|
|
107
|
+
observer.attach_flow_manager(flow_manager)
|
|
108
|
+
observer.attach_turn_tracking_observer(turn_tracker)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
Place the observer after TTS in your pipeline:
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
Pipeline([
|
|
116
|
+
transport.input(),
|
|
117
|
+
stt,
|
|
118
|
+
context_aggregator.user(),
|
|
119
|
+
llm,
|
|
120
|
+
tts,
|
|
121
|
+
observer,
|
|
122
|
+
transport.output(),
|
|
123
|
+
context_aggregator.assistant(),
|
|
124
|
+
])
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Enable metrics on the pipeline task so latency and usage fields are populated:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from pipecat.pipeline.task import PipelineTask
|
|
131
|
+
from pipecat.pipeline.pipeline_params import PipelineParams
|
|
132
|
+
from pipecat.observers.turn_tracking_observer import TurnTrackingObserver
|
|
133
|
+
|
|
134
|
+
turn_tracker = TurnTrackingObserver()
|
|
135
|
+
|
|
136
|
+
task = PipelineTask(
|
|
137
|
+
pipeline,
|
|
138
|
+
params=PipelineParams(
|
|
139
|
+
observers=[observer.latency_observer, turn_tracker],
|
|
140
|
+
enable_metrics=True,
|
|
141
|
+
enable_usage_metrics=True,
|
|
142
|
+
),
|
|
143
|
+
)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Without these flags the observer will log warnings and LLM/TTS metric fields will be absent from the payload.
|
|
147
|
+
For more example check https://github.com/usetuner/tuner-pipecat-sdk-python/tree/main/examples
|
|
148
|
+
|
|
149
|
+
## FlowsObserver Parameters
|
|
150
|
+
|
|
151
|
+
| Parameter | Type | Default | Description |
|
|
152
|
+
|-----------|------|---------|-------------|
|
|
153
|
+
| `api_key` | `str` | — | Tuner API key |
|
|
154
|
+
| `workspace_id` | `int` | — | Tuner workspace ID |
|
|
155
|
+
| `agent_id` | `str` | — | Agent identifier |
|
|
156
|
+
| `call_id` | `str` | — | Unique call ID (use `uuid4()`) |
|
|
157
|
+
| `base_url` | `str` | `http://localhost:8000` | Tuner API base URL |
|
|
158
|
+
| `call_type` | `str` | `"web_call"` | Call type label |
|
|
159
|
+
| `recording_url` | `str` | `"pipecat://no-recording"` | Recording URL if available |
|
|
160
|
+
| `asr_model` | `str` | `""` | ASR model name (e.g. `deepgram/nova-3`) |
|
|
161
|
+
| `llm_model` | `str` | `""` | LLM model name (e.g. `gpt-4o-mini`) |
|
|
162
|
+
| `tts_model` | `str` | `""` | TTS model name (e.g. `cartesia/sonic`) |
|
|
163
|
+
| `debug` | `bool` | `False` | Log full transcript at flush |
|
|
164
|
+
|
|
165
|
+
## Public API
|
|
166
|
+
|
|
167
|
+
- `tuner_pipecat_sdk.FlowsObserver`
|
|
168
|
+
- `tuner_pipecat_sdk.TunerConfig`
|
|
169
|
+
|
|
170
|
+
Payload and transcript schemas are available under `tuner_pipecat_sdk.models`.
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
## To build the project
|
|
174
|
+
folow the steps in setup_guide.md
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# tuner-pipecat-sdk
|
|
2
|
+
|
|
3
|
+
`tuner-pipecat-sdk` is a lightweight observer SDK for [`pipecat-flows`](https://github.com/pipecat-ai/pipecat-flows).
|
|
4
|
+
It captures flow transitions, latency signals, transcript segments, and usage metadata,
|
|
5
|
+
then sends a structured `CallPayload` to the Tuner API when a call ends.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
- Python **3.10–3.13**.
|
|
12
|
+
- **Do not use Python 3.14** for installs yet: Pipecat pulls **`onnxruntime~=1.23.2`** and **`numba`** without 3.14 wheels → errors like *No matching distribution found for onnxruntime*.
|
|
13
|
+
- This SDK depends on **`pipecat-ai>=0.0.105`**.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install tuner-pipecat-sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## Quick Start Example
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
import uuid
|
|
26
|
+
from tuner_pipecat_sdk import FlowsObserver
|
|
27
|
+
|
|
28
|
+
observer = FlowsObserver(
|
|
29
|
+
api_key="YOUR_TUNER_API_KEY",
|
|
30
|
+
workspace_id=42,
|
|
31
|
+
agent_id="my-agent",
|
|
32
|
+
call_id=str(uuid.uuid4()),
|
|
33
|
+
base_url="https://app.usetuner.ai",
|
|
34
|
+
asr_model="deepgram/nova-3",
|
|
35
|
+
llm_model="gpt-4o-mini",
|
|
36
|
+
tts_model="cartesia/sonic",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# Required: attach the flow manager before running the pipeline
|
|
40
|
+
observer.attach_flow_manager(flow_manager)
|
|
41
|
+
observer.attach_turn_tracking_observer(turn_tracker)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
Place the observer after TTS in your pipeline:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
Pipeline([
|
|
49
|
+
transport.input(),
|
|
50
|
+
stt,
|
|
51
|
+
context_aggregator.user(),
|
|
52
|
+
llm,
|
|
53
|
+
tts,
|
|
54
|
+
observer,
|
|
55
|
+
transport.output(),
|
|
56
|
+
context_aggregator.assistant(),
|
|
57
|
+
])
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Enable metrics on the pipeline task so latency and usage fields are populated:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from pipecat.pipeline.task import PipelineTask
|
|
64
|
+
from pipecat.pipeline.pipeline_params import PipelineParams
|
|
65
|
+
from pipecat.observers.turn_tracking_observer import TurnTrackingObserver
|
|
66
|
+
|
|
67
|
+
turn_tracker = TurnTrackingObserver()
|
|
68
|
+
|
|
69
|
+
task = PipelineTask(
|
|
70
|
+
pipeline,
|
|
71
|
+
params=PipelineParams(
|
|
72
|
+
observers=[observer.latency_observer, turn_tracker],
|
|
73
|
+
enable_metrics=True,
|
|
74
|
+
enable_usage_metrics=True,
|
|
75
|
+
),
|
|
76
|
+
)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Without these flags the observer will log warnings and LLM/TTS metric fields will be absent from the payload.
|
|
80
|
+
For more example check https://github.com/usetuner/tuner-pipecat-sdk-python/tree/main/examples
|
|
81
|
+
|
|
82
|
+
## FlowsObserver Parameters
|
|
83
|
+
|
|
84
|
+
| Parameter | Type | Default | Description |
|
|
85
|
+
|-----------|------|---------|-------------|
|
|
86
|
+
| `api_key` | `str` | — | Tuner API key |
|
|
87
|
+
| `workspace_id` | `int` | — | Tuner workspace ID |
|
|
88
|
+
| `agent_id` | `str` | — | Agent identifier |
|
|
89
|
+
| `call_id` | `str` | — | Unique call ID (use `uuid4()`) |
|
|
90
|
+
| `base_url` | `str` | `http://localhost:8000` | Tuner API base URL |
|
|
91
|
+
| `call_type` | `str` | `"web_call"` | Call type label |
|
|
92
|
+
| `recording_url` | `str` | `"pipecat://no-recording"` | Recording URL if available |
|
|
93
|
+
| `asr_model` | `str` | `""` | ASR model name (e.g. `deepgram/nova-3`) |
|
|
94
|
+
| `llm_model` | `str` | `""` | LLM model name (e.g. `gpt-4o-mini`) |
|
|
95
|
+
| `tts_model` | `str` | `""` | TTS model name (e.g. `cartesia/sonic`) |
|
|
96
|
+
| `debug` | `bool` | `False` | Log full transcript at flush |
|
|
97
|
+
|
|
98
|
+
## Public API
|
|
99
|
+
|
|
100
|
+
- `tuner_pipecat_sdk.FlowsObserver`
|
|
101
|
+
- `tuner_pipecat_sdk.TunerConfig`
|
|
102
|
+
|
|
103
|
+
Payload and transcript schemas are available under `tuner_pipecat_sdk.models`.
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## To build the project
|
|
107
|
+
folow the steps in setup_guide.md
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
## `FlowsObserver`
|
|
4
|
+
|
|
5
|
+
`FlowsObserver` is a `FrameProcessor` that captures runtime signals and emits one payload per call.
|
|
6
|
+
|
|
7
|
+
Constructor:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
FlowsObserver(
|
|
11
|
+
api_key: str,
|
|
12
|
+
workspace_id: int,
|
|
13
|
+
agent_id: str,
|
|
14
|
+
call_id: str,
|
|
15
|
+
call_type: str = "web_call",
|
|
16
|
+
base_url: str = "http://localhost:8000",
|
|
17
|
+
recording_url: str = "pipecat://no-recording",
|
|
18
|
+
debug: bool = False,
|
|
19
|
+
asr_model: str = "",
|
|
20
|
+
llm_model: str = "",
|
|
21
|
+
tts_model: str = "",
|
|
22
|
+
)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Methods:
|
|
26
|
+
|
|
27
|
+
- `attach_flow_manager(flow_manager) -> None`
|
|
28
|
+
- `attach_turn_tracking_observer(turn_tracker) -> None`
|
|
29
|
+
- `latency_observer -> UserBotLatencyObserver`
|
|
30
|
+
|
|
31
|
+
## `TunerConfig`
|
|
32
|
+
|
|
33
|
+
Validated configuration model used by the observer and HTTP client.
|
|
34
|
+
|
|
35
|
+
Validation rules:
|
|
36
|
+
|
|
37
|
+
- `api_key`, `agent_id`, `call_id` must be non-empty.
|
|
38
|
+
- `workspace_id` must be a positive integer.
|
|
39
|
+
|
|
40
|
+
## Models
|
|
41
|
+
|
|
42
|
+
Public payload and transcript models are available via:
|
|
43
|
+
|
|
44
|
+
- `tuner_pipecat_sdk.models.CallPayload`
|
|
45
|
+
- `tuner_pipecat_sdk.models.TranscriptSegment`
|
|
46
|
+
- `tuner_pipecat_sdk.models.ToolInfo`
|
|
47
|
+
- `tuner_pipecat_sdk.models.NodeInfo`
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
## Requirements
|
|
4
|
+
|
|
5
|
+
- Python 3.10+
|
|
6
|
+
- A `pipecat` bot that uses `pipecat-flows`
|
|
7
|
+
- Tuner API credentials (`api_key`, `workspace_id`, `agent_id`)
|
|
8
|
+
|
|
9
|
+
## Pipecat app working directory
|
|
10
|
+
|
|
11
|
+
Run the pipeline from your **Pipecat application project root** (the app that creates the pipeline, adds `FlowsObserver`, and calls `PipelineTask`). That is the working directory (`pwd`) for the process that runs this SDK.
|
|
12
|
+
|
|
13
|
+
Example: if your app is at `/path/to/pipecat-app`, start your server or script from there:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cd /path/to/pipecat-app
|
|
17
|
+
python -m your_app.main
|
|
18
|
+
# or
|
|
19
|
+
uv run your_app
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Relative imports, config paths, and pipeline setup all resolve from this directory. The observer runs inside the pipeline process; it does not need a separate working directory.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install -e .
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Minimal Setup
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import uuid
|
|
34
|
+
from tuner_pipecat_sdk import FlowsObserver
|
|
35
|
+
|
|
36
|
+
observer = FlowsObserver(
|
|
37
|
+
api_key="YOUR_TUNER_API_KEY",
|
|
38
|
+
workspace_id=42,
|
|
39
|
+
agent_id="support-agent",
|
|
40
|
+
call_id=str(uuid.uuid4()),
|
|
41
|
+
base_url="https://your-tuner-api.example.com",
|
|
42
|
+
asr_model="deepgram/nova-3",
|
|
43
|
+
llm_model="gpt-4o-mini",
|
|
44
|
+
tts_model="cartesia/sonic",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
observer.attach_flow_manager(flow_manager)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Set `asr_model`, `llm_model`, and `tts_model` to populate
|
|
51
|
+
`general_meta_data_raw.ai_models` in the payload.
|
|
52
|
+
|
|
53
|
+
## Pipeline Placement
|
|
54
|
+
|
|
55
|
+
Put `FlowsObserver` after TTS and before transport output:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
Pipeline([
|
|
59
|
+
transport.input(),
|
|
60
|
+
stt,
|
|
61
|
+
context_aggregator.user(),
|
|
62
|
+
llm,
|
|
63
|
+
tts,
|
|
64
|
+
observer,
|
|
65
|
+
transport.output(),
|
|
66
|
+
context_aggregator.assistant(),
|
|
67
|
+
])
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Metrics from Pipecat (required for full payload)
|
|
71
|
+
|
|
72
|
+
The SDK reads **usage and latency from Pipecat only** (no fallback). Ensure the task is created with metrics enabled:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from pipecat.pipeline.task import PipelineTask
|
|
76
|
+
from pipecat.pipeline.pipeline_params import PipelineParams
|
|
77
|
+
from pipecat.observers.turn_tracking_observer import TurnTrackingObserver
|
|
78
|
+
|
|
79
|
+
turn_tracker = TurnTrackingObserver()
|
|
80
|
+
observer.attach_turn_tracking_observer(turn_tracker)
|
|
81
|
+
|
|
82
|
+
task = PipelineTask(
|
|
83
|
+
pipeline,
|
|
84
|
+
params=PipelineParams(
|
|
85
|
+
observers=[observer.latency_observer, turn_tracker],
|
|
86
|
+
enable_metrics=True,
|
|
87
|
+
enable_usage_metrics=True,
|
|
88
|
+
),
|
|
89
|
+
)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Without these, `llm_token`, `tts_character_count`, and per-turn `ttfb_ms` / `llm_ms` / `tts_ms` will be absent (null/zero) in the payload.
|
|
93
|
+
|
|
94
|
+
## What Happens at Call End
|
|
95
|
+
|
|
96
|
+
When `EndFrame` or `CancelFrame` is observed:
|
|
97
|
+
|
|
98
|
+
1. The observer reads transcript context from the attached flow manager.
|
|
99
|
+
2. It builds a typed `CallPayload`.
|
|
100
|
+
3. It sends the payload to `POST /api/v1/public/call`.
|
|
101
|
+
|
|
102
|
+
Network failures are logged and swallowed so the media pipeline is not blocked.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Integration Guide
|
|
2
|
+
|
|
3
|
+
## Integration Contract
|
|
4
|
+
|
|
5
|
+
`FlowsObserver` reads runtime events from your pipeline and emits one payload at call end.
|
|
6
|
+
Turn timing is captured through `attach_turn_tracking_observer(...)`.
|
|
7
|
+
|
|
8
|
+
## Recommended Flow
|
|
9
|
+
|
|
10
|
+
1. Create your `FlowManager`.
|
|
11
|
+
2. Create `FlowsObserver` with call metadata and model names.
|
|
12
|
+
3. Call `observer.attach_flow_manager(flow_manager)` once before starting the task.
|
|
13
|
+
4. Run your pipeline with observer after TTS.
|
|
14
|
+
|
|
15
|
+
## Captured Signals
|
|
16
|
+
|
|
17
|
+
- Call start/end timestamps and total duration
|
|
18
|
+
- Per-turn latency: user stop to LLM, TTS, bot start, and bot stop
|
|
19
|
+
- ASR confidence per turn
|
|
20
|
+
- Flow node transitions:
|
|
21
|
+
- from/to node
|
|
22
|
+
- triggering function and arguments
|
|
23
|
+
- Transcript segments:
|
|
24
|
+
- user turns
|
|
25
|
+
- agent turns
|
|
26
|
+
- tool call segments
|
|
27
|
+
- tool result segments
|
|
28
|
+
- node transition segments
|
|
29
|
+
|
|
30
|
+
## Notes on Interruptions and TTS
|
|
31
|
+
|
|
32
|
+
Interruption behavior in transcript context depends on the TTS provider behavior in `pipecat`:
|
|
33
|
+
|
|
34
|
+
- Providers with word timestamps typically commit only spoken words.
|
|
35
|
+
- Providers without word timestamps often commit full synthesized text before playback.
|
|
36
|
+
|
|
37
|
+
For strongly structured flows, `pipecat-flows` context reset strategies can help keep context clean between nodes.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
Each example shows a different voice bot use case built with [Pipecat Flows](https://github.com/pipecat-ai/pipecat-flows) and observed with `pipecat-flows-tuner`.
|
|
4
|
+
|
|
5
|
+
Every example is self-contained with its own `pyproject.toml`. Run `uv sync` inside the example directory and follow its README.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Examples
|
|
10
|
+
|
|
11
|
+
| Example | Use case | Key concepts |
|
|
12
|
+
|---------|----------|-------------|
|
|
13
|
+
| [`customer_support/`](customer_support/) | Acme Corp support agent | Multi-branch flow, state accumulation, resolve vs. escalate |
|
|
14
|
+
| [`appointment_booking/`](appointment_booking/) | Medical clinic receptionist | Linear 7-node flow, enum inputs, confirmation + reschedule |
|
|
15
|
+
| [`pizza_order/`](pizza_order/) | Pipecat Pizza ordering | Toppings selection, delivery/pickup branch, running price total |
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
All examples share the same requirements:
|
|
22
|
+
|
|
23
|
+
- Python 3.10+, [`uv`](https://docs.astral.sh/uv/)
|
|
24
|
+
- For **installing the SDK with pip**, Python version issues, or local path deps, see the **repository root README** (not repeated here).
|
|
25
|
+
- API keys: `CARTESIA_API_KEY`, `DEEPGRAM_API_KEY`, `OPENAI_API_KEY`
|
|
26
|
+
- Optional: Tuner API credentials (`TUNER_API_KEY`, `TUNER_WORKSPACE_ID`, `TUNER_AGENT_ID`, `TUNER_BASE_URL`)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cd examples/<example_name>
|
|
34
|
+
uv sync
|
|
35
|
+
cp .env.example .env # fill in your API keys
|
|
36
|
+
uv run <example_name>.py
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Then open http://localhost:7860 and click **Connect**.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## How the SDK fits in
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
transport.input()
|
|
47
|
+
└─► STT
|
|
48
|
+
└─► context_aggregator.user()
|
|
49
|
+
└─► LLM
|
|
50
|
+
└─► TTS
|
|
51
|
+
└─► FlowsObserver ← pipecat-flows-tuner
|
|
52
|
+
└─► transport.output()
|
|
53
|
+
└─► context_aggregator.assistant()
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`FlowsObserver` sits after TTS in the pipeline. It intercepts metrics frames, tracks node transitions via `attach_flow_manager()`, and posts a structured `CallPayload` to the Tuner API when the call ends.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Appointment Booking Bot
|
|
2
|
+
|
|
3
|
+
A medical clinic appointment booking bot built with Pipecat Flows and the `pipecat-flows-tuner` SDK.
|
|
4
|
+
|
|
5
|
+
**What it demonstrates:**
|
|
6
|
+
- Linear 7-node data-collection flow
|
|
7
|
+
- Enum-constrained inputs (service type, day, time slot)
|
|
8
|
+
- State accumulation across nodes (`patient_name`, `service`, `day`, `time_slot`, `phone`)
|
|
9
|
+
- Confirmation node with reschedule branch
|
|
10
|
+
- Full call observability via `FlowsObserver`
|
|
11
|
+
|
|
12
|
+
## Flow diagram
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
greeting
|
|
16
|
+
└─► service_type
|
|
17
|
+
└─► preferred_day
|
|
18
|
+
└─► preferred_time
|
|
19
|
+
└─► contact_info
|
|
20
|
+
└─► confirm
|
|
21
|
+
├─► farewell (confirmed)
|
|
22
|
+
└─► farewell (reschedule)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Prerequisites
|
|
26
|
+
|
|
27
|
+
- Python 3.10+
|
|
28
|
+
- `uv` package manager
|
|
29
|
+
|
|
30
|
+
## Setup
|
|
31
|
+
|
|
32
|
+
1. Install dependencies:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
uv sync
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. Create a `.env` file:
|
|
39
|
+
|
|
40
|
+
```env
|
|
41
|
+
CARTESIA_API_KEY=your_cartesia_key
|
|
42
|
+
DEEPGRAM_API_KEY=your_deepgram_key
|
|
43
|
+
OPENAI_API_KEY=your_openai_key
|
|
44
|
+
|
|
45
|
+
# Optional — Tuner observability (defaults to local dev server)
|
|
46
|
+
TUNER_API_KEY=dev
|
|
47
|
+
TUNER_WORKSPACE_ID=1
|
|
48
|
+
TUNER_AGENT_ID=appointment-booking-bot
|
|
49
|
+
TUNER_BASE_URL=http://localhost:8000
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Run
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv run appointment_booking.py
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Open http://localhost:7860 in your browser and click **Connect**.
|
|
59
|
+
|
|
60
|
+
## Services used
|
|
61
|
+
|
|
62
|
+
| Role | Service |
|
|
63
|
+
|------|---------|
|
|
64
|
+
| STT | Deepgram Nova-3 |
|
|
65
|
+
| LLM | OpenAI GPT-4o-mini |
|
|
66
|
+
| TTS | Cartesia Sonic |
|
|
67
|
+
| Transport | SmallWebRTC (default) |
|