@ohos-ports/genkit 1.42.0-beta.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 +203 -0
- package/README.md +434 -0
- package/lib/beta.d.mts +18 -0
- package/lib/beta.d.ts +18 -0
- package/lib/beta.js +88 -0
- package/lib/beta.js.map +1 -0
- package/lib/beta.mjs +64 -0
- package/lib/beta.mjs.map +1 -0
- package/lib/client/agent.d.mts +52 -0
- package/lib/client/agent.d.ts +52 -0
- package/lib/client/agent.js +90 -0
- package/lib/client/agent.js.map +1 -0
- package/lib/client/agent.mjs +68 -0
- package/lib/client/agent.mjs.map +1 -0
- package/lib/client/client.d.mts +80 -0
- package/lib/client/client.d.ts +80 -0
- package/lib/client/client.js +164 -0
- package/lib/client/client.js.map +1 -0
- package/lib/client/client.mjs +139 -0
- package/lib/client/client.mjs.map +1 -0
- package/lib/client/index.d.mts +6 -0
- package/lib/client/index.d.ts +6 -0
- package/lib/client/index.js +55 -0
- package/lib/client/index.js.map +1 -0
- package/lib/client/index.mjs +31 -0
- package/lib/client/index.mjs.map +1 -0
- package/lib/client/types.d.mts +17 -0
- package/lib/client/types.d.ts +17 -0
- package/lib/client/types.js +17 -0
- package/lib/client/types.js.map +1 -0
- package/lib/client/types.mjs +1 -0
- package/lib/client/types.mjs.map +1 -0
- package/lib/common.d.mts +3 -0
- package/lib/common.d.ts +3 -0
- package/lib/common.js +151 -0
- package/lib/common.js.map +1 -0
- package/lib/common.mjs +128 -0
- package/lib/common.mjs.map +1 -0
- package/lib/context.d.mts +1 -0
- package/lib/context.d.ts +1 -0
- package/lib/context.js +50 -0
- package/lib/context.js.map +1 -0
- package/lib/context.mjs +28 -0
- package/lib/context.mjs.map +1 -0
- package/lib/embedder.d.mts +1 -0
- package/lib/embedder.d.ts +1 -0
- package/lib/embedder.js +48 -0
- package/lib/embedder.js.map +1 -0
- package/lib/embedder.mjs +26 -0
- package/lib/embedder.mjs.map +1 -0
- package/lib/evaluator.d.mts +1 -0
- package/lib/evaluator.d.ts +1 -0
- package/lib/evaluator.js +60 -0
- package/lib/evaluator.js.map +1 -0
- package/lib/evaluator.mjs +38 -0
- package/lib/evaluator.mjs.map +1 -0
- package/lib/extract.d.mts +1 -0
- package/lib/extract.d.ts +1 -0
- package/lib/extract.js +48 -0
- package/lib/extract.js.map +1 -0
- package/lib/extract.mjs +23 -0
- package/lib/extract.mjs.map +1 -0
- package/lib/formats.d.mts +1 -0
- package/lib/formats.d.ts +1 -0
- package/lib/formats.js +34 -0
- package/lib/formats.js.map +1 -0
- package/lib/formats.mjs +18 -0
- package/lib/formats.mjs.map +1 -0
- package/lib/genkit-beta.d.mts +183 -0
- package/lib/genkit-beta.d.ts +183 -0
- package/lib/genkit-beta.js +178 -0
- package/lib/genkit-beta.js.map +1 -0
- package/lib/genkit-beta.mjs +159 -0
- package/lib/genkit-beta.mjs.map +1 -0
- package/lib/genkit.d.mts +10 -0
- package/lib/genkit.d.ts +10 -0
- package/lib/genkit.js +471 -0
- package/lib/genkit.js.map +1 -0
- package/lib/genkit.mjs +489 -0
- package/lib/genkit.mjs.map +1 -0
- package/lib/index-BSkuxdwl.d.mts +311 -0
- package/lib/index-BSkuxdwl.d.ts +311 -0
- package/lib/index.d.mts +10 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +51 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +24 -0
- package/lib/index.mjs.map +1 -0
- package/lib/logging.d.mts +1 -0
- package/lib/logging.d.ts +1 -0
- package/lib/logging.js +46 -0
- package/lib/logging.js.map +1 -0
- package/lib/logging.mjs +22 -0
- package/lib/logging.mjs.map +1 -0
- package/lib/middleware.d.mts +1 -0
- package/lib/middleware.d.ts +1 -0
- package/lib/middleware.js +56 -0
- package/lib/middleware.js.map +1 -0
- package/lib/middleware.mjs +34 -0
- package/lib/middleware.mjs.map +1 -0
- package/lib/model.d.mts +1 -0
- package/lib/model.d.ts +1 -0
- package/lib/model.js +92 -0
- package/lib/model.js.map +1 -0
- package/lib/model.mjs +70 -0
- package/lib/model.mjs.map +1 -0
- package/lib/plugin.d.mts +10 -0
- package/lib/plugin.d.ts +10 -0
- package/lib/plugin.js +143 -0
- package/lib/plugin.js.map +1 -0
- package/lib/plugin.mjs +113 -0
- package/lib/plugin.mjs.map +1 -0
- package/lib/registry.d.mts +1 -0
- package/lib/registry.d.ts +1 -0
- package/lib/registry.js +46 -0
- package/lib/registry.js.map +1 -0
- package/lib/registry.mjs +24 -0
- package/lib/registry.mjs.map +1 -0
- package/lib/reranker.d.mts +1 -0
- package/lib/reranker.d.ts +1 -0
- package/lib/reranker.js +54 -0
- package/lib/reranker.js.map +1 -0
- package/lib/reranker.mjs +32 -0
- package/lib/reranker.mjs.map +1 -0
- package/lib/retriever.d.mts +1 -0
- package/lib/retriever.d.ts +1 -0
- package/lib/retriever.js +58 -0
- package/lib/retriever.js.map +1 -0
- package/lib/retriever.mjs +36 -0
- package/lib/retriever.mjs.map +1 -0
- package/lib/schema.d.mts +1 -0
- package/lib/schema.d.ts +1 -0
- package/lib/schema.js +54 -0
- package/lib/schema.js.map +1 -0
- package/lib/schema.mjs +32 -0
- package/lib/schema.mjs.map +1 -0
- package/lib/testing.d.mts +1 -0
- package/lib/testing.d.ts +1 -0
- package/lib/testing.js +50 -0
- package/lib/testing.js.map +1 -0
- package/lib/testing.mjs +28 -0
- package/lib/testing.mjs.map +1 -0
- package/lib/tool.d.mts +1 -0
- package/lib/tool.d.ts +1 -0
- package/lib/tool.js +54 -0
- package/lib/tool.js.map +1 -0
- package/lib/tool.mjs +32 -0
- package/lib/tool.mjs.map +1 -0
- package/lib/tracing.d.mts +1 -0
- package/lib/tracing.d.ts +1 -0
- package/lib/tracing.js +82 -0
- package/lib/tracing.js.map +1 -0
- package/lib/tracing.mjs +60 -0
- package/lib/tracing.mjs.map +1 -0
- package/package.json +233 -0
- package/src/beta.ts +85 -0
- package/src/client/agent.ts +160 -0
- package/src/client/client.ts +237 -0
- package/src/client/index.ts +72 -0
- package/src/client/types.ts +41 -0
- package/src/common.ts +175 -0
- package/src/context.ts +37 -0
- package/src/embedder.ts +41 -0
- package/src/evaluator.ts +50 -0
- package/src/extract.ts +30 -0
- package/src/formats.ts +30 -0
- package/src/genkit-beta.ts +275 -0
- package/src/genkit.ts +818 -0
- package/src/index.ts +29 -0
- package/src/logging.ts +30 -0
- package/src/middleware.ts +38 -0
- package/src/model.ts +87 -0
- package/src/plugin.ts +172 -0
- package/src/registry.ts +36 -0
- package/src/reranker.ts +42 -0
- package/src/retriever.ts +55 -0
- package/src/schema.ts +40 -0
- package/src/testing.ts +47 -0
- package/src/tool.ts +40 -0
- package/src/tracing.ts +55 -0
- package/tests/agent_client_test.ts +497 -0
- package/tests/embed_test.ts +142 -0
- package/tests/evaluate_test.ts +52 -0
- package/tests/flow_test.ts +94 -0
- package/tests/formats_test.ts +168 -0
- package/tests/generate_test.ts +1631 -0
- package/tests/genkit_test.ts +33 -0
- package/tests/helpers.ts +176 -0
- package/tests/mock-model_test.ts +490 -0
- package/tests/plugins_test.ts +259 -0
- package/tests/prompts/badSchemaRef.prompt +9 -0
- package/tests/prompts/chat_preamble.prompt +5 -0
- package/tests/prompts/kitchensink.prompt +25 -0
- package/tests/prompts/output.prompt +11 -0
- package/tests/prompts/schemaRef.prompt +9 -0
- package/tests/prompts/sub/test.prompt +5 -0
- package/tests/prompts/test.prompt +5 -0
- package/tests/prompts/test.variant.prompt +8 -0
- package/tests/prompts/toolPrompt.prompt +6 -0
- package/tests/prompts_test.ts +1442 -0
- package/tests/session_test.ts +17 -0
- package/typedoc.json +22 -0
package/lib/extract.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
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 extract_exports = {};
|
|
20
|
+
__export(extract_exports, {
|
|
21
|
+
extractJson: () => import_extract.extractJson,
|
|
22
|
+
parsePartialJson: () => import_extract.parsePartialJson
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(extract_exports);
|
|
25
|
+
var import_extract = require("@genkit-ai/ai/extract");
|
|
26
|
+
/**
|
|
27
|
+
* @license
|
|
28
|
+
*
|
|
29
|
+
* Copyright 2024 Google LLC
|
|
30
|
+
*
|
|
31
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
32
|
+
* you may not use this file except in compliance with the License.
|
|
33
|
+
* You may obtain a copy of the License at
|
|
34
|
+
*
|
|
35
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
36
|
+
*
|
|
37
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
38
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
39
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
40
|
+
* See the License for the specific language governing permissions and
|
|
41
|
+
* limitations under the License.
|
|
42
|
+
*/
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
extractJson,
|
|
46
|
+
parsePartialJson
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/extract.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Extraction utilities — helpers for extracting structured JSON from model\n * output, including partial JSON parsing for streaming.\n *\n * ```ts\n * import { extractJson, parsePartialJson } from 'genkit/extract';\n * ```\n *\n * @module extract\n */\n\nexport { extractJson, parsePartialJson } from '@genkit-ai/ai/extract';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,qBAA8C;AA7B9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
|
package/lib/extract.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2024 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import { extractJson, parsePartialJson } from "@genkit-ai/ai/extract";
|
|
19
|
+
export {
|
|
20
|
+
extractJson,
|
|
21
|
+
parsePartialJson
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=extract.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/extract.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Extraction utilities — helpers for extracting structured JSON from model\n * output, including partial JSON parsing for streaming.\n *\n * ```ts\n * import { extractJson, parsePartialJson } from 'genkit/extract';\n * ```\n *\n * @module extract\n */\n\nexport { extractJson, parsePartialJson } from '@genkit-ai/ai/extract';\n"],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,SAAS,aAAa,wBAAwB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FormatArgument, Formatter } from '@genkit-ai/ai/formats';
|
package/lib/formats.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FormatArgument, Formatter } from '@genkit-ai/ai/formats';
|
package/lib/formats.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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 formats_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(formats_exports);
|
|
17
|
+
/**
|
|
18
|
+
* @license
|
|
19
|
+
*
|
|
20
|
+
* Copyright 2024 Google LLC
|
|
21
|
+
*
|
|
22
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
23
|
+
* you may not use this file except in compliance with the License.
|
|
24
|
+
* You may obtain a copy of the License at
|
|
25
|
+
*
|
|
26
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
+
*
|
|
28
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
29
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
31
|
+
* See the License for the specific language governing permissions and
|
|
32
|
+
* limitations under the License.
|
|
33
|
+
*/
|
|
34
|
+
//# sourceMappingURL=formats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/formats.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Output format types — `Formatter` and `FormatArgument` interfaces used when\n * defining custom output formats for model generation.\n *\n * ```ts\n * import type { Formatter, FormatArgument } from 'genkit/formats';\n * ```\n *\n * @module formats\n */\n\nexport type { FormatArgument, Formatter } from '@genkit-ai/ai/formats';\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
|
package/lib/formats.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2024 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
//# sourceMappingURL=formats.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/formats.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Output format types — `Formatter` and `FormatArgument` interfaces used when\n * defining custom output formats for model generation.\n *\n * ```ts\n * import type { Formatter, FormatArgument } from 'genkit/formats';\n * ```\n *\n * @module formats\n */\n\nexport type { FormatArgument, Formatter } from '@genkit-ai/ai/formats';\n"],"mappings":"AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { AgentFn, Agent, AgentConfig, InterruptConfig, ToolAction, GenerationCommonConfigSchema, GenerateOptions, GenerateResponseData, ResourceOptions, ResourceFn, ResourceAction } from '@genkit-ai/ai';
|
|
2
|
+
export { Agent, AgentFn, AgentStreamChunk, ClientTransform, PromptConfig, SessionRunner } from '@genkit-ai/ai';
|
|
3
|
+
import { SessionStore } from '@genkit-ai/ai/session';
|
|
4
|
+
export { SessionSnapshot, SessionSnapshotInput, SessionState, SessionStore, SessionStoreOptions, SnapshotMutator } from '@genkit-ai/ai/session';
|
|
5
|
+
export { FileSessionStore, InMemorySessionStore } from '@genkit-ai/ai/session-stores';
|
|
6
|
+
export { JsonPatch, JsonPatchOperation, applyPatch, diff } from '@genkit-ai/ai/json-patch';
|
|
7
|
+
import { z, Operation } from '@genkit-ai/core';
|
|
8
|
+
import { Formatter } from '@genkit-ai/ai/formats';
|
|
9
|
+
import { a as Genkit, G as GenkitOptions } from './index-BSkuxdwl.mjs';
|
|
10
|
+
import '@genkit-ai/ai/tool';
|
|
11
|
+
import '@genkit-ai/ai/embedder';
|
|
12
|
+
import '@genkit-ai/ai/evaluator';
|
|
13
|
+
import '@genkit-ai/ai/model';
|
|
14
|
+
import '@genkit-ai/ai/reranker';
|
|
15
|
+
import '@genkit-ai/ai/retriever';
|
|
16
|
+
import '@genkit-ai/core/registry';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Copyright 2025 Google LLC
|
|
20
|
+
*
|
|
21
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
22
|
+
* you may not use this file except in compliance with the License.
|
|
23
|
+
* You may obtain a copy of the License at
|
|
24
|
+
*
|
|
25
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
26
|
+
*
|
|
27
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
28
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
29
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
30
|
+
* See the License for the specific language governing permissions and
|
|
31
|
+
* limitations under the License.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* WARNING: these APIs are considered unstable and subject to frequent breaking changes that may not honor semver.
|
|
36
|
+
*
|
|
37
|
+
* Initializes Genkit BETA APIs with a set of options.
|
|
38
|
+
*
|
|
39
|
+
* This will create a new Genkit registry, register the provided plugins, stores, and other configuration. This
|
|
40
|
+
* should be called before any flows are registered.
|
|
41
|
+
*
|
|
42
|
+
* @beta
|
|
43
|
+
*/
|
|
44
|
+
declare function genkit(options: GenkitOptions): GenkitBeta;
|
|
45
|
+
/**
|
|
46
|
+
* Genkit BETA APIs.
|
|
47
|
+
*
|
|
48
|
+
* @beta
|
|
49
|
+
*/
|
|
50
|
+
declare class GenkitBeta extends Genkit {
|
|
51
|
+
constructor(options?: GenkitOptions);
|
|
52
|
+
/**
|
|
53
|
+
* Defines and registers a custom agent with a custom handler function.
|
|
54
|
+
*
|
|
55
|
+
* @beta
|
|
56
|
+
*/
|
|
57
|
+
defineCustomAgent<State = unknown>(config: {
|
|
58
|
+
name: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
stateSchema?: z.ZodType<State>;
|
|
61
|
+
store?: SessionStore<State>;
|
|
62
|
+
}, fn: AgentFn<State>): Agent<State>;
|
|
63
|
+
/**
|
|
64
|
+
* Defines and registers an agent from an existing Prompt template.
|
|
65
|
+
*
|
|
66
|
+
* @beta
|
|
67
|
+
*/
|
|
68
|
+
definePromptAgent<State = unknown, I extends z.ZodTypeAny = z.ZodTypeAny>(config: {
|
|
69
|
+
promptName: string;
|
|
70
|
+
/**
|
|
71
|
+
* Input values for the referenced prompt's input variables. Lets a single
|
|
72
|
+
* prompt be reused/customized across multiple agents.
|
|
73
|
+
*/
|
|
74
|
+
promptInput?: z.infer<I>;
|
|
75
|
+
stateSchema?: z.ZodType<State>;
|
|
76
|
+
store?: SessionStore<State>;
|
|
77
|
+
}): Agent<State>;
|
|
78
|
+
/**
|
|
79
|
+
* Defines and registers an agent by creating a prompt and wiring it into a
|
|
80
|
+
* multi-turn agent in one step.
|
|
81
|
+
*
|
|
82
|
+
* This is a convenience shortcut that combines `definePrompt` and
|
|
83
|
+
* `definePromptAgent` into a single call.
|
|
84
|
+
*
|
|
85
|
+
* ```ts
|
|
86
|
+
* const myAgent = ai.defineAgent({
|
|
87
|
+
* name: 'myAgent',
|
|
88
|
+
* model: 'googleai/gemini-2.5-flash',
|
|
89
|
+
* system: 'Talk like a pirate.',
|
|
90
|
+
* tools: [weatherTool],
|
|
91
|
+
* store: new FileSessionStore('./.snapshots'),
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @beta
|
|
96
|
+
*/
|
|
97
|
+
defineAgent<State = unknown, I extends z.ZodTypeAny = z.ZodTypeAny>(config: AgentConfig<State, I>): Agent<State>;
|
|
98
|
+
/**
|
|
99
|
+
* Defines and registers a custom model output formatter.
|
|
100
|
+
*
|
|
101
|
+
* Here's an example of a custom JSON output formatter:
|
|
102
|
+
*
|
|
103
|
+
* ```ts
|
|
104
|
+
* import { extractJson } from 'genkit/extract';
|
|
105
|
+
*
|
|
106
|
+
* ai.defineFormat(
|
|
107
|
+
* { name: 'customJson' },
|
|
108
|
+
* (schema) => {
|
|
109
|
+
* let instructions: string | undefined;
|
|
110
|
+
* if (schema) {
|
|
111
|
+
* instructions = `Output should be in JSON format and conform to the following schema:
|
|
112
|
+
* \`\`\`
|
|
113
|
+
* ${JSON.stringify(schema)}
|
|
114
|
+
* \`\`\`
|
|
115
|
+
* `;
|
|
116
|
+
* }
|
|
117
|
+
* return {
|
|
118
|
+
* parseChunk: (chunk) => extractJson(chunk.accumulatedText),
|
|
119
|
+
* parseMessage: (message) => extractJson(message.text),
|
|
120
|
+
* instructions,
|
|
121
|
+
* };
|
|
122
|
+
* }
|
|
123
|
+
* );
|
|
124
|
+
*
|
|
125
|
+
* const { output } = await ai.generate({
|
|
126
|
+
* prompt: 'Invent a menu item for a pirate themed restaurant.',
|
|
127
|
+
* output: { format: 'customJson', schema: MenuItemSchema },
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @beta
|
|
132
|
+
*/
|
|
133
|
+
defineFormat(options: {
|
|
134
|
+
name: string;
|
|
135
|
+
} & Formatter['config'], handler: Formatter['handler']): {
|
|
136
|
+
config: Formatter['config'];
|
|
137
|
+
handler: Formatter['handler'];
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Defines and registers an interrupt.
|
|
141
|
+
*
|
|
142
|
+
* Interrupts are special tools that halt model processing and return control back to the caller. Interrupts make it simpler to implement
|
|
143
|
+
* "human-in-the-loop" and out-of-band processing patterns that require waiting on external actions to complete.
|
|
144
|
+
*
|
|
145
|
+
* @beta
|
|
146
|
+
*/
|
|
147
|
+
defineInterrupt<I extends z.ZodTypeAny, O extends z.ZodTypeAny>(config: InterruptConfig<I, O>): ToolAction<I, O>;
|
|
148
|
+
/**
|
|
149
|
+
* Starts a generate operation for long running generation models, typically for
|
|
150
|
+
* video and complex audio generation.
|
|
151
|
+
*
|
|
152
|
+
* See {@link GenerateOptions} for detailed information about available options.
|
|
153
|
+
*
|
|
154
|
+
* ```ts
|
|
155
|
+
* const operation = await ai.generateOperation({
|
|
156
|
+
* model: googleAI.model('veo-3.1-generate-preview'),
|
|
157
|
+
* prompt: 'A banana riding a bicycle.',
|
|
158
|
+
* });
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* The status of the operation and final result can be obtained using {@link Genkit.checkOperation}.
|
|
162
|
+
*/
|
|
163
|
+
generateOperation<O extends z.ZodTypeAny = z.ZodTypeAny, CustomOptions extends z.ZodTypeAny = typeof GenerationCommonConfigSchema>(opts: GenerateOptions<O, CustomOptions> | PromiseLike<GenerateOptions<O, CustomOptions>>): Promise<Operation<GenerateResponseData>>;
|
|
164
|
+
/**
|
|
165
|
+
* Defines a resource. Resources can then be accessed from a generate call.
|
|
166
|
+
*
|
|
167
|
+
* ```ts
|
|
168
|
+
* ai.defineResource({
|
|
169
|
+
* uri: 'my://resource/{param}',
|
|
170
|
+
* description: 'provides my resource',
|
|
171
|
+
* }, async ({param}) => {
|
|
172
|
+
* return [{ text: `resource ${param}` }]
|
|
173
|
+
* });
|
|
174
|
+
*
|
|
175
|
+
* await ai.generate({
|
|
176
|
+
* prompt: [{ resource: 'my://resource/value' }]
|
|
177
|
+
* })
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
defineResource(opts: ResourceOptions, fn: ResourceFn): ResourceAction;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export { GenkitBeta, GenkitOptions as GenkitBetaOptions, genkit };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { AgentFn, Agent, AgentConfig, InterruptConfig, ToolAction, GenerationCommonConfigSchema, GenerateOptions, GenerateResponseData, ResourceOptions, ResourceFn, ResourceAction } from '@genkit-ai/ai';
|
|
2
|
+
export { Agent, AgentFn, AgentStreamChunk, ClientTransform, PromptConfig, SessionRunner } from '@genkit-ai/ai';
|
|
3
|
+
import { SessionStore } from '@genkit-ai/ai/session';
|
|
4
|
+
export { SessionSnapshot, SessionSnapshotInput, SessionState, SessionStore, SessionStoreOptions, SnapshotMutator } from '@genkit-ai/ai/session';
|
|
5
|
+
export { FileSessionStore, InMemorySessionStore } from '@genkit-ai/ai/session-stores';
|
|
6
|
+
export { JsonPatch, JsonPatchOperation, applyPatch, diff } from '@genkit-ai/ai/json-patch';
|
|
7
|
+
import { z, Operation } from '@genkit-ai/core';
|
|
8
|
+
import { Formatter } from '@genkit-ai/ai/formats';
|
|
9
|
+
import { a as Genkit, G as GenkitOptions } from './index-BSkuxdwl.js';
|
|
10
|
+
import '@genkit-ai/ai/tool';
|
|
11
|
+
import '@genkit-ai/ai/embedder';
|
|
12
|
+
import '@genkit-ai/ai/evaluator';
|
|
13
|
+
import '@genkit-ai/ai/model';
|
|
14
|
+
import '@genkit-ai/ai/reranker';
|
|
15
|
+
import '@genkit-ai/ai/retriever';
|
|
16
|
+
import '@genkit-ai/core/registry';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Copyright 2025 Google LLC
|
|
20
|
+
*
|
|
21
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
22
|
+
* you may not use this file except in compliance with the License.
|
|
23
|
+
* You may obtain a copy of the License at
|
|
24
|
+
*
|
|
25
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
26
|
+
*
|
|
27
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
28
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
29
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
30
|
+
* See the License for the specific language governing permissions and
|
|
31
|
+
* limitations under the License.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* WARNING: these APIs are considered unstable and subject to frequent breaking changes that may not honor semver.
|
|
36
|
+
*
|
|
37
|
+
* Initializes Genkit BETA APIs with a set of options.
|
|
38
|
+
*
|
|
39
|
+
* This will create a new Genkit registry, register the provided plugins, stores, and other configuration. This
|
|
40
|
+
* should be called before any flows are registered.
|
|
41
|
+
*
|
|
42
|
+
* @beta
|
|
43
|
+
*/
|
|
44
|
+
declare function genkit(options: GenkitOptions): GenkitBeta;
|
|
45
|
+
/**
|
|
46
|
+
* Genkit BETA APIs.
|
|
47
|
+
*
|
|
48
|
+
* @beta
|
|
49
|
+
*/
|
|
50
|
+
declare class GenkitBeta extends Genkit {
|
|
51
|
+
constructor(options?: GenkitOptions);
|
|
52
|
+
/**
|
|
53
|
+
* Defines and registers a custom agent with a custom handler function.
|
|
54
|
+
*
|
|
55
|
+
* @beta
|
|
56
|
+
*/
|
|
57
|
+
defineCustomAgent<State = unknown>(config: {
|
|
58
|
+
name: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
stateSchema?: z.ZodType<State>;
|
|
61
|
+
store?: SessionStore<State>;
|
|
62
|
+
}, fn: AgentFn<State>): Agent<State>;
|
|
63
|
+
/**
|
|
64
|
+
* Defines and registers an agent from an existing Prompt template.
|
|
65
|
+
*
|
|
66
|
+
* @beta
|
|
67
|
+
*/
|
|
68
|
+
definePromptAgent<State = unknown, I extends z.ZodTypeAny = z.ZodTypeAny>(config: {
|
|
69
|
+
promptName: string;
|
|
70
|
+
/**
|
|
71
|
+
* Input values for the referenced prompt's input variables. Lets a single
|
|
72
|
+
* prompt be reused/customized across multiple agents.
|
|
73
|
+
*/
|
|
74
|
+
promptInput?: z.infer<I>;
|
|
75
|
+
stateSchema?: z.ZodType<State>;
|
|
76
|
+
store?: SessionStore<State>;
|
|
77
|
+
}): Agent<State>;
|
|
78
|
+
/**
|
|
79
|
+
* Defines and registers an agent by creating a prompt and wiring it into a
|
|
80
|
+
* multi-turn agent in one step.
|
|
81
|
+
*
|
|
82
|
+
* This is a convenience shortcut that combines `definePrompt` and
|
|
83
|
+
* `definePromptAgent` into a single call.
|
|
84
|
+
*
|
|
85
|
+
* ```ts
|
|
86
|
+
* const myAgent = ai.defineAgent({
|
|
87
|
+
* name: 'myAgent',
|
|
88
|
+
* model: 'googleai/gemini-2.5-flash',
|
|
89
|
+
* system: 'Talk like a pirate.',
|
|
90
|
+
* tools: [weatherTool],
|
|
91
|
+
* store: new FileSessionStore('./.snapshots'),
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @beta
|
|
96
|
+
*/
|
|
97
|
+
defineAgent<State = unknown, I extends z.ZodTypeAny = z.ZodTypeAny>(config: AgentConfig<State, I>): Agent<State>;
|
|
98
|
+
/**
|
|
99
|
+
* Defines and registers a custom model output formatter.
|
|
100
|
+
*
|
|
101
|
+
* Here's an example of a custom JSON output formatter:
|
|
102
|
+
*
|
|
103
|
+
* ```ts
|
|
104
|
+
* import { extractJson } from 'genkit/extract';
|
|
105
|
+
*
|
|
106
|
+
* ai.defineFormat(
|
|
107
|
+
* { name: 'customJson' },
|
|
108
|
+
* (schema) => {
|
|
109
|
+
* let instructions: string | undefined;
|
|
110
|
+
* if (schema) {
|
|
111
|
+
* instructions = `Output should be in JSON format and conform to the following schema:
|
|
112
|
+
* \`\`\`
|
|
113
|
+
* ${JSON.stringify(schema)}
|
|
114
|
+
* \`\`\`
|
|
115
|
+
* `;
|
|
116
|
+
* }
|
|
117
|
+
* return {
|
|
118
|
+
* parseChunk: (chunk) => extractJson(chunk.accumulatedText),
|
|
119
|
+
* parseMessage: (message) => extractJson(message.text),
|
|
120
|
+
* instructions,
|
|
121
|
+
* };
|
|
122
|
+
* }
|
|
123
|
+
* );
|
|
124
|
+
*
|
|
125
|
+
* const { output } = await ai.generate({
|
|
126
|
+
* prompt: 'Invent a menu item for a pirate themed restaurant.',
|
|
127
|
+
* output: { format: 'customJson', schema: MenuItemSchema },
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @beta
|
|
132
|
+
*/
|
|
133
|
+
defineFormat(options: {
|
|
134
|
+
name: string;
|
|
135
|
+
} & Formatter['config'], handler: Formatter['handler']): {
|
|
136
|
+
config: Formatter['config'];
|
|
137
|
+
handler: Formatter['handler'];
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Defines and registers an interrupt.
|
|
141
|
+
*
|
|
142
|
+
* Interrupts are special tools that halt model processing and return control back to the caller. Interrupts make it simpler to implement
|
|
143
|
+
* "human-in-the-loop" and out-of-band processing patterns that require waiting on external actions to complete.
|
|
144
|
+
*
|
|
145
|
+
* @beta
|
|
146
|
+
*/
|
|
147
|
+
defineInterrupt<I extends z.ZodTypeAny, O extends z.ZodTypeAny>(config: InterruptConfig<I, O>): ToolAction<I, O>;
|
|
148
|
+
/**
|
|
149
|
+
* Starts a generate operation for long running generation models, typically for
|
|
150
|
+
* video and complex audio generation.
|
|
151
|
+
*
|
|
152
|
+
* See {@link GenerateOptions} for detailed information about available options.
|
|
153
|
+
*
|
|
154
|
+
* ```ts
|
|
155
|
+
* const operation = await ai.generateOperation({
|
|
156
|
+
* model: googleAI.model('veo-3.1-generate-preview'),
|
|
157
|
+
* prompt: 'A banana riding a bicycle.',
|
|
158
|
+
* });
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* The status of the operation and final result can be obtained using {@link Genkit.checkOperation}.
|
|
162
|
+
*/
|
|
163
|
+
generateOperation<O extends z.ZodTypeAny = z.ZodTypeAny, CustomOptions extends z.ZodTypeAny = typeof GenerationCommonConfigSchema>(opts: GenerateOptions<O, CustomOptions> | PromiseLike<GenerateOptions<O, CustomOptions>>): Promise<Operation<GenerateResponseData>>;
|
|
164
|
+
/**
|
|
165
|
+
* Defines a resource. Resources can then be accessed from a generate call.
|
|
166
|
+
*
|
|
167
|
+
* ```ts
|
|
168
|
+
* ai.defineResource({
|
|
169
|
+
* uri: 'my://resource/{param}',
|
|
170
|
+
* description: 'provides my resource',
|
|
171
|
+
* }, async ({param}) => {
|
|
172
|
+
* return [{ text: `resource ${param}` }]
|
|
173
|
+
* });
|
|
174
|
+
*
|
|
175
|
+
* await ai.generate({
|
|
176
|
+
* prompt: [{ resource: 'my://resource/value' }]
|
|
177
|
+
* })
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
defineResource(opts: ResourceOptions, fn: ResourceFn): ResourceAction;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export { GenkitBeta, GenkitOptions as GenkitBetaOptions, genkit };
|