@voicelayer/sdk 0.1.3 → 0.1.4
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.
- package/README.md +43 -0
- package/dist/index.d.ts +536 -623
- package/dist/index.js +6300 -4190
- package/dist/runtime/text-session.d.ts +3 -0
- package/dist/runtime/text-session.js +4119 -0
- package/dist/text-session-B8-jhQzv.d.ts +837 -0
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -201,6 +201,49 @@ interfaces directly.
|
|
|
201
201
|
|
|
202
202
|
---
|
|
203
203
|
|
|
204
|
+
## Bring your own LLM
|
|
205
|
+
|
|
206
|
+
Don't want a first-party model at all? Bring your own brain — your existing agent, a private model, a LangChain app, anything. VoiceLayer keeps doing STT, TTS, turn-taking, and telephony; your code does the thinking. Three ways, smallest first.
|
|
207
|
+
|
|
208
|
+
**1. An in-process function** — your existing agent as a callback (the "two lines" path):
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
import { defineAgent } from '@voicelayer/sdk';
|
|
212
|
+
|
|
213
|
+
export default await defineAgent({
|
|
214
|
+
name: 'support',
|
|
215
|
+
prompt: 'bridged to my brain',
|
|
216
|
+
onQuery: async (text) => myExistingAgent.reply(text), // ← your brain
|
|
217
|
+
}).start(import.meta.url);
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
`onQuery` gets the caller's final transcript and returns the reply — a `string`, or an `AsyncIterable<string>` to stream tokens (the SDK speaks the first sentence as soon as it lands). STT, TTS, and barge-in stay ours.
|
|
221
|
+
|
|
222
|
+
**2. A direct endpoint** — point at any public OpenAI-compatible URL:
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
import { defineAgent, connector } from '@voicelayer/sdk';
|
|
226
|
+
|
|
227
|
+
export default await defineAgent({
|
|
228
|
+
name: 'support',
|
|
229
|
+
prompt: 'You are a helpful assistant. Keep replies short.',
|
|
230
|
+
models: {
|
|
231
|
+
llm: connector.llm({
|
|
232
|
+
url: 'https://your-brain.example.com/v1', // OpenAI-compatible
|
|
233
|
+
apiKey: process.env.BRAIN_API_KEY,
|
|
234
|
+
model: 'your-model',
|
|
235
|
+
fallbackText: 'Sorry, let me try that again.',
|
|
236
|
+
}),
|
|
237
|
+
},
|
|
238
|
+
}).start(import.meta.url);
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Works with OpenAI, Azure, Together, Groq, vLLM, or a [LiteLLM](https://docs.litellm.ai) proxy in front of anything. The URL is `https`-only and SSRF-guarded; under the hood it reuses the proven LiveKit OpenAI client.
|
|
242
|
+
|
|
243
|
+
**3. A private endpoint (tunnel)** — keep your brain behind your firewall. Run the one-container `vl-brain` daemon — it dials *out* to us (no inbound ports) and LiteLLM is baked in to normalize any provider. The connector then shows up as a voice agent in the dashboard (its LLM is your brain; STT/TTS still swappable) — test it in the Playground, attach a number. No SDK code required. See the [`vl-brain` daemon guide](../../apps/connector-daemon/README.md).
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
204
247
|
## Connectors
|
|
205
248
|
|
|
206
249
|
Connectors are **typed integrations** with external systems. They show up on `ctx.connectors` and (optionally) as LLM tools.
|