@livekit/agents-plugin-google 1.0.0-next.0
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/LICENSE +201 -0
- package/README.md +89 -0
- package/dist/beta/gemini_tts.cjs +239 -0
- package/dist/beta/gemini_tts.cjs.map +1 -0
- package/dist/beta/gemini_tts.d.cts +47 -0
- package/dist/beta/gemini_tts.d.ts +47 -0
- package/dist/beta/gemini_tts.d.ts.map +1 -0
- package/dist/beta/gemini_tts.js +221 -0
- package/dist/beta/gemini_tts.js.map +1 -0
- package/dist/beta/gemini_tts.test.cjs +9 -0
- package/dist/beta/gemini_tts.test.cjs.map +1 -0
- package/dist/beta/gemini_tts.test.d.cts +2 -0
- package/dist/beta/gemini_tts.test.d.ts +2 -0
- package/dist/beta/gemini_tts.test.d.ts.map +1 -0
- package/dist/beta/gemini_tts.test.js +8 -0
- package/dist/beta/gemini_tts.test.js.map +1 -0
- package/dist/beta/index.cjs +42 -0
- package/dist/beta/index.cjs.map +1 -0
- package/dist/beta/index.d.cts +3 -0
- package/dist/beta/index.d.ts +3 -0
- package/dist/beta/index.d.ts.map +1 -0
- package/dist/beta/index.js +7 -0
- package/dist/beta/index.js.map +1 -0
- package/dist/beta/realtime/api_proto.cjs +17 -0
- package/dist/beta/realtime/api_proto.cjs.map +1 -0
- package/dist/beta/realtime/api_proto.d.cts +26 -0
- package/dist/beta/realtime/api_proto.d.ts +26 -0
- package/dist/beta/realtime/api_proto.d.ts.map +1 -0
- package/dist/beta/realtime/api_proto.js +1 -0
- package/dist/beta/realtime/api_proto.js.map +1 -0
- package/dist/beta/realtime/index.cjs +29 -0
- package/dist/beta/realtime/index.cjs.map +1 -0
- package/dist/beta/realtime/index.d.cts +3 -0
- package/dist/beta/realtime/index.d.ts +3 -0
- package/dist/beta/realtime/index.d.ts.map +1 -0
- package/dist/beta/realtime/index.js +5 -0
- package/dist/beta/realtime/index.js.map +1 -0
- package/dist/beta/realtime/realtime_api.cjs +993 -0
- package/dist/beta/realtime/realtime_api.cjs.map +1 -0
- package/dist/beta/realtime/realtime_api.d.cts +267 -0
- package/dist/beta/realtime/realtime_api.d.ts +267 -0
- package/dist/beta/realtime/realtime_api.d.ts.map +1 -0
- package/dist/beta/realtime/realtime_api.js +974 -0
- package/dist/beta/realtime/realtime_api.js.map +1 -0
- package/dist/index.cjs +58 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/llm.cjs +381 -0
- package/dist/llm.cjs.map +1 -0
- package/dist/llm.d.cts +82 -0
- package/dist/llm.d.ts +82 -0
- package/dist/llm.d.ts.map +1 -0
- package/dist/llm.js +362 -0
- package/dist/llm.js.map +1 -0
- package/dist/llm.test.cjs +8 -0
- package/dist/llm.test.cjs.map +1 -0
- package/dist/llm.test.d.cts +2 -0
- package/dist/llm.test.d.ts +2 -0
- package/dist/llm.test.d.ts.map +1 -0
- package/dist/llm.test.js +7 -0
- package/dist/llm.test.js.map +1 -0
- package/dist/models.cjs +17 -0
- package/dist/models.cjs.map +1 -0
- package/dist/models.d.cts +5 -0
- package/dist/models.d.ts +5 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +1 -0
- package/dist/models.js.map +1 -0
- package/dist/tools.cjs +17 -0
- package/dist/tools.cjs.map +1 -0
- package/dist/tools.d.cts +3 -0
- package/dist/tools.d.ts +3 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +1 -0
- package/dist/tools.js.map +1 -0
- package/dist/utils.cjs +137 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +14 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +112 -0
- package/dist/utils.js.map +1 -0
- package/package.json +56 -0
- package/src/beta/gemini_tts.test.ts +11 -0
- package/src/beta/gemini_tts.ts +309 -0
- package/src/beta/index.ts +6 -0
- package/src/beta/realtime/api_proto.ts +41 -0
- package/src/beta/realtime/index.ts +5 -0
- package/src/beta/realtime/realtime_api.ts +1440 -0
- package/src/index.ts +20 -0
- package/src/llm.test.ts +10 -0
- package/src/llm.ts +463 -0
- package/src/models.ts +100 -0
- package/src/tools.ts +6 -0
- package/src/utils.ts +157 -0
package/dist/llm.test.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/llm.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { llm } from '@livekit/agents-plugins-test';\nimport { describe } from 'vitest';\nimport { LLM } from './llm.js';\n\ndescribe('Google', async () => {\n await llm(new LLM());\n});\n"],"mappings":"AAGA,SAAS,WAAW;AACpB,SAAS,gBAAgB;AACzB,SAAS,WAAW;AAEpB,SAAS,UAAU,YAAY;AAC7B,QAAM,IAAI,IAAI,IAAI,CAAC;AACrB,CAAC;","names":[]}
|
package/dist/models.cjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var models_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(models_exports);
|
|
17
|
+
//# sourceMappingURL=models.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/models.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n// Speech to Text v2\nexport type SpeechModels =\n | 'long'\n | 'short'\n | 'telephony'\n | 'medical_dictation'\n | 'medical_conversation'\n | 'chirp'\n | 'chirp_2'\n | 'latest_long'\n | 'latest_short';\n\nexport type SpeechLanguages =\n | 'en-US'\n | 'ja-JP'\n | 'en-IN'\n | 'en-GB'\n | 'hi-IN'\n | 'af-ZA'\n | 'sq-AL'\n | 'am-ET'\n | 'ar-EG'\n | 'hy-AM'\n | 'ast-ES'\n | 'az-AZ'\n | 'eu-ES'\n | 'be-BY'\n | 'bs-BA'\n | 'bg-BG'\n | 'my-MM'\n | 'ca-ES'\n | 'ceb-PH'\n | 'ckb-IQ'\n | 'zh-Hans-CN'\n | 'yue-Hant-HK'\n | 'zh-TW'\n | 'hr-HR'\n | 'cs-CZ'\n | 'da-DK'\n | 'nl-NL'\n | 'en-AU'\n | 'et-EE'\n | 'fil-PH'\n | 'fi-FI'\n | 'fr-CA'\n | 'fr-FR'\n | 'gl-ES'\n | 'ka-GE'\n | 'de-DE'\n | 'el-GR'\n | 'gu-IN'\n | 'ha-NG'\n | 'iw-IL'\n | 'hu-HU'\n | 'is-IS'\n | 'id-ID'\n | 'it-IT'\n | 'jv-ID'\n | 'kea-CV'\n | 'kam-KE'\n | 'kn-IN'\n | 'kk-KZ'\n | 'km-KH'\n | 'ko-KR'\n | 'ky-KG'\n | 'lo-LA'\n | 'lv-LV'\n | 'ln-CD'\n | 'lt-LT'\n | 'luo-KE'\n | 'lb-LU'\n | 'mk-MK'\n | 'no-NO'\n | 'pl-PL'\n | 'pt-BR'\n | 'pt-PT'\n | 'ro-RO'\n | 'ru-RU'\n | 'es-CO'\n | 'es-MX'\n | 'es-US'\n | 'th-TH'\n | 'tr-TR'\n | 'uk-UA'\n | 'vi-VN';\n\nexport type Gender = 'male' | 'female' | 'neutral';\n\nexport type ChatModels =\n | 'gemini-2.5-pro-preview-05-06'\n | 'gemini-2.5-flash-preview-04-17'\n | 'gemini-2.5-flash-preview-05-20'\n | 'gemini-2.0-flash-001'\n | 'gemini-2.0-flash-lite-preview-02-05'\n | 'gemini-2.0-pro-exp-02-05'\n | 'gemini-1.5-pro';\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type SpeechModels = 'long' | 'short' | 'telephony' | 'medical_dictation' | 'medical_conversation' | 'chirp' | 'chirp_2' | 'latest_long' | 'latest_short';
|
|
2
|
+
export type SpeechLanguages = 'en-US' | 'ja-JP' | 'en-IN' | 'en-GB' | 'hi-IN' | 'af-ZA' | 'sq-AL' | 'am-ET' | 'ar-EG' | 'hy-AM' | 'ast-ES' | 'az-AZ' | 'eu-ES' | 'be-BY' | 'bs-BA' | 'bg-BG' | 'my-MM' | 'ca-ES' | 'ceb-PH' | 'ckb-IQ' | 'zh-Hans-CN' | 'yue-Hant-HK' | 'zh-TW' | 'hr-HR' | 'cs-CZ' | 'da-DK' | 'nl-NL' | 'en-AU' | 'et-EE' | 'fil-PH' | 'fi-FI' | 'fr-CA' | 'fr-FR' | 'gl-ES' | 'ka-GE' | 'de-DE' | 'el-GR' | 'gu-IN' | 'ha-NG' | 'iw-IL' | 'hu-HU' | 'is-IS' | 'id-ID' | 'it-IT' | 'jv-ID' | 'kea-CV' | 'kam-KE' | 'kn-IN' | 'kk-KZ' | 'km-KH' | 'ko-KR' | 'ky-KG' | 'lo-LA' | 'lv-LV' | 'ln-CD' | 'lt-LT' | 'luo-KE' | 'lb-LU' | 'mk-MK' | 'no-NO' | 'pl-PL' | 'pt-BR' | 'pt-PT' | 'ro-RO' | 'ru-RU' | 'es-CO' | 'es-MX' | 'es-US' | 'th-TH' | 'tr-TR' | 'uk-UA' | 'vi-VN';
|
|
3
|
+
export type Gender = 'male' | 'female' | 'neutral';
|
|
4
|
+
export type ChatModels = 'gemini-2.5-pro-preview-05-06' | 'gemini-2.5-flash-preview-04-17' | 'gemini-2.5-flash-preview-05-20' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite-preview-02-05' | 'gemini-2.0-pro-exp-02-05' | 'gemini-1.5-pro';
|
|
5
|
+
//# sourceMappingURL=models.d.ts.map
|
package/dist/models.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type SpeechModels = 'long' | 'short' | 'telephony' | 'medical_dictation' | 'medical_conversation' | 'chirp' | 'chirp_2' | 'latest_long' | 'latest_short';
|
|
2
|
+
export type SpeechLanguages = 'en-US' | 'ja-JP' | 'en-IN' | 'en-GB' | 'hi-IN' | 'af-ZA' | 'sq-AL' | 'am-ET' | 'ar-EG' | 'hy-AM' | 'ast-ES' | 'az-AZ' | 'eu-ES' | 'be-BY' | 'bs-BA' | 'bg-BG' | 'my-MM' | 'ca-ES' | 'ceb-PH' | 'ckb-IQ' | 'zh-Hans-CN' | 'yue-Hant-HK' | 'zh-TW' | 'hr-HR' | 'cs-CZ' | 'da-DK' | 'nl-NL' | 'en-AU' | 'et-EE' | 'fil-PH' | 'fi-FI' | 'fr-CA' | 'fr-FR' | 'gl-ES' | 'ka-GE' | 'de-DE' | 'el-GR' | 'gu-IN' | 'ha-NG' | 'iw-IL' | 'hu-HU' | 'is-IS' | 'id-ID' | 'it-IT' | 'jv-ID' | 'kea-CV' | 'kam-KE' | 'kn-IN' | 'kk-KZ' | 'km-KH' | 'ko-KR' | 'ky-KG' | 'lo-LA' | 'lv-LV' | 'ln-CD' | 'lt-LT' | 'luo-KE' | 'lb-LU' | 'mk-MK' | 'no-NO' | 'pl-PL' | 'pt-BR' | 'pt-PT' | 'ro-RO' | 'ru-RU' | 'es-CO' | 'es-MX' | 'es-US' | 'th-TH' | 'tr-TR' | 'uk-UA' | 'vi-VN';
|
|
3
|
+
export type Gender = 'male' | 'female' | 'neutral';
|
|
4
|
+
export type ChatModels = 'gemini-2.5-pro-preview-05-06' | 'gemini-2.5-flash-preview-04-17' | 'gemini-2.5-flash-preview-05-20' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite-preview-02-05' | 'gemini-2.0-pro-exp-02-05' | 'gemini-1.5-pro';
|
|
5
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,OAAO,GACP,WAAW,GACX,mBAAmB,GACnB,sBAAsB,GACtB,OAAO,GACP,SAAS,GACT,aAAa,GACb,cAAc,CAAC;AAEnB,MAAM,MAAM,eAAe,GACvB,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,YAAY,GACZ,aAAa,GACb,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,CAAC;AAEZ,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEnD,MAAM,MAAM,UAAU,GAClB,8BAA8B,GAC9B,gCAAgC,GAChC,gCAAgC,GAChC,sBAAsB,GACtB,qCAAqC,GACrC,0BAA0B,GAC1B,gBAAgB,CAAC"}
|
package/dist/models.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/tools.cjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var tools_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(tools_exports);
|
|
17
|
+
//# sourceMappingURL=tools.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tools.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { Tool } from '@google/genai';\n\nexport type LLMTools = Omit<Tool, 'functionDeclarations'>;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/tools.d.cts
ADDED
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC"}
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils.cjs
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
convertJSONSchemaToOpenAPISchema: () => convertJSONSchemaToOpenAPISchema,
|
|
22
|
+
toFunctionDeclarations: () => toFunctionDeclarations
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(utils_exports);
|
|
25
|
+
var import_agents = require("@livekit/agents");
|
|
26
|
+
function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
|
27
|
+
if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
if (typeof jsonSchema === "boolean") {
|
|
31
|
+
return { type: "boolean", properties: {} };
|
|
32
|
+
}
|
|
33
|
+
const {
|
|
34
|
+
type,
|
|
35
|
+
description,
|
|
36
|
+
required,
|
|
37
|
+
properties,
|
|
38
|
+
items,
|
|
39
|
+
allOf,
|
|
40
|
+
anyOf,
|
|
41
|
+
oneOf,
|
|
42
|
+
format,
|
|
43
|
+
const: constValue,
|
|
44
|
+
minLength,
|
|
45
|
+
enum: enumValues
|
|
46
|
+
} = jsonSchema;
|
|
47
|
+
const result = {};
|
|
48
|
+
if (description) result.description = description;
|
|
49
|
+
if (required) result.required = required;
|
|
50
|
+
if (format) result.format = format;
|
|
51
|
+
if (constValue !== void 0) {
|
|
52
|
+
result.enum = [constValue];
|
|
53
|
+
}
|
|
54
|
+
if (type) {
|
|
55
|
+
if (Array.isArray(type)) {
|
|
56
|
+
if (type.includes("null")) {
|
|
57
|
+
result.type = type.filter((t) => t !== "null")[0];
|
|
58
|
+
result.nullable = true;
|
|
59
|
+
} else {
|
|
60
|
+
result.type = type;
|
|
61
|
+
}
|
|
62
|
+
} else if (type === "null") {
|
|
63
|
+
result.type = "null";
|
|
64
|
+
} else {
|
|
65
|
+
result.type = type;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (enumValues !== void 0) {
|
|
69
|
+
result.enum = enumValues;
|
|
70
|
+
}
|
|
71
|
+
if (properties != null) {
|
|
72
|
+
result.properties = Object.entries(properties).reduce(
|
|
73
|
+
(acc, [key, value]) => {
|
|
74
|
+
acc[key] = convertJSONSchemaToOpenAPISchema(value);
|
|
75
|
+
return acc;
|
|
76
|
+
},
|
|
77
|
+
{}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
if (items) {
|
|
81
|
+
result.items = Array.isArray(items) ? items.map(convertJSONSchemaToOpenAPISchema) : convertJSONSchemaToOpenAPISchema(items);
|
|
82
|
+
}
|
|
83
|
+
if (allOf) {
|
|
84
|
+
result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);
|
|
85
|
+
}
|
|
86
|
+
if (anyOf) {
|
|
87
|
+
if (anyOf.some((schema) => typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")) {
|
|
88
|
+
const nonNullSchemas = anyOf.filter(
|
|
89
|
+
(schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
|
|
90
|
+
);
|
|
91
|
+
if (nonNullSchemas.length === 1) {
|
|
92
|
+
const converted = convertJSONSchemaToOpenAPISchema(
|
|
93
|
+
nonNullSchemas[0]
|
|
94
|
+
);
|
|
95
|
+
if (typeof converted === "object") {
|
|
96
|
+
result.nullable = true;
|
|
97
|
+
Object.assign(result, converted);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);
|
|
101
|
+
result.nullable = true;
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (oneOf) {
|
|
108
|
+
result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);
|
|
109
|
+
}
|
|
110
|
+
if (minLength !== void 0) {
|
|
111
|
+
result.minLength = minLength;
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
function isEmptyObjectSchema(jsonSchema) {
|
|
116
|
+
return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
|
|
117
|
+
}
|
|
118
|
+
function toFunctionDeclarations(toolCtx) {
|
|
119
|
+
const functionDeclarations = [];
|
|
120
|
+
for (const [name, tool] of Object.entries(toolCtx)) {
|
|
121
|
+
const { description, parameters } = tool;
|
|
122
|
+
const jsonSchema = import_agents.llm.toJsonSchema(parameters);
|
|
123
|
+
const schemaCopy = JSON.parse(JSON.stringify(jsonSchema));
|
|
124
|
+
functionDeclarations.push({
|
|
125
|
+
name,
|
|
126
|
+
description,
|
|
127
|
+
parameters: convertJSONSchemaToOpenAPISchema(schemaCopy)
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return functionDeclarations;
|
|
131
|
+
}
|
|
132
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
133
|
+
0 && (module.exports = {
|
|
134
|
+
convertJSONSchemaToOpenAPISchema,
|
|
135
|
+
toFunctionDeclarations
|
|
136
|
+
});
|
|
137
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { FunctionDeclaration, Schema } from '@google/genai';\nimport { llm } from '@livekit/agents';\nimport type { JSONSchema7 } from 'json-schema';\n\n/**\n * JSON Schema v7\n * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01\n */\nexport type JSONSchema7Definition = JSONSchema7 | boolean;\n\n/**\n * Converts JSON Schema 7 to OpenAPI Schema 3.0\n */\n// Adapted from https://github.com/vercel/ai/blob/main/packages/google/src/convert-json-schema-to-openapi-schema.ts\nexport function convertJSONSchemaToOpenAPISchema(jsonSchema: JSONSchema7Definition): unknown {\n // parameters need to be undefined if they are empty objects:\n if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {\n return undefined;\n }\n\n if (typeof jsonSchema === 'boolean') {\n return { type: 'boolean', properties: {} };\n }\n\n const {\n type,\n description,\n required,\n properties,\n items,\n allOf,\n anyOf,\n oneOf,\n format,\n const: constValue,\n minLength,\n enum: enumValues,\n } = jsonSchema;\n\n const result: Record<string, unknown> = {};\n\n if (description) result.description = description;\n if (required) result.required = required;\n if (format) result.format = format;\n\n if (constValue !== undefined) {\n result.enum = [constValue];\n }\n\n // Handle type\n if (type) {\n if (Array.isArray(type)) {\n if (type.includes('null')) {\n result.type = type.filter((t) => t !== 'null')[0];\n result.nullable = true;\n } else {\n result.type = type;\n }\n } else if (type === 'null') {\n result.type = 'null';\n } else {\n result.type = type;\n }\n }\n\n // Handle enum\n if (enumValues !== undefined) {\n result.enum = enumValues;\n }\n\n if (properties != null) {\n result.properties = Object.entries(properties).reduce(\n (acc, [key, value]) => {\n acc[key] = convertJSONSchemaToOpenAPISchema(value);\n return acc;\n },\n {} as Record<string, unknown>,\n );\n }\n\n if (items) {\n result.items = Array.isArray(items)\n ? items.map(convertJSONSchemaToOpenAPISchema)\n : convertJSONSchemaToOpenAPISchema(items);\n }\n\n if (allOf) {\n result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);\n }\n if (anyOf) {\n // Handle cases where anyOf includes a null type\n if (anyOf.some((schema) => typeof schema === 'object' && schema?.type === 'null')) {\n const nonNullSchemas = anyOf.filter(\n (schema) => !(typeof schema === 'object' && schema?.type === 'null'),\n );\n\n if (nonNullSchemas.length === 1) {\n // If there's only one non-null schema, convert it and make it nullable\n const converted = convertJSONSchemaToOpenAPISchema(\n nonNullSchemas[0] as JSONSchema7Definition,\n );\n if (typeof converted === 'object') {\n result.nullable = true;\n Object.assign(result, converted);\n }\n } else {\n // If there are multiple non-null schemas, keep them in anyOf\n result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);\n result.nullable = true;\n }\n } else {\n result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);\n }\n }\n if (oneOf) {\n result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);\n }\n\n if (minLength !== undefined) {\n result.minLength = minLength;\n }\n\n return result;\n}\n\nfunction isEmptyObjectSchema(jsonSchema: JSONSchema7Definition): boolean {\n return (\n jsonSchema != null &&\n typeof jsonSchema === 'object' &&\n jsonSchema.type === 'object' &&\n (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) &&\n !jsonSchema.additionalProperties\n );\n}\n\nexport function toFunctionDeclarations(toolCtx: llm.ToolContext): FunctionDeclaration[] {\n const functionDeclarations: FunctionDeclaration[] = [];\n\n for (const [name, tool] of Object.entries(toolCtx)) {\n const { description, parameters } = tool;\n const jsonSchema = llm.toJsonSchema(parameters);\n\n // Create a deep copy to prevent the Google GenAI library from mutating the schema\n const schemaCopy = JSON.parse(JSON.stringify(jsonSchema));\n\n functionDeclarations.push({\n name,\n description,\n parameters: convertJSONSchemaToOpenAPISchema(schemaCopy) as Schema,\n });\n }\n\n return functionDeclarations;\n}\n"],"mappings":"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","names":[]}
|
package/dist/utils.d.cts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FunctionDeclaration } from '@google/genai';
|
|
2
|
+
import { llm } from '@livekit/agents';
|
|
3
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
4
|
+
/**
|
|
5
|
+
* JSON Schema v7
|
|
6
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
|
|
7
|
+
*/
|
|
8
|
+
export type JSONSchema7Definition = JSONSchema7 | boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Converts JSON Schema 7 to OpenAPI Schema 3.0
|
|
11
|
+
*/
|
|
12
|
+
export declare function convertJSONSchemaToOpenAPISchema(jsonSchema: JSONSchema7Definition): unknown;
|
|
13
|
+
export declare function toFunctionDeclarations(toolCtx: llm.ToolContext): FunctionDeclaration[];
|
|
14
|
+
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FunctionDeclaration } from '@google/genai';
|
|
2
|
+
import { llm } from '@livekit/agents';
|
|
3
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
4
|
+
/**
|
|
5
|
+
* JSON Schema v7
|
|
6
|
+
* @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
|
|
7
|
+
*/
|
|
8
|
+
export type JSONSchema7Definition = JSONSchema7 | boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Converts JSON Schema 7 to OpenAPI Schema 3.0
|
|
11
|
+
*/
|
|
12
|
+
export declare function convertJSONSchemaToOpenAPISchema(jsonSchema: JSONSchema7Definition): unknown;
|
|
13
|
+
export declare function toFunctionDeclarations(toolCtx: llm.ToolContext): FunctionDeclaration[];
|
|
14
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAU,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG,OAAO,CAAC;AAE1D;;GAEG;AAEH,wBAAgB,gCAAgC,CAAC,UAAU,EAAE,qBAAqB,GAAG,OAAO,CA6G3F;AAYD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,GAAG,CAAC,WAAW,GAAG,mBAAmB,EAAE,CAkBtF"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { llm } from "@livekit/agents";
|
|
2
|
+
function convertJSONSchemaToOpenAPISchema(jsonSchema) {
|
|
3
|
+
if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {
|
|
4
|
+
return void 0;
|
|
5
|
+
}
|
|
6
|
+
if (typeof jsonSchema === "boolean") {
|
|
7
|
+
return { type: "boolean", properties: {} };
|
|
8
|
+
}
|
|
9
|
+
const {
|
|
10
|
+
type,
|
|
11
|
+
description,
|
|
12
|
+
required,
|
|
13
|
+
properties,
|
|
14
|
+
items,
|
|
15
|
+
allOf,
|
|
16
|
+
anyOf,
|
|
17
|
+
oneOf,
|
|
18
|
+
format,
|
|
19
|
+
const: constValue,
|
|
20
|
+
minLength,
|
|
21
|
+
enum: enumValues
|
|
22
|
+
} = jsonSchema;
|
|
23
|
+
const result = {};
|
|
24
|
+
if (description) result.description = description;
|
|
25
|
+
if (required) result.required = required;
|
|
26
|
+
if (format) result.format = format;
|
|
27
|
+
if (constValue !== void 0) {
|
|
28
|
+
result.enum = [constValue];
|
|
29
|
+
}
|
|
30
|
+
if (type) {
|
|
31
|
+
if (Array.isArray(type)) {
|
|
32
|
+
if (type.includes("null")) {
|
|
33
|
+
result.type = type.filter((t) => t !== "null")[0];
|
|
34
|
+
result.nullable = true;
|
|
35
|
+
} else {
|
|
36
|
+
result.type = type;
|
|
37
|
+
}
|
|
38
|
+
} else if (type === "null") {
|
|
39
|
+
result.type = "null";
|
|
40
|
+
} else {
|
|
41
|
+
result.type = type;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (enumValues !== void 0) {
|
|
45
|
+
result.enum = enumValues;
|
|
46
|
+
}
|
|
47
|
+
if (properties != null) {
|
|
48
|
+
result.properties = Object.entries(properties).reduce(
|
|
49
|
+
(acc, [key, value]) => {
|
|
50
|
+
acc[key] = convertJSONSchemaToOpenAPISchema(value);
|
|
51
|
+
return acc;
|
|
52
|
+
},
|
|
53
|
+
{}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (items) {
|
|
57
|
+
result.items = Array.isArray(items) ? items.map(convertJSONSchemaToOpenAPISchema) : convertJSONSchemaToOpenAPISchema(items);
|
|
58
|
+
}
|
|
59
|
+
if (allOf) {
|
|
60
|
+
result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);
|
|
61
|
+
}
|
|
62
|
+
if (anyOf) {
|
|
63
|
+
if (anyOf.some((schema) => typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")) {
|
|
64
|
+
const nonNullSchemas = anyOf.filter(
|
|
65
|
+
(schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
|
|
66
|
+
);
|
|
67
|
+
if (nonNullSchemas.length === 1) {
|
|
68
|
+
const converted = convertJSONSchemaToOpenAPISchema(
|
|
69
|
+
nonNullSchemas[0]
|
|
70
|
+
);
|
|
71
|
+
if (typeof converted === "object") {
|
|
72
|
+
result.nullable = true;
|
|
73
|
+
Object.assign(result, converted);
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);
|
|
77
|
+
result.nullable = true;
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (oneOf) {
|
|
84
|
+
result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);
|
|
85
|
+
}
|
|
86
|
+
if (minLength !== void 0) {
|
|
87
|
+
result.minLength = minLength;
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
function isEmptyObjectSchema(jsonSchema) {
|
|
92
|
+
return jsonSchema != null && typeof jsonSchema === "object" && jsonSchema.type === "object" && (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) && !jsonSchema.additionalProperties;
|
|
93
|
+
}
|
|
94
|
+
function toFunctionDeclarations(toolCtx) {
|
|
95
|
+
const functionDeclarations = [];
|
|
96
|
+
for (const [name, tool] of Object.entries(toolCtx)) {
|
|
97
|
+
const { description, parameters } = tool;
|
|
98
|
+
const jsonSchema = llm.toJsonSchema(parameters);
|
|
99
|
+
const schemaCopy = JSON.parse(JSON.stringify(jsonSchema));
|
|
100
|
+
functionDeclarations.push({
|
|
101
|
+
name,
|
|
102
|
+
description,
|
|
103
|
+
parameters: convertJSONSchemaToOpenAPISchema(schemaCopy)
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return functionDeclarations;
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
convertJSONSchemaToOpenAPISchema,
|
|
110
|
+
toFunctionDeclarations
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { FunctionDeclaration, Schema } from '@google/genai';\nimport { llm } from '@livekit/agents';\nimport type { JSONSchema7 } from 'json-schema';\n\n/**\n * JSON Schema v7\n * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01\n */\nexport type JSONSchema7Definition = JSONSchema7 | boolean;\n\n/**\n * Converts JSON Schema 7 to OpenAPI Schema 3.0\n */\n// Adapted from https://github.com/vercel/ai/blob/main/packages/google/src/convert-json-schema-to-openapi-schema.ts\nexport function convertJSONSchemaToOpenAPISchema(jsonSchema: JSONSchema7Definition): unknown {\n // parameters need to be undefined if they are empty objects:\n if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {\n return undefined;\n }\n\n if (typeof jsonSchema === 'boolean') {\n return { type: 'boolean', properties: {} };\n }\n\n const {\n type,\n description,\n required,\n properties,\n items,\n allOf,\n anyOf,\n oneOf,\n format,\n const: constValue,\n minLength,\n enum: enumValues,\n } = jsonSchema;\n\n const result: Record<string, unknown> = {};\n\n if (description) result.description = description;\n if (required) result.required = required;\n if (format) result.format = format;\n\n if (constValue !== undefined) {\n result.enum = [constValue];\n }\n\n // Handle type\n if (type) {\n if (Array.isArray(type)) {\n if (type.includes('null')) {\n result.type = type.filter((t) => t !== 'null')[0];\n result.nullable = true;\n } else {\n result.type = type;\n }\n } else if (type === 'null') {\n result.type = 'null';\n } else {\n result.type = type;\n }\n }\n\n // Handle enum\n if (enumValues !== undefined) {\n result.enum = enumValues;\n }\n\n if (properties != null) {\n result.properties = Object.entries(properties).reduce(\n (acc, [key, value]) => {\n acc[key] = convertJSONSchemaToOpenAPISchema(value);\n return acc;\n },\n {} as Record<string, unknown>,\n );\n }\n\n if (items) {\n result.items = Array.isArray(items)\n ? items.map(convertJSONSchemaToOpenAPISchema)\n : convertJSONSchemaToOpenAPISchema(items);\n }\n\n if (allOf) {\n result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);\n }\n if (anyOf) {\n // Handle cases where anyOf includes a null type\n if (anyOf.some((schema) => typeof schema === 'object' && schema?.type === 'null')) {\n const nonNullSchemas = anyOf.filter(\n (schema) => !(typeof schema === 'object' && schema?.type === 'null'),\n );\n\n if (nonNullSchemas.length === 1) {\n // If there's only one non-null schema, convert it and make it nullable\n const converted = convertJSONSchemaToOpenAPISchema(\n nonNullSchemas[0] as JSONSchema7Definition,\n );\n if (typeof converted === 'object') {\n result.nullable = true;\n Object.assign(result, converted);\n }\n } else {\n // If there are multiple non-null schemas, keep them in anyOf\n result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);\n result.nullable = true;\n }\n } else {\n result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);\n }\n }\n if (oneOf) {\n result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);\n }\n\n if (minLength !== undefined) {\n result.minLength = minLength;\n }\n\n return result;\n}\n\nfunction isEmptyObjectSchema(jsonSchema: JSONSchema7Definition): boolean {\n return (\n jsonSchema != null &&\n typeof jsonSchema === 'object' &&\n jsonSchema.type === 'object' &&\n (jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0) &&\n !jsonSchema.additionalProperties\n );\n}\n\nexport function toFunctionDeclarations(toolCtx: llm.ToolContext): FunctionDeclaration[] {\n const functionDeclarations: FunctionDeclaration[] = [];\n\n for (const [name, tool] of Object.entries(toolCtx)) {\n const { description, parameters } = tool;\n const jsonSchema = llm.toJsonSchema(parameters);\n\n // Create a deep copy to prevent the Google GenAI library from mutating the schema\n const schemaCopy = JSON.parse(JSON.stringify(jsonSchema));\n\n functionDeclarations.push({\n name,\n description,\n parameters: convertJSONSchemaToOpenAPISchema(schemaCopy) as Schema,\n });\n }\n\n return functionDeclarations;\n}\n"],"mappings":"AAIA,SAAS,WAAW;AAab,SAAS,iCAAiC,YAA4C;AAE3F,MAAI,cAAc,QAAQ,oBAAoB,UAAU,GAAG;AACzD,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,eAAe,WAAW;AACnC,WAAO,EAAE,MAAM,WAAW,YAAY,CAAC,EAAE;AAAA,EAC3C;AAEA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,MAAM;AAAA,EACR,IAAI;AAEJ,QAAM,SAAkC,CAAC;AAEzC,MAAI,YAAa,QAAO,cAAc;AACtC,MAAI,SAAU,QAAO,WAAW;AAChC,MAAI,OAAQ,QAAO,SAAS;AAE5B,MAAI,eAAe,QAAW;AAC5B,WAAO,OAAO,CAAC,UAAU;AAAA,EAC3B;AAGA,MAAI,MAAM;AACR,QAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,UAAI,KAAK,SAAS,MAAM,GAAG;AACzB,eAAO,OAAO,KAAK,OAAO,CAAC,MAAM,MAAM,MAAM,EAAE,CAAC;AAChD,eAAO,WAAW;AAAA,MACpB,OAAO;AACL,eAAO,OAAO;AAAA,MAChB;AAAA,IACF,WAAW,SAAS,QAAQ;AAC1B,aAAO,OAAO;AAAA,IAChB,OAAO;AACL,aAAO,OAAO;AAAA,IAChB;AAAA,EACF;AAGA,MAAI,eAAe,QAAW;AAC5B,WAAO,OAAO;AAAA,EAChB;AAEA,MAAI,cAAc,MAAM;AACtB,WAAO,aAAa,OAAO,QAAQ,UAAU,EAAE;AAAA,MAC7C,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM;AACrB,YAAI,GAAG,IAAI,iCAAiC,KAAK;AACjD,eAAO;AAAA,MACT;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,OAAO;AACT,WAAO,QAAQ,MAAM,QAAQ,KAAK,IAC9B,MAAM,IAAI,gCAAgC,IAC1C,iCAAiC,KAAK;AAAA,EAC5C;AAEA,MAAI,OAAO;AACT,WAAO,QAAQ,MAAM,IAAI,gCAAgC;AAAA,EAC3D;AACA,MAAI,OAAO;AAET,QAAI,MAAM,KAAK,CAAC,WAAW,OAAO,WAAW,aAAY,iCAAQ,UAAS,MAAM,GAAG;AACjF,YAAM,iBAAiB,MAAM;AAAA,QAC3B,CAAC,WAAW,EAAE,OAAO,WAAW,aAAY,iCAAQ,UAAS;AAAA,MAC/D;AAEA,UAAI,eAAe,WAAW,GAAG;AAE/B,cAAM,YAAY;AAAA,UAChB,eAAe,CAAC;AAAA,QAClB;AACA,YAAI,OAAO,cAAc,UAAU;AACjC,iBAAO,WAAW;AAClB,iBAAO,OAAO,QAAQ,SAAS;AAAA,QACjC;AAAA,MACF,OAAO;AAEL,eAAO,QAAQ,eAAe,IAAI,gCAAgC;AAClE,eAAO,WAAW;AAAA,MACpB;AAAA,IACF,OAAO;AACL,aAAO,QAAQ,MAAM,IAAI,gCAAgC;AAAA,IAC3D;AAAA,EACF;AACA,MAAI,OAAO;AACT,WAAO,QAAQ,MAAM,IAAI,gCAAgC;AAAA,EAC3D;AAEA,MAAI,cAAc,QAAW;AAC3B,WAAO,YAAY;AAAA,EACrB;AAEA,SAAO;AACT;AAEA,SAAS,oBAAoB,YAA4C;AACvE,SACE,cAAc,QACd,OAAO,eAAe,YACtB,WAAW,SAAS,aACnB,WAAW,cAAc,QAAQ,OAAO,KAAK,WAAW,UAAU,EAAE,WAAW,MAChF,CAAC,WAAW;AAEhB;AAEO,SAAS,uBAAuB,SAAiD;AACtF,QAAM,uBAA8C,CAAC;AAErD,aAAW,CAAC,MAAM,IAAI,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,UAAM,EAAE,aAAa,WAAW,IAAI;AACpC,UAAM,aAAa,IAAI,aAAa,UAAU;AAG9C,UAAM,aAAa,KAAK,MAAM,KAAK,UAAU,UAAU,CAAC;AAExD,yBAAqB,KAAK;AAAA,MACxB;AAAA,MACA;AAAA,MACA,YAAY,iCAAiC,UAAU;AAAA,IACzD,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@livekit/agents-plugin-google",
|
|
3
|
+
"version": "1.0.0-next.0",
|
|
4
|
+
"description": "Google Gemini plugin for LiveKit Node Agents",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"require": "dist/index.cjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"import": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"require": {
|
|
14
|
+
"types": "./dist/index.d.cts",
|
|
15
|
+
"default": "./dist/index.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"author": "LiveKit",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"repository": "git@github.com:livekit/agents-js.git",
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"src",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@livekit/agents": "^1.0.0-next.0",
|
|
29
|
+
"@livekit/agents-plugin-openai": "^1.0.0-next.0",
|
|
30
|
+
"@livekit/agents-plugins-test": "^1.0.0-next.0",
|
|
31
|
+
"@livekit/rtc-node": "^0.13.12",
|
|
32
|
+
"@microsoft/api-extractor": "^7.35.0",
|
|
33
|
+
"tsup": "^8.3.5",
|
|
34
|
+
"typescript": "^5.0.0"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@google/genai": "^1.13.0",
|
|
38
|
+
"@livekit/mutex": "^1.1.1",
|
|
39
|
+
"@std/async": "npm:@jsr/std__async@^1.0.14",
|
|
40
|
+
"@types/json-schema": "^7.0.15",
|
|
41
|
+
"json-schema": "^0.4.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@livekit/rtc-node": "^0.13.12",
|
|
45
|
+
"@livekit/agents": "^1.0.0-next.01.0.0-next.0"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsup --onSuccess \"pnpm build:types\"",
|
|
49
|
+
"build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
|
|
50
|
+
"clean": "rm -rf dist",
|
|
51
|
+
"clean:build": "pnpm clean && pnpm build",
|
|
52
|
+
"lint": "eslint -f unix \"src/**/*.{ts,js}\"",
|
|
53
|
+
"api:check": "api-extractor run --typescript-compiler-folder ../../node_modules/typescript",
|
|
54
|
+
"api:update": "api-extractor run --local --typescript-compiler-folder ../../node_modules/typescript --verbose"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2025 LiveKit, Inc.
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
import { STT } from '@livekit/agents-plugin-openai';
|
|
5
|
+
import { tts } from '@livekit/agents-plugins-test';
|
|
6
|
+
import { describe } from 'vitest';
|
|
7
|
+
import { TTS } from './gemini_tts.js';
|
|
8
|
+
|
|
9
|
+
describe('Google Gemini TTS', async () => {
|
|
10
|
+
await tts(new TTS(), new STT(), { nonStreaming: true, streaming: false });
|
|
11
|
+
});
|