@livekit/agents-plugin-baseten 1.2.4 → 1.2.5
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.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/llm.cjs +13 -1
- package/dist/llm.cjs.map +1 -1
- package/dist/llm.d.cts +3 -0
- package/dist/llm.d.ts +3 -0
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +13 -1
- package/dist/llm.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +12 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/llm.ts +19 -1
- package/src/types.ts +12 -0
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/dist/llm.cjs
CHANGED
|
@@ -71,9 +71,18 @@ class OpenAILLM extends import_agents.llm.LLM {
|
|
|
71
71
|
if (this.#opts.maxCompletionTokens) {
|
|
72
72
|
extras.max_completion_tokens = this.#opts.maxCompletionTokens;
|
|
73
73
|
}
|
|
74
|
-
if (this.#opts.temperature) {
|
|
74
|
+
if (this.#opts.temperature !== void 0) {
|
|
75
75
|
extras.temperature = this.#opts.temperature;
|
|
76
76
|
}
|
|
77
|
+
if (this.#opts.topP !== void 0) {
|
|
78
|
+
extras.top_p = this.#opts.topP;
|
|
79
|
+
}
|
|
80
|
+
if (this.#opts.presencePenalty !== void 0) {
|
|
81
|
+
extras.presence_penalty = this.#opts.presencePenalty;
|
|
82
|
+
}
|
|
83
|
+
if (this.#opts.frequencyPenalty !== void 0) {
|
|
84
|
+
extras.frequency_penalty = this.#opts.frequencyPenalty;
|
|
85
|
+
}
|
|
77
86
|
if (this.#opts.serviceTier) {
|
|
78
87
|
extras.service_tier = this.#opts.serviceTier;
|
|
79
88
|
}
|
|
@@ -124,6 +133,9 @@ class LLM extends OpenAILLM {
|
|
|
124
133
|
apiKey,
|
|
125
134
|
baseURL: "https://inference.baseten.co/v1",
|
|
126
135
|
temperature: opts.temperature,
|
|
136
|
+
topP: opts.topP,
|
|
137
|
+
presencePenalty: opts.presencePenalty,
|
|
138
|
+
frequencyPenalty: opts.frequencyPenalty,
|
|
127
139
|
user: opts.user,
|
|
128
140
|
maxCompletionTokens: opts.maxTokens,
|
|
129
141
|
toolChoice: opts.toolChoice,
|
package/dist/llm.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/llm.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Baseten LLM plugin for LiveKit Agents\n * Configures the OpenAI plugin to work with Baseten's OpenAI-compatible API\n */\nimport type { APIConnectOptions } from '@livekit/agents';\nimport { DEFAULT_API_CONNECT_OPTIONS, inference, llm } from '@livekit/agents';\nimport { OpenAI } from 'openai';\nimport type { BasetenLLMOptions } from './types.js';\n\nexport interface LLMOptions {\n model: string;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client?: OpenAI;\n toolChoice?: llm.ToolChoice;\n parallelToolCalls?: boolean;\n metadata?: Record<string, string>;\n maxCompletionTokens?: number;\n serviceTier?: string;\n store?: boolean;\n strictToolSchema?: boolean;\n}\n\nconst defaultLLMOptions: LLMOptions = {\n model: 'openai/gpt-4o-mini',\n apiKey: process.env.OPENAI_API_KEY,\n parallelToolCalls: true,\n strictToolSchema: false,\n};\n\nexport class OpenAILLM extends llm.LLM {\n #opts: LLMOptions;\n #client: OpenAI;\n #providerFmt: llm.ProviderFormat;\n\n constructor(\n opts: Partial<LLMOptions> = defaultLLMOptions,\n providerFmt: llm.ProviderFormat = 'openai',\n ) {\n super();\n\n this.#opts = { ...defaultLLMOptions, ...opts };\n this.#providerFmt = providerFmt;\n if (this.#opts.apiKey === undefined) {\n throw new Error('OpenAI API key is required, whether as an argument or as $OPENAI_API_KEY');\n }\n\n this.#client =\n this.#opts.client ||\n new OpenAI({\n baseURL: opts.baseURL,\n apiKey: opts.apiKey,\n });\n }\n\n label(): string {\n return 'openai.LLM';\n }\n\n get model(): string {\n return this.#opts.model;\n }\n\n chat({\n chatCtx,\n toolCtx,\n connOptions = DEFAULT_API_CONNECT_OPTIONS,\n parallelToolCalls,\n toolChoice,\n extraKwargs,\n }: {\n chatCtx: llm.ChatContext;\n toolCtx?: llm.ToolContext;\n connOptions?: APIConnectOptions;\n parallelToolCalls?: boolean;\n toolChoice?: llm.ToolChoice;\n extraKwargs?: Record<string, unknown>;\n }): inference.LLMStream {\n const extras: Record<string, unknown> = { ...extraKwargs };\n\n if (this.#opts.metadata) {\n extras.metadata = this.#opts.metadata;\n }\n\n if (this.#opts.user) {\n extras.user = this.#opts.user;\n }\n\n if (this.#opts.maxCompletionTokens) {\n extras.max_completion_tokens = this.#opts.maxCompletionTokens;\n }\n\n if (this.#opts.temperature) {\n extras.temperature = this.#opts.temperature;\n }\n\n if (this.#opts.serviceTier) {\n extras.service_tier = this.#opts.serviceTier;\n }\n\n if (this.#opts.store !== undefined) {\n extras.store = this.#opts.store;\n }\n\n parallelToolCalls =\n parallelToolCalls !== undefined ? parallelToolCalls : this.#opts.parallelToolCalls;\n if (toolCtx && Object.keys(toolCtx).length > 0 && parallelToolCalls !== undefined) {\n extras.parallel_tool_calls = parallelToolCalls;\n }\n\n toolChoice = toolChoice !== undefined ? toolChoice : this.#opts.toolChoice;\n if (toolChoice) {\n extras.tool_choice = toolChoice;\n }\n\n return new LLMStream(this as unknown as inference.LLM, {\n model: this.#opts.model,\n providerFmt: this.#providerFmt,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n client: this.#client as any,\n chatCtx,\n toolCtx,\n connOptions,\n modelOptions: extras,\n strictToolSchema: this.#opts.strictToolSchema || false,\n gatewayOptions: undefined, // OpenAI plugin doesn't use gateway authentication\n });\n }\n}\n\nexport class LLMStream extends inference.LLMStream {}\n\nexport class LLM extends OpenAILLM {\n constructor(opts: BasetenLLMOptions) {\n const apiKey = opts.apiKey ?? process.env.BASETEN_API_KEY;\n if (!apiKey) {\n throw new Error(\n 'Baseten API key is required. Set BASETEN_API_KEY environment variable or pass apiKey in options.',\n );\n }\n\n if (!opts.model) {\n throw new Error(\n 'Model is required. Please specify a model name (e.g., \"openai/gpt-4o-mini\").',\n );\n }\n\n const model = opts.model;\n\n // Configure the OpenAI plugin with Baseten's endpoint\n super({\n model,\n apiKey,\n baseURL: 'https://inference.baseten.co/v1',\n temperature: opts.temperature,\n user: opts.user,\n maxCompletionTokens: opts.maxTokens,\n toolChoice: opts.toolChoice,\n parallelToolCalls: opts.parallelToolCalls,\n });\n }\n\n label(): string {\n return 'baseten.LLM';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,oBAA4D;AAC5D,oBAAuB;
|
|
1
|
+
{"version":3,"sources":["../src/llm.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Baseten LLM plugin for LiveKit Agents\n * Configures the OpenAI plugin to work with Baseten's OpenAI-compatible API\n */\nimport type { APIConnectOptions } from '@livekit/agents';\nimport { DEFAULT_API_CONNECT_OPTIONS, inference, llm } from '@livekit/agents';\nimport { OpenAI } from 'openai';\nimport type { BasetenLLMOptions } from './types.js';\n\nexport interface LLMOptions {\n model: string;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n topP?: number;\n presencePenalty?: number;\n frequencyPenalty?: number;\n client?: OpenAI;\n toolChoice?: llm.ToolChoice;\n parallelToolCalls?: boolean;\n metadata?: Record<string, string>;\n maxCompletionTokens?: number;\n serviceTier?: string;\n store?: boolean;\n strictToolSchema?: boolean;\n}\n\nconst defaultLLMOptions: LLMOptions = {\n model: 'openai/gpt-4o-mini',\n apiKey: process.env.OPENAI_API_KEY,\n parallelToolCalls: true,\n strictToolSchema: false,\n};\n\nexport class OpenAILLM extends llm.LLM {\n #opts: LLMOptions;\n #client: OpenAI;\n #providerFmt: llm.ProviderFormat;\n\n constructor(\n opts: Partial<LLMOptions> = defaultLLMOptions,\n providerFmt: llm.ProviderFormat = 'openai',\n ) {\n super();\n\n this.#opts = { ...defaultLLMOptions, ...opts };\n this.#providerFmt = providerFmt;\n if (this.#opts.apiKey === undefined) {\n throw new Error('OpenAI API key is required, whether as an argument or as $OPENAI_API_KEY');\n }\n\n this.#client =\n this.#opts.client ||\n new OpenAI({\n baseURL: opts.baseURL,\n apiKey: opts.apiKey,\n });\n }\n\n label(): string {\n return 'openai.LLM';\n }\n\n get model(): string {\n return this.#opts.model;\n }\n\n chat({\n chatCtx,\n toolCtx,\n connOptions = DEFAULT_API_CONNECT_OPTIONS,\n parallelToolCalls,\n toolChoice,\n extraKwargs,\n }: {\n chatCtx: llm.ChatContext;\n toolCtx?: llm.ToolContext;\n connOptions?: APIConnectOptions;\n parallelToolCalls?: boolean;\n toolChoice?: llm.ToolChoice;\n extraKwargs?: Record<string, unknown>;\n }): inference.LLMStream {\n const extras: Record<string, unknown> = { ...extraKwargs };\n\n if (this.#opts.metadata) {\n extras.metadata = this.#opts.metadata;\n }\n\n if (this.#opts.user) {\n extras.user = this.#opts.user;\n }\n\n if (this.#opts.maxCompletionTokens) {\n extras.max_completion_tokens = this.#opts.maxCompletionTokens;\n }\n\n if (this.#opts.temperature !== undefined) {\n extras.temperature = this.#opts.temperature;\n }\n\n if (this.#opts.topP !== undefined) {\n extras.top_p = this.#opts.topP;\n }\n\n if (this.#opts.presencePenalty !== undefined) {\n extras.presence_penalty = this.#opts.presencePenalty;\n }\n\n if (this.#opts.frequencyPenalty !== undefined) {\n extras.frequency_penalty = this.#opts.frequencyPenalty;\n }\n\n if (this.#opts.serviceTier) {\n extras.service_tier = this.#opts.serviceTier;\n }\n\n if (this.#opts.store !== undefined) {\n extras.store = this.#opts.store;\n }\n\n parallelToolCalls =\n parallelToolCalls !== undefined ? parallelToolCalls : this.#opts.parallelToolCalls;\n if (toolCtx && Object.keys(toolCtx).length > 0 && parallelToolCalls !== undefined) {\n extras.parallel_tool_calls = parallelToolCalls;\n }\n\n toolChoice = toolChoice !== undefined ? toolChoice : this.#opts.toolChoice;\n if (toolChoice) {\n extras.tool_choice = toolChoice;\n }\n\n return new LLMStream(this as unknown as inference.LLM, {\n model: this.#opts.model,\n providerFmt: this.#providerFmt,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n client: this.#client as any,\n chatCtx,\n toolCtx,\n connOptions,\n modelOptions: extras,\n strictToolSchema: this.#opts.strictToolSchema || false,\n gatewayOptions: undefined, // OpenAI plugin doesn't use gateway authentication\n });\n }\n}\n\nexport class LLMStream extends inference.LLMStream {}\n\nexport class LLM extends OpenAILLM {\n constructor(opts: BasetenLLMOptions) {\n const apiKey = opts.apiKey ?? process.env.BASETEN_API_KEY;\n if (!apiKey) {\n throw new Error(\n 'Baseten API key is required. Set BASETEN_API_KEY environment variable or pass apiKey in options.',\n );\n }\n\n if (!opts.model) {\n throw new Error(\n 'Model is required. Please specify a model name (e.g., \"openai/gpt-4o-mini\").',\n );\n }\n\n const model = opts.model;\n\n // Configure the OpenAI plugin with Baseten's endpoint\n super({\n model,\n apiKey,\n baseURL: 'https://inference.baseten.co/v1',\n temperature: opts.temperature,\n topP: opts.topP,\n presencePenalty: opts.presencePenalty,\n frequencyPenalty: opts.frequencyPenalty,\n user: opts.user,\n maxCompletionTokens: opts.maxTokens,\n toolChoice: opts.toolChoice,\n parallelToolCalls: opts.parallelToolCalls,\n });\n }\n\n label(): string {\n return 'baseten.LLM';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,oBAA4D;AAC5D,oBAAuB;AAsBvB,MAAM,oBAAgC;AAAA,EACpC,OAAO;AAAA,EACP,QAAQ,QAAQ,IAAI;AAAA,EACpB,mBAAmB;AAAA,EACnB,kBAAkB;AACpB;AAEO,MAAM,kBAAkB,kB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AAAA,EACT;AACF;","names":[]}
|
package/dist/llm.d.cts
CHANGED
package/dist/llm.d.ts
CHANGED
package/dist/llm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../src/llm.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAA+B,SAAS,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AASD,qBAAa,SAAU,SAAQ,GAAG,CAAC,GAAG;;gBAMlC,IAAI,GAAE,OAAO,CAAC,UAAU,CAAqB,EAC7C,WAAW,GAAE,GAAG,CAAC,cAAyB;IAkB5C,KAAK,IAAI,MAAM;IAIf,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,CAAC,EACH,OAAO,EACP,OAAO,EACP,WAAyC,EACzC,iB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EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AASD,qBAAa,SAAU,SAAQ,GAAG,CAAC,GAAG;;gBAMlC,IAAI,GAAE,OAAO,CAAC,UAAU,CAAqB,EAC7C,WAAW,GAAE,GAAG,CAAC,cAAyB;IAkB5C,KAAK,IAAI,MAAM;IAIf,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,CAAC,EACH,OAAO,EACP,OAAO,EACP,WAAyC,EACzC,iBAAiB,EACjB,UAAU,EACV,WAAW,GACZ,EAAE;QACD,OAAO,EAAE,GAAG,CAAC,WAAW,CAAC;QACzB,OAAO,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC;QAC1B,WAAW,CAAC,EAAE,iBAAiB,CAAC;QAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,UAAU,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC;QAC5B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACvC,GAAG,SAAS,CAAC,SAAS;CA+DxB;AAED,qBAAa,SAAU,SAAQ,SAAS,CAAC,SAAS;CAAG;AAErD,qBAAa,GAAI,SAAQ,SAAS;gBACpB,IAAI,EAAE,iBAAiB;IAgCnC,KAAK,IAAI,MAAM;CAGhB"}
|
package/dist/llm.js
CHANGED
|
@@ -46,9 +46,18 @@ class OpenAILLM extends llm.LLM {
|
|
|
46
46
|
if (this.#opts.maxCompletionTokens) {
|
|
47
47
|
extras.max_completion_tokens = this.#opts.maxCompletionTokens;
|
|
48
48
|
}
|
|
49
|
-
if (this.#opts.temperature) {
|
|
49
|
+
if (this.#opts.temperature !== void 0) {
|
|
50
50
|
extras.temperature = this.#opts.temperature;
|
|
51
51
|
}
|
|
52
|
+
if (this.#opts.topP !== void 0) {
|
|
53
|
+
extras.top_p = this.#opts.topP;
|
|
54
|
+
}
|
|
55
|
+
if (this.#opts.presencePenalty !== void 0) {
|
|
56
|
+
extras.presence_penalty = this.#opts.presencePenalty;
|
|
57
|
+
}
|
|
58
|
+
if (this.#opts.frequencyPenalty !== void 0) {
|
|
59
|
+
extras.frequency_penalty = this.#opts.frequencyPenalty;
|
|
60
|
+
}
|
|
52
61
|
if (this.#opts.serviceTier) {
|
|
53
62
|
extras.service_tier = this.#opts.serviceTier;
|
|
54
63
|
}
|
|
@@ -99,6 +108,9 @@ class LLM extends OpenAILLM {
|
|
|
99
108
|
apiKey,
|
|
100
109
|
baseURL: "https://inference.baseten.co/v1",
|
|
101
110
|
temperature: opts.temperature,
|
|
111
|
+
topP: opts.topP,
|
|
112
|
+
presencePenalty: opts.presencePenalty,
|
|
113
|
+
frequencyPenalty: opts.frequencyPenalty,
|
|
102
114
|
user: opts.user,
|
|
103
115
|
maxCompletionTokens: opts.maxTokens,
|
|
104
116
|
toolChoice: opts.toolChoice,
|
package/dist/llm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/llm.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Baseten LLM plugin for LiveKit Agents\n * Configures the OpenAI plugin to work with Baseten's OpenAI-compatible API\n */\nimport type { APIConnectOptions } from '@livekit/agents';\nimport { DEFAULT_API_CONNECT_OPTIONS, inference, llm } from '@livekit/agents';\nimport { OpenAI } from 'openai';\nimport type { BasetenLLMOptions } from './types.js';\n\nexport interface LLMOptions {\n model: string;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n client?: OpenAI;\n toolChoice?: llm.ToolChoice;\n parallelToolCalls?: boolean;\n metadata?: Record<string, string>;\n maxCompletionTokens?: number;\n serviceTier?: string;\n store?: boolean;\n strictToolSchema?: boolean;\n}\n\nconst defaultLLMOptions: LLMOptions = {\n model: 'openai/gpt-4o-mini',\n apiKey: process.env.OPENAI_API_KEY,\n parallelToolCalls: true,\n strictToolSchema: false,\n};\n\nexport class OpenAILLM extends llm.LLM {\n #opts: LLMOptions;\n #client: OpenAI;\n #providerFmt: llm.ProviderFormat;\n\n constructor(\n opts: Partial<LLMOptions> = defaultLLMOptions,\n providerFmt: llm.ProviderFormat = 'openai',\n ) {\n super();\n\n this.#opts = { ...defaultLLMOptions, ...opts };\n this.#providerFmt = providerFmt;\n if (this.#opts.apiKey === undefined) {\n throw new Error('OpenAI API key is required, whether as an argument or as $OPENAI_API_KEY');\n }\n\n this.#client =\n this.#opts.client ||\n new OpenAI({\n baseURL: opts.baseURL,\n apiKey: opts.apiKey,\n });\n }\n\n label(): string {\n return 'openai.LLM';\n }\n\n get model(): string {\n return this.#opts.model;\n }\n\n chat({\n chatCtx,\n toolCtx,\n connOptions = DEFAULT_API_CONNECT_OPTIONS,\n parallelToolCalls,\n toolChoice,\n extraKwargs,\n }: {\n chatCtx: llm.ChatContext;\n toolCtx?: llm.ToolContext;\n connOptions?: APIConnectOptions;\n parallelToolCalls?: boolean;\n toolChoice?: llm.ToolChoice;\n extraKwargs?: Record<string, unknown>;\n }): inference.LLMStream {\n const extras: Record<string, unknown> = { ...extraKwargs };\n\n if (this.#opts.metadata) {\n extras.metadata = this.#opts.metadata;\n }\n\n if (this.#opts.user) {\n extras.user = this.#opts.user;\n }\n\n if (this.#opts.maxCompletionTokens) {\n extras.max_completion_tokens = this.#opts.maxCompletionTokens;\n }\n\n if (this.#opts.temperature) {\n extras.temperature = this.#opts.temperature;\n }\n\n if (this.#opts.serviceTier) {\n extras.service_tier = this.#opts.serviceTier;\n }\n\n if (this.#opts.store !== undefined) {\n extras.store = this.#opts.store;\n }\n\n parallelToolCalls =\n parallelToolCalls !== undefined ? parallelToolCalls : this.#opts.parallelToolCalls;\n if (toolCtx && Object.keys(toolCtx).length > 0 && parallelToolCalls !== undefined) {\n extras.parallel_tool_calls = parallelToolCalls;\n }\n\n toolChoice = toolChoice !== undefined ? toolChoice : this.#opts.toolChoice;\n if (toolChoice) {\n extras.tool_choice = toolChoice;\n }\n\n return new LLMStream(this as unknown as inference.LLM, {\n model: this.#opts.model,\n providerFmt: this.#providerFmt,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n client: this.#client as any,\n chatCtx,\n toolCtx,\n connOptions,\n modelOptions: extras,\n strictToolSchema: this.#opts.strictToolSchema || false,\n gatewayOptions: undefined, // OpenAI plugin doesn't use gateway authentication\n });\n }\n}\n\nexport class LLMStream extends inference.LLMStream {}\n\nexport class LLM extends OpenAILLM {\n constructor(opts: BasetenLLMOptions) {\n const apiKey = opts.apiKey ?? process.env.BASETEN_API_KEY;\n if (!apiKey) {\n throw new Error(\n 'Baseten API key is required. Set BASETEN_API_KEY environment variable or pass apiKey in options.',\n );\n }\n\n if (!opts.model) {\n throw new Error(\n 'Model is required. Please specify a model name (e.g., \"openai/gpt-4o-mini\").',\n );\n }\n\n const model = opts.model;\n\n // Configure the OpenAI plugin with Baseten's endpoint\n super({\n model,\n apiKey,\n baseURL: 'https://inference.baseten.co/v1',\n temperature: opts.temperature,\n user: opts.user,\n maxCompletionTokens: opts.maxTokens,\n toolChoice: opts.toolChoice,\n parallelToolCalls: opts.parallelToolCalls,\n });\n }\n\n label(): string {\n return 'baseten.LLM';\n }\n}\n"],"mappings":"AASA,SAAS,6BAA6B,WAAW,WAAW;AAC5D,SAAS,cAAc;
|
|
1
|
+
{"version":3,"sources":["../src/llm.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Baseten LLM plugin for LiveKit Agents\n * Configures the OpenAI plugin to work with Baseten's OpenAI-compatible API\n */\nimport type { APIConnectOptions } from '@livekit/agents';\nimport { DEFAULT_API_CONNECT_OPTIONS, inference, llm } from '@livekit/agents';\nimport { OpenAI } from 'openai';\nimport type { BasetenLLMOptions } from './types.js';\n\nexport interface LLMOptions {\n model: string;\n apiKey?: string;\n baseURL?: string;\n user?: string;\n temperature?: number;\n topP?: number;\n presencePenalty?: number;\n frequencyPenalty?: number;\n client?: OpenAI;\n toolChoice?: llm.ToolChoice;\n parallelToolCalls?: boolean;\n metadata?: Record<string, string>;\n maxCompletionTokens?: number;\n serviceTier?: string;\n store?: boolean;\n strictToolSchema?: boolean;\n}\n\nconst defaultLLMOptions: LLMOptions = {\n model: 'openai/gpt-4o-mini',\n apiKey: process.env.OPENAI_API_KEY,\n parallelToolCalls: true,\n strictToolSchema: false,\n};\n\nexport class OpenAILLM extends llm.LLM {\n #opts: LLMOptions;\n #client: OpenAI;\n #providerFmt: llm.ProviderFormat;\n\n constructor(\n opts: Partial<LLMOptions> = defaultLLMOptions,\n providerFmt: llm.ProviderFormat = 'openai',\n ) {\n super();\n\n this.#opts = { ...defaultLLMOptions, ...opts };\n this.#providerFmt = providerFmt;\n if (this.#opts.apiKey === undefined) {\n throw new Error('OpenAI API key is required, whether as an argument or as $OPENAI_API_KEY');\n }\n\n this.#client =\n this.#opts.client ||\n new OpenAI({\n baseURL: opts.baseURL,\n apiKey: opts.apiKey,\n });\n }\n\n label(): string {\n return 'openai.LLM';\n }\n\n get model(): string {\n return this.#opts.model;\n }\n\n chat({\n chatCtx,\n toolCtx,\n connOptions = DEFAULT_API_CONNECT_OPTIONS,\n parallelToolCalls,\n toolChoice,\n extraKwargs,\n }: {\n chatCtx: llm.ChatContext;\n toolCtx?: llm.ToolContext;\n connOptions?: APIConnectOptions;\n parallelToolCalls?: boolean;\n toolChoice?: llm.ToolChoice;\n extraKwargs?: Record<string, unknown>;\n }): inference.LLMStream {\n const extras: Record<string, unknown> = { ...extraKwargs };\n\n if (this.#opts.metadata) {\n extras.metadata = this.#opts.metadata;\n }\n\n if (this.#opts.user) {\n extras.user = this.#opts.user;\n }\n\n if (this.#opts.maxCompletionTokens) {\n extras.max_completion_tokens = this.#opts.maxCompletionTokens;\n }\n\n if (this.#opts.temperature !== undefined) {\n extras.temperature = this.#opts.temperature;\n }\n\n if (this.#opts.topP !== undefined) {\n extras.top_p = this.#opts.topP;\n }\n\n if (this.#opts.presencePenalty !== undefined) {\n extras.presence_penalty = this.#opts.presencePenalty;\n }\n\n if (this.#opts.frequencyPenalty !== undefined) {\n extras.frequency_penalty = this.#opts.frequencyPenalty;\n }\n\n if (this.#opts.serviceTier) {\n extras.service_tier = this.#opts.serviceTier;\n }\n\n if (this.#opts.store !== undefined) {\n extras.store = this.#opts.store;\n }\n\n parallelToolCalls =\n parallelToolCalls !== undefined ? parallelToolCalls : this.#opts.parallelToolCalls;\n if (toolCtx && Object.keys(toolCtx).length > 0 && parallelToolCalls !== undefined) {\n extras.parallel_tool_calls = parallelToolCalls;\n }\n\n toolChoice = toolChoice !== undefined ? toolChoice : this.#opts.toolChoice;\n if (toolChoice) {\n extras.tool_choice = toolChoice;\n }\n\n return new LLMStream(this as unknown as inference.LLM, {\n model: this.#opts.model,\n providerFmt: this.#providerFmt,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n client: this.#client as any,\n chatCtx,\n toolCtx,\n connOptions,\n modelOptions: extras,\n strictToolSchema: this.#opts.strictToolSchema || false,\n gatewayOptions: undefined, // OpenAI plugin doesn't use gateway authentication\n });\n }\n}\n\nexport class LLMStream extends inference.LLMStream {}\n\nexport class LLM extends OpenAILLM {\n constructor(opts: BasetenLLMOptions) {\n const apiKey = opts.apiKey ?? process.env.BASETEN_API_KEY;\n if (!apiKey) {\n throw new Error(\n 'Baseten API key is required. Set BASETEN_API_KEY environment variable or pass apiKey in options.',\n );\n }\n\n if (!opts.model) {\n throw new Error(\n 'Model is required. Please specify a model name (e.g., \"openai/gpt-4o-mini\").',\n );\n }\n\n const model = opts.model;\n\n // Configure the OpenAI plugin with Baseten's endpoint\n super({\n model,\n apiKey,\n baseURL: 'https://inference.baseten.co/v1',\n temperature: opts.temperature,\n topP: opts.topP,\n presencePenalty: opts.presencePenalty,\n frequencyPenalty: opts.frequencyPenalty,\n user: opts.user,\n maxCompletionTokens: opts.maxTokens,\n toolChoice: opts.toolChoice,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ACA,SAAS;AAAA,MACT,aAAa,KAAK;AAAA,MAClB,MAAM,KAAK;AAAA,MACX,iBAAiB,KAAK;AAAA,MACtB,kBAAkB,KAAK;AAAA,MACvB,MAAM,KAAK;AAAA,MACX,qBAAqB,KAAK;AAAA,MAC1B,YAAY,KAAK;AAAA,MACjB,mBAAmB,KAAK;AAAA,IAC1B,CAAC;AAAA,EACH;AAAA,EAEA,QAAgB;AACd,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Baseten plugin types and interfaces\n */\n\n/**\n * Options for configuring the Baseten LLM\n * Since Baseten provides an OpenAI-compatible API, these options\n * map to standard OpenAI parameters.\n */\nexport interface BasetenLLMOptions {\n apiKey?: string;\n model: string;\n temperature?: number;\n maxTokens?: number;\n user?: string;\n toolChoice?: 'none' | 'auto' | 'required' | { type: 'function'; function: { name: string } };\n parallelToolCalls?: boolean;\n}\n\n/**\n * Options for configuring the Baseten STT service\n */\nexport interface BasetenSttOptions {\n apiKey: string;\n /** @deprecated Use modelEndpoint instead */\n modelId?: string;\n /** Full WebSocket endpoint URL (e.g., from Baseten dashboard). Takes priority over modelId. */\n modelEndpoint?: string;\n environment?: string;\n encoding?: string;\n sampleRate?: number;\n bufferSizeSeconds?: number;\n vadThreshold?: number;\n vadMinSilenceDurationMs?: number;\n vadSpeechPadMs?: number;\n enablePartialTranscripts?: boolean;\n partialTranscriptIntervalS?: number;\n finalTranscriptMaxDurationS?: number;\n audioLanguage?: string;\n prompt?: string;\n languageDetectionOnly?: boolean;\n}\n\n/**\n * Options for configuring the Baseten TTS service\n */\nexport interface BasetenTTSOptions {\n apiKey: string;\n modelEndpoint: string;\n voice?: string;\n language?: string;\n temperature?: number;\n maxTokens?: number;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Baseten plugin types and interfaces\n */\n\n/**\n * Options for configuring the Baseten LLM\n * Since Baseten provides an OpenAI-compatible API, these options\n * map to standard OpenAI parameters.\n */\nexport interface BasetenLLMOptions {\n apiKey?: string;\n model: string;\n temperature?: number;\n /** Nucleus sampling parameter. Forwarded to Baseten as `top_p`. */\n topP?: number;\n maxTokens?: number;\n /**\n * Penalty for new tokens based on whether they appear in the text so far.\n * Forwarded to Baseten as `presence_penalty`.\n */\n presencePenalty?: number;\n /**\n * Penalty for new tokens based on their frequency in the text so far.\n * Forwarded to Baseten as `frequency_penalty`.\n */\n frequencyPenalty?: number;\n user?: string;\n toolChoice?: 'none' | 'auto' | 'required' | { type: 'function'; function: { name: string } };\n parallelToolCalls?: boolean;\n}\n\n/**\n * Options for configuring the Baseten STT service\n */\nexport interface BasetenSttOptions {\n apiKey: string;\n /** @deprecated Use modelEndpoint instead */\n modelId?: string;\n /** Full WebSocket endpoint URL (e.g., from Baseten dashboard). Takes priority over modelId. */\n modelEndpoint?: string;\n environment?: string;\n encoding?: string;\n sampleRate?: number;\n bufferSizeSeconds?: number;\n vadThreshold?: number;\n vadMinSilenceDurationMs?: number;\n vadSpeechPadMs?: number;\n enablePartialTranscripts?: boolean;\n partialTranscriptIntervalS?: number;\n finalTranscriptMaxDurationS?: number;\n audioLanguage?: string;\n prompt?: string;\n languageDetectionOnly?: boolean;\n}\n\n/**\n * Options for configuring the Baseten TTS service\n */\nexport interface BasetenTTSOptions {\n apiKey: string;\n modelEndpoint: string;\n voice?: string;\n language?: string;\n temperature?: number;\n maxTokens?: number;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/types.d.cts
CHANGED
|
@@ -10,7 +10,19 @@ export interface BasetenLLMOptions {
|
|
|
10
10
|
apiKey?: string;
|
|
11
11
|
model: string;
|
|
12
12
|
temperature?: number;
|
|
13
|
+
/** Nucleus sampling parameter. Forwarded to Baseten as `top_p`. */
|
|
14
|
+
topP?: number;
|
|
13
15
|
maxTokens?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Penalty for new tokens based on whether they appear in the text so far.
|
|
18
|
+
* Forwarded to Baseten as `presence_penalty`.
|
|
19
|
+
*/
|
|
20
|
+
presencePenalty?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Penalty for new tokens based on their frequency in the text so far.
|
|
23
|
+
* Forwarded to Baseten as `frequency_penalty`.
|
|
24
|
+
*/
|
|
25
|
+
frequencyPenalty?: number;
|
|
14
26
|
user?: string;
|
|
15
27
|
toolChoice?: 'none' | 'auto' | 'required' | {
|
|
16
28
|
type: 'function';
|
package/dist/types.d.ts
CHANGED
|
@@ -10,7 +10,19 @@ export interface BasetenLLMOptions {
|
|
|
10
10
|
apiKey?: string;
|
|
11
11
|
model: string;
|
|
12
12
|
temperature?: number;
|
|
13
|
+
/** Nucleus sampling parameter. Forwarded to Baseten as `top_p`. */
|
|
14
|
+
topP?: number;
|
|
13
15
|
maxTokens?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Penalty for new tokens based on whether they appear in the text so far.
|
|
18
|
+
* Forwarded to Baseten as `presence_penalty`.
|
|
19
|
+
*/
|
|
20
|
+
presencePenalty?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Penalty for new tokens based on their frequency in the text so far.
|
|
23
|
+
* Forwarded to Baseten as `frequency_penalty`.
|
|
24
|
+
*/
|
|
25
|
+
frequencyPenalty?: number;
|
|
14
26
|
user?: string;
|
|
15
27
|
toolChoice?: 'none' | 'auto' | 'required' | {
|
|
16
28
|
type: 'function';
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAI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O,CAAC;IACnC,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@livekit/agents-plugin-baseten",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "Baseten plugin for LiveKit Node Agents",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"require": "dist/index.cjs",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"@types/ws": "^8.5.8",
|
|
41
41
|
"tsx": "^4.7.0",
|
|
42
42
|
"typescript": "^5.9.3",
|
|
43
|
-
"@livekit/agents": "1.2.
|
|
44
|
-
"@livekit/agents-plugin-silero": "1.2.
|
|
45
|
-
"@livekit/agents-plugins-test": "1.2.
|
|
43
|
+
"@livekit/agents": "1.2.5",
|
|
44
|
+
"@livekit/agents-plugin-silero": "1.2.5",
|
|
45
|
+
"@livekit/agents-plugins-test": "1.2.5"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"dotenv": "^17.2.3",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@livekit/rtc-node": "^0.13.25",
|
|
54
|
-
"@livekit/agents": "1.2.
|
|
54
|
+
"@livekit/agents": "1.2.5"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsup --onSuccess \"pnpm build:types\"",
|
package/src/llm.ts
CHANGED
|
@@ -17,6 +17,9 @@ export interface LLMOptions {
|
|
|
17
17
|
baseURL?: string;
|
|
18
18
|
user?: string;
|
|
19
19
|
temperature?: number;
|
|
20
|
+
topP?: number;
|
|
21
|
+
presencePenalty?: number;
|
|
22
|
+
frequencyPenalty?: number;
|
|
20
23
|
client?: OpenAI;
|
|
21
24
|
toolChoice?: llm.ToolChoice;
|
|
22
25
|
parallelToolCalls?: boolean;
|
|
@@ -96,10 +99,22 @@ export class OpenAILLM extends llm.LLM {
|
|
|
96
99
|
extras.max_completion_tokens = this.#opts.maxCompletionTokens;
|
|
97
100
|
}
|
|
98
101
|
|
|
99
|
-
if (this.#opts.temperature) {
|
|
102
|
+
if (this.#opts.temperature !== undefined) {
|
|
100
103
|
extras.temperature = this.#opts.temperature;
|
|
101
104
|
}
|
|
102
105
|
|
|
106
|
+
if (this.#opts.topP !== undefined) {
|
|
107
|
+
extras.top_p = this.#opts.topP;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (this.#opts.presencePenalty !== undefined) {
|
|
111
|
+
extras.presence_penalty = this.#opts.presencePenalty;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (this.#opts.frequencyPenalty !== undefined) {
|
|
115
|
+
extras.frequency_penalty = this.#opts.frequencyPenalty;
|
|
116
|
+
}
|
|
117
|
+
|
|
103
118
|
if (this.#opts.serviceTier) {
|
|
104
119
|
extras.service_tier = this.#opts.serviceTier;
|
|
105
120
|
}
|
|
@@ -159,6 +174,9 @@ export class LLM extends OpenAILLM {
|
|
|
159
174
|
apiKey,
|
|
160
175
|
baseURL: 'https://inference.baseten.co/v1',
|
|
161
176
|
temperature: opts.temperature,
|
|
177
|
+
topP: opts.topP,
|
|
178
|
+
presencePenalty: opts.presencePenalty,
|
|
179
|
+
frequencyPenalty: opts.frequencyPenalty,
|
|
162
180
|
user: opts.user,
|
|
163
181
|
maxCompletionTokens: opts.maxTokens,
|
|
164
182
|
toolChoice: opts.toolChoice,
|
package/src/types.ts
CHANGED
|
@@ -15,7 +15,19 @@ export interface BasetenLLMOptions {
|
|
|
15
15
|
apiKey?: string;
|
|
16
16
|
model: string;
|
|
17
17
|
temperature?: number;
|
|
18
|
+
/** Nucleus sampling parameter. Forwarded to Baseten as `top_p`. */
|
|
19
|
+
topP?: number;
|
|
18
20
|
maxTokens?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Penalty for new tokens based on whether they appear in the text so far.
|
|
23
|
+
* Forwarded to Baseten as `presence_penalty`.
|
|
24
|
+
*/
|
|
25
|
+
presencePenalty?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Penalty for new tokens based on their frequency in the text so far.
|
|
28
|
+
* Forwarded to Baseten as `frequency_penalty`.
|
|
29
|
+
*/
|
|
30
|
+
frequencyPenalty?: number;
|
|
19
31
|
user?: string;
|
|
20
32
|
toolChoice?: 'none' | 'auto' | 'required' | { type: 'function'; function: { name: string } };
|
|
21
33
|
parallelToolCalls?: boolean;
|