@livekit/agents-plugin-openai 0.9.1 → 0.9.2
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/dist/index.d.cts +6 -0
- package/dist/llm.cjs +18 -0
- package/dist/llm.cjs.map +1 -1
- package/dist/llm.d.cts +211 -0
- package/dist/llm.d.ts +16 -1
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +18 -0
- package/dist/llm.js.map +1 -1
- package/dist/llm.test.d.cts +2 -0
- package/dist/models.cjs.map +1 -1
- package/dist/models.d.cts +15 -0
- package/dist/models.d.ts +1 -0
- package/dist/models.d.ts.map +1 -1
- package/dist/realtime/api_proto.d.cts +413 -0
- package/dist/realtime/index.d.cts +3 -0
- package/dist/realtime/realtime_model.d.cts +190 -0
- package/dist/stt.d.cts +43 -0
- package/dist/stt.test.d.cts +2 -0
- package/dist/tts.d.cts +37 -0
- package/dist/tts.test.d.cts +2 -0
- package/package.json +12 -8
- package/src/llm.ts +31 -0
- package/src/models.ts +6 -0
package/dist/stt.d.cts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type AudioBuffer, stt } from '@livekit/agents';
|
|
2
|
+
import { OpenAI } from 'openai';
|
|
3
|
+
import type { GroqAudioModels, WhisperModels } from './models.js';
|
|
4
|
+
export interface STTOptions {
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
language: string;
|
|
7
|
+
prompt?: string;
|
|
8
|
+
detectLanguage: boolean;
|
|
9
|
+
model: WhisperModels | string;
|
|
10
|
+
baseURL?: string;
|
|
11
|
+
client?: OpenAI;
|
|
12
|
+
}
|
|
13
|
+
export declare class STT extends stt.STT {
|
|
14
|
+
#private;
|
|
15
|
+
label: string;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new instance of OpenAI STT.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* `apiKey` must be set to your OpenAI API key, either using the argument or by setting the
|
|
21
|
+
* `OPENAI_API_KEY` environmental variable.
|
|
22
|
+
*/
|
|
23
|
+
constructor(opts?: Partial<STTOptions>);
|
|
24
|
+
/**
|
|
25
|
+
* Create a new instance of Groq STT.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* `apiKey` must be set to your Groq API key, either using the argument or by setting the
|
|
29
|
+
* `GROQ_API_KEY` environmental variable.
|
|
30
|
+
*/
|
|
31
|
+
static withGroq(opts?: Partial<{
|
|
32
|
+
model: string | GroqAudioModels;
|
|
33
|
+
apiKey?: string;
|
|
34
|
+
baseURL?: string;
|
|
35
|
+
client: OpenAI;
|
|
36
|
+
language: string;
|
|
37
|
+
detectLanguage: boolean;
|
|
38
|
+
}>): STT;
|
|
39
|
+
_recognize(buffer: AudioBuffer, language?: string): Promise<stt.SpeechEvent>;
|
|
40
|
+
/** This method throws an error; streaming is unsupported on OpenAI STT. */
|
|
41
|
+
stream(): stt.SpeechStream;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=stt.d.ts.map
|
package/dist/tts.d.cts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { tts } from '@livekit/agents';
|
|
2
|
+
import { OpenAI } from 'openai';
|
|
3
|
+
import type { TTSModels, TTSVoices } from './models.js';
|
|
4
|
+
export interface TTSOptions {
|
|
5
|
+
model: TTSModels | string;
|
|
6
|
+
voice: TTSVoices;
|
|
7
|
+
speed: number;
|
|
8
|
+
instructions?: string;
|
|
9
|
+
baseURL?: string;
|
|
10
|
+
client?: OpenAI;
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class TTS extends tts.TTS {
|
|
14
|
+
#private;
|
|
15
|
+
label: string;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new instance of OpenAI TTS.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* `apiKey` must be set to your OpenAI API key, either using the argument or by setting the
|
|
21
|
+
* `OPENAI_API_KEY` environmental variable.
|
|
22
|
+
*/
|
|
23
|
+
constructor(opts?: Partial<TTSOptions>);
|
|
24
|
+
updateOptions(opts: {
|
|
25
|
+
model?: TTSModels | string;
|
|
26
|
+
voice?: TTSVoices;
|
|
27
|
+
speed?: number;
|
|
28
|
+
}): void;
|
|
29
|
+
synthesize(text: string): ChunkedStream;
|
|
30
|
+
stream(): tts.SynthesizeStream;
|
|
31
|
+
}
|
|
32
|
+
export declare class ChunkedStream extends tts.ChunkedStream {
|
|
33
|
+
#private;
|
|
34
|
+
label: string;
|
|
35
|
+
constructor(tts: TTS, text: string, stream: Promise<any>);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=tts.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livekit/agents-plugin-openai",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "OpenAI plugin for LiveKit Node Agents",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"require": "dist/index.cjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
-
"
|
|
9
|
+
"import": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
|
-
"
|
|
12
|
-
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"require": {
|
|
14
|
+
"types": "./dist/index.d.cts",
|
|
15
|
+
"default": "./dist/index.cjs"
|
|
13
16
|
}
|
|
14
17
|
},
|
|
15
18
|
"author": "LiveKit",
|
|
@@ -25,7 +28,7 @@
|
|
|
25
28
|
"@livekit/agents": "^x",
|
|
26
29
|
"@livekit/agents-plugin-silero": "^x",
|
|
27
30
|
"@livekit/agents-plugins-test": "^x",
|
|
28
|
-
"@livekit/rtc-node": "^0.13.
|
|
31
|
+
"@livekit/rtc-node": "^0.13.11",
|
|
29
32
|
"@microsoft/api-extractor": "^7.35.0",
|
|
30
33
|
"@types/ws": "^8.5.10",
|
|
31
34
|
"tsup": "^8.3.5",
|
|
@@ -37,11 +40,12 @@
|
|
|
37
40
|
"ws": "^8.16.0"
|
|
38
41
|
},
|
|
39
42
|
"peerDependencies": {
|
|
40
|
-
"@livekit/rtc-node": "^0.13.
|
|
41
|
-
"@livekit/agents": "^0.7.
|
|
43
|
+
"@livekit/rtc-node": "^0.13.11",
|
|
44
|
+
"@livekit/agents": "^0.7.7x"
|
|
42
45
|
},
|
|
43
46
|
"scripts": {
|
|
44
|
-
"build": "tsup --onSuccess \"
|
|
47
|
+
"build": "tsup --onSuccess \"pnpm build:types\"",
|
|
48
|
+
"build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
|
|
45
49
|
"clean": "rm -rf dist",
|
|
46
50
|
"clean:build": "pnpm clean && pnpm build",
|
|
47
51
|
"lint": "eslint -f unix \"src/**/*.{ts,js}\"",
|
package/src/llm.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
ChatModels,
|
|
11
11
|
DeepSeekChatModels,
|
|
12
12
|
GroqChatModels,
|
|
13
|
+
MetaChatModels,
|
|
13
14
|
OctoChatModels,
|
|
14
15
|
PerplexityChatModels,
|
|
15
16
|
TelnyxChatModels,
|
|
@@ -382,6 +383,36 @@ export class LLM extends llm.LLM {
|
|
|
382
383
|
});
|
|
383
384
|
}
|
|
384
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Create a new instance of Meta Llama LLM.
|
|
388
|
+
*
|
|
389
|
+
* @remarks
|
|
390
|
+
* `apiKey` must be set to your Meta Llama API key, either using the argument or by setting the
|
|
391
|
+
* `LLAMA_API_KEY` environmental variable.
|
|
392
|
+
*/
|
|
393
|
+
static withMeta(
|
|
394
|
+
opts: Partial<{
|
|
395
|
+
apiKey?: string;
|
|
396
|
+
baseURL?: string;
|
|
397
|
+
client?: OpenAI;
|
|
398
|
+
model?: string | MetaChatModels;
|
|
399
|
+
temperature?: number;
|
|
400
|
+
user?: string;
|
|
401
|
+
}> = {},
|
|
402
|
+
): LLM {
|
|
403
|
+
opts.apiKey = opts.apiKey || process.env.LLAMA_API_KEY;
|
|
404
|
+
opts.baseURL = opts.baseURL || 'https://api.llama.com/compat/v1/';
|
|
405
|
+
opts.model = opts.model || 'Llama-4-Maverick-17B-128E-Instruct-FP8';
|
|
406
|
+
|
|
407
|
+
if (opts.apiKey === undefined) {
|
|
408
|
+
throw new Error(
|
|
409
|
+
'Meta Llama API key is required, either as argument or set LLAMA_API_KEY environmental variable',
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return new LLM(opts);
|
|
414
|
+
}
|
|
415
|
+
|
|
385
416
|
chat({
|
|
386
417
|
chatCtx,
|
|
387
418
|
fncCtx,
|
package/src/models.ts
CHANGED
|
@@ -128,3 +128,9 @@ export type OctoChatModels =
|
|
|
128
128
|
| 'wizardlm-2-8x22bllamaguard-2-7b';
|
|
129
129
|
|
|
130
130
|
export type XAIChatModels = 'grok-2' | 'grok-2-mini' | 'grok-2-mini-public' | 'grok-2-public';
|
|
131
|
+
|
|
132
|
+
export type MetaChatModels =
|
|
133
|
+
| 'Llama-4-Scout-17B-16E-Instruct-FP8'
|
|
134
|
+
| 'Llama-4-Maverick-17B-128E-Instruct-FP8'
|
|
135
|
+
| 'Llama-3.3-70B-Instruct'
|
|
136
|
+
| 'Llama-3.3-8B-Instruct';
|