@livekit/agents-plugin-openai 0.3.5 → 0.4.1

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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @livekit/agents-plugin-openai@0.3.5 build /home/runner/work/agents-js/agents-js/plugins/openai
2
+ > @livekit/agents-plugin-openai@0.4.1 build /home/runner/work/agents-js/agents-js/plugins/openai
3
3
  > tsc -b tsconfig.json
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @livekit/agents-plugin-openai
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`d2f1ef9f54cd7dd13892aa2ebe2f3f348b01afcb`](https://github.com/livekit/agents-js/commit/d2f1ef9f54cd7dd13892aa2ebe2f3f348b01afcb)]:
8
+ - @livekit/agents@0.4.1
9
+
10
+ ## 0.4.0
11
+
12
+ ### Minor Changes
13
+
14
+ - OpenAI function calling: support arrays and optional fields in function call schema - [#140](https://github.com/livekit/agents-js/pull/140) ([@nbsp](https://github.com/nbsp))
15
+
16
+ - add OpenAI LLM - [#140](https://github.com/livekit/agents-js/pull/140) ([@nbsp](https://github.com/nbsp))
17
+
18
+ ### Patch Changes
19
+
20
+ - add ChatContext - [#140](https://github.com/livekit/agents-js/pull/140) ([@nbsp](https://github.com/nbsp))
21
+
22
+ - Updated dependencies [[`d9273f27ae8df6c41e56a8258f540a4ffd9a7b7b`](https://github.com/livekit/agents-js/commit/d9273f27ae8df6c41e56a8258f540a4ffd9a7b7b), [`b4b9c1d337ff9a0212e90fb31002d4fcf58fe287`](https://github.com/livekit/agents-js/commit/b4b9c1d337ff9a0212e90fb31002d4fcf58fe287), [`4713a0490a3e4cd823aa648172c618ea924ae5d6`](https://github.com/livekit/agents-js/commit/4713a0490a3e4cd823aa648172c618ea924ae5d6), [`09782ec316590aa956d1a234dfb5594a8974dbfc`](https://github.com/livekit/agents-js/commit/09782ec316590aa956d1a234dfb5594a8974dbfc), [`d32f2470d4d1ea6786f4e13334f7251cc9823c04`](https://github.com/livekit/agents-js/commit/d32f2470d4d1ea6786f4e13334f7251cc9823c04), [`37bcf55aa75a289978af82e86332298dd7c07c73`](https://github.com/livekit/agents-js/commit/37bcf55aa75a289978af82e86332298dd7c07c73), [`35265a5b58adcbc048078d39c115412734dd4462`](https://github.com/livekit/agents-js/commit/35265a5b58adcbc048078d39c115412734dd4462), [`61899cde8c7fc19791d9d7d6a5ccabc2bb8f94dd`](https://github.com/livekit/agents-js/commit/61899cde8c7fc19791d9d7d6a5ccabc2bb8f94dd), [`644effb7c607e214e8d3ff8147afa7aec4a2496b`](https://github.com/livekit/agents-js/commit/644effb7c607e214e8d3ff8147afa7aec4a2496b), [`0e40262f3a60823d3d9cabbbd90f71c943db6c0e`](https://github.com/livekit/agents-js/commit/0e40262f3a60823d3d9cabbbd90f71c943db6c0e), [`cb788b7c37ca2297c04f5deb410a2fdab70d5c5f`](https://github.com/livekit/agents-js/commit/cb788b7c37ca2297c04f5deb410a2fdab70d5c5f), [`f844e8bb865beadbc58ea1c3a21e362aee1dce55`](https://github.com/livekit/agents-js/commit/f844e8bb865beadbc58ea1c3a21e362aee1dce55)]:
23
+ - @livekit/agents@0.4.0
24
+
3
25
  ## 0.3.5
4
26
 
5
27
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * as realtime from './realtime/index.js';
2
+ export * from './models.js';
3
+ export { type LLMOptions, LLM, LLMStream } from './llm.js';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,KAAK,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -2,4 +2,6 @@
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  export * as realtime from './realtime/index.js';
5
+ export * from './models.js';
6
+ export { LLM, LLMStream } from './llm.js';
5
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,sCAAsC;AACtC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,sCAAsC;AACtC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAmB,GAAG,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC"}
package/dist/llm.d.ts ADDED
@@ -0,0 +1,195 @@
1
+ import { llm } from '@livekit/agents';
2
+ import { OpenAI } from 'openai';
3
+ import type { CerebrasChatModels, ChatModels, DeepSeekChatModels, GroqChatModels, OctoChatModels, PerplexityChatModels, TelnyxChatModels, TogetherChatModels, XAIChatModels } from './models.js';
4
+ export interface LLMOptions {
5
+ model: string | ChatModels;
6
+ apiKey?: string;
7
+ baseURL?: string;
8
+ user?: string;
9
+ temperature?: number;
10
+ client?: OpenAI;
11
+ }
12
+ export declare class LLM extends llm.LLM {
13
+ #private;
14
+ /**
15
+ * Create a new instance of OpenAI LLM.
16
+ *
17
+ * @remarks
18
+ * `apiKey` must be set to your OpenAI API key, either using the argument or by setting the
19
+ * `OPENAI_API_KEY` environmental variable.
20
+ */
21
+ constructor(opts?: Partial<LLMOptions>);
22
+ /**
23
+ * Create a new instance of OpenAI LLM with Azure.
24
+ *
25
+ * @remarks
26
+ * This automatically infers the following arguments from their corresponding environment variables if they are not provided:
27
+ * - `apiKey` from `AZURE_OPENAI_API_KEY`
28
+ * - `organization` from `OPENAI_ORG_ID`
29
+ * - `project` from `OPENAI_PROJECT_ID`
30
+ * - `azureAdToken` from `AZURE_OPENAI_AD_TOKEN`
31
+ * - `apiVersion` from `OPENAI_API_VERSION`
32
+ * - `azureEndpoint` from `AZURE_OPENAI_ENDPOINT`
33
+ */
34
+ static withAzure(opts?: {
35
+ model: string | ChatModels;
36
+ azureEndpoint?: string;
37
+ azureDeployment?: string;
38
+ apiVersion?: string;
39
+ apiKey?: string;
40
+ azureAdToken?: string;
41
+ azureAdTokenProvider?: () => Promise<string>;
42
+ organization?: string;
43
+ project?: string;
44
+ baseURL?: string;
45
+ user?: string;
46
+ temperature?: number;
47
+ }): LLM;
48
+ /**
49
+ * Create a new instance of Cerebras LLM.
50
+ *
51
+ * @remarks
52
+ * `apiKey` must be set to your Cerebras API key, either using the argument or by setting the
53
+ * `CEREBRAS_API_KEY` environmental variable.
54
+ */
55
+ static withCerebras(opts?: Partial<{
56
+ model: string | CerebrasChatModels;
57
+ apiKey?: string;
58
+ baseURL?: string;
59
+ user?: string;
60
+ temperature?: number;
61
+ client: OpenAI;
62
+ }>): LLM;
63
+ /**
64
+ * Create a new instance of Fireworks LLM.
65
+ *
66
+ * @remarks
67
+ * `apiKey` must be set to your Fireworks API key, either using the argument or by setting the
68
+ * `FIREWORKS_API_KEY` environmental variable.
69
+ */
70
+ static withFireworks(opts?: Partial<LLMOptions>): LLM;
71
+ /**
72
+ * Create a new instance of xAI LLM.
73
+ *
74
+ * @remarks
75
+ * `apiKey` must be set to your xAI API key, either using the argument or by setting the
76
+ * `XAI_API_KEY` environmental variable.
77
+ */
78
+ static withXAI(opts?: Partial<{
79
+ model: string | XAIChatModels;
80
+ apiKey?: string;
81
+ baseURL?: string;
82
+ user?: string;
83
+ temperature?: number;
84
+ client: OpenAI;
85
+ }>): LLM;
86
+ /**
87
+ * Create a new instance of Groq LLM.
88
+ *
89
+ * @remarks
90
+ * `apiKey` must be set to your Groq API key, either using the argument or by setting the
91
+ * `GROQ_API_KEY` environmental variable.
92
+ */
93
+ static withGroq(opts?: Partial<{
94
+ model: string | GroqChatModels;
95
+ apiKey?: string;
96
+ baseURL?: string;
97
+ user?: string;
98
+ temperature?: number;
99
+ client: OpenAI;
100
+ }>): LLM;
101
+ /**
102
+ * Create a new instance of DeepSeek LLM.
103
+ *
104
+ * @remarks
105
+ * `apiKey` must be set to your DeepSeek API key, either using the argument or by setting the
106
+ * `DEEPSEEK_API_KEY` environmental variable.
107
+ */
108
+ static withDeepSeek(opts?: Partial<{
109
+ model: string | DeepSeekChatModels;
110
+ apiKey?: string;
111
+ baseURL?: string;
112
+ user?: string;
113
+ temperature?: number;
114
+ client: OpenAI;
115
+ }>): LLM;
116
+ /**
117
+ * Create a new instance of OctoAI LLM.
118
+ *
119
+ * @remarks
120
+ * `apiKey` must be set to your OctoAI API key, either using the argument or by setting the
121
+ * `OCTOAI_TOKEN` environmental variable.
122
+ */
123
+ static withOcto(opts?: Partial<{
124
+ model: string | OctoChatModels;
125
+ apiKey?: string;
126
+ baseURL?: string;
127
+ user?: string;
128
+ temperature?: number;
129
+ client: OpenAI;
130
+ }>): LLM;
131
+ /** Create a new instance of Ollama LLM. */
132
+ static withOllama(opts?: Partial<{
133
+ model: string;
134
+ baseURL?: string;
135
+ temperature?: number;
136
+ client: OpenAI;
137
+ }>): LLM;
138
+ /**
139
+ * Create a new instance of PerplexityAI LLM.
140
+ *
141
+ * @remarks
142
+ * `apiKey` must be set to your PerplexityAI API key, either using the argument or by setting the
143
+ * `PERPLEXITY_API_KEY` environmental variable.
144
+ */
145
+ static withPerplexity(opts?: Partial<{
146
+ model: string | PerplexityChatModels;
147
+ apiKey?: string;
148
+ baseURL?: string;
149
+ user?: string;
150
+ temperature?: number;
151
+ client: OpenAI;
152
+ }>): LLM;
153
+ /**
154
+ * Create a new instance of TogetherAI LLM.
155
+ *
156
+ * @remarks
157
+ * `apiKey` must be set to your TogetherAI API key, either using the argument or by setting the
158
+ * `TOGETHER_API_KEY` environmental variable.
159
+ */
160
+ static withTogether(opts?: Partial<{
161
+ model: string | TogetherChatModels;
162
+ apiKey?: string;
163
+ baseURL?: string;
164
+ user?: string;
165
+ temperature?: number;
166
+ client: OpenAI;
167
+ }>): LLM;
168
+ /**
169
+ * Create a new instance of Telnyx LLM.
170
+ *
171
+ * @remarks
172
+ * `apiKey` must be set to your Telnyx API key, either using the argument or by setting the
173
+ * `TELNYX_API_KEY` environmental variable.
174
+ */
175
+ static withTelnyx(opts?: Partial<{
176
+ model: string | TelnyxChatModels;
177
+ apiKey?: string;
178
+ baseURL?: string;
179
+ user?: string;
180
+ temperature?: number;
181
+ client: OpenAI;
182
+ }>): LLM;
183
+ chat({ chatCtx, fncCtx, temperature, n, parallelToolCalls, }: {
184
+ chatCtx: llm.ChatContext;
185
+ fncCtx?: llm.FunctionContext | undefined;
186
+ temperature?: number | undefined;
187
+ n?: number | undefined;
188
+ parallelToolCalls?: boolean | undefined;
189
+ }): LLMStream;
190
+ }
191
+ export declare class LLMStream extends llm.LLMStream {
192
+ #private;
193
+ constructor(client: OpenAI, chatCtx: llm.ChatContext, fncCtx: llm.FunctionContext | undefined, opts: LLMOptions, parallelToolCalls?: boolean, temperature?: number, n?: number);
194
+ }
195
+ //# sourceMappingURL=llm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../src/llm.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAO,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAe,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACd,MAA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