@tanstack/ai-gemini 0.17.2 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/src/experimental/text-interactions/adapter.ts +304 -100
- package/src/experimental/text-interactions/events.ts +29 -23
- package/src/experimental/text-interactions/provider-options.ts +0 -1
- package/dist/esm/adapters/audio.d.ts +0 -92
- package/dist/esm/adapters/audio.js +0 -66
- package/dist/esm/adapters/audio.js.map +0 -1
- package/dist/esm/adapters/image.d.ts +0 -101
- package/dist/esm/adapters/image.js +0 -253
- package/dist/esm/adapters/image.js.map +0 -1
- package/dist/esm/adapters/summarize.d.ts +0 -33
- package/dist/esm/adapters/summarize.js +0 -18
- package/dist/esm/adapters/summarize.js.map +0 -1
- package/dist/esm/adapters/text.d.ts +0 -85
- package/dist/esm/adapters/text.js +0 -658
- package/dist/esm/adapters/text.js.map +0 -1
- package/dist/esm/adapters/tts.d.ts +0 -165
- package/dist/esm/adapters/tts.js +0 -192
- package/dist/esm/adapters/tts.js.map +0 -1
- package/dist/esm/adapters/video.d.ts +0 -108
- package/dist/esm/adapters/video.js +0 -227
- package/dist/esm/adapters/video.js.map +0 -1
- package/dist/esm/experimental/index.d.ts +0 -6
- package/dist/esm/experimental/index.js +0 -7
- package/dist/esm/experimental/index.js.map +0 -1
- package/dist/esm/experimental/text-interactions/adapter.d.ts +0 -75
- package/dist/esm/experimental/text-interactions/adapter.js +0 -899
- package/dist/esm/experimental/text-interactions/adapter.js.map +0 -1
- package/dist/esm/experimental/text-interactions/events.d.ts +0 -141
- package/dist/esm/experimental/text-interactions/provider-options.d.ts +0 -15
- package/dist/esm/image/image-provider-options.d.ts +0 -181
- package/dist/esm/image/image-provider-options.js +0 -67
- package/dist/esm/image/image-provider-options.js.map +0 -1
- package/dist/esm/index.d.ts +0 -33
- package/dist/esm/index.js +0 -38
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/message-types.d.ts +0 -104
- package/dist/esm/model-meta.d.ts +0 -242
- package/dist/esm/model-meta.js +0 -159
- package/dist/esm/model-meta.js.map +0 -1
- package/dist/esm/text/text-provider-options.d.ts +0 -196
- package/dist/esm/tools/code-execution-tool.d.ts +0 -10
- package/dist/esm/tools/code-execution-tool.js +0 -18
- package/dist/esm/tools/code-execution-tool.js.map +0 -1
- package/dist/esm/tools/computer-use-tool.d.ts +0 -13
- package/dist/esm/tools/computer-use-tool.js +0 -33
- package/dist/esm/tools/computer-use-tool.js.map +0 -1
- package/dist/esm/tools/file-search-tool.d.ts +0 -10
- package/dist/esm/tools/file-search-tool.js +0 -19
- package/dist/esm/tools/file-search-tool.js.map +0 -1
- package/dist/esm/tools/function-declaration-tool.d.ts +0 -5
- package/dist/esm/tools/function-declaration-tool.js +0 -28
- package/dist/esm/tools/function-declaration-tool.js.map +0 -1
- package/dist/esm/tools/google-maps-tool.d.ts +0 -10
- package/dist/esm/tools/google-maps-tool.js +0 -19
- package/dist/esm/tools/google-maps-tool.js.map +0 -1
- package/dist/esm/tools/google-search-retriveal-tool.d.ts +0 -10
- package/dist/esm/tools/google-search-retriveal-tool.js +0 -19
- package/dist/esm/tools/google-search-retriveal-tool.js.map +0 -1
- package/dist/esm/tools/google-search-tool.d.ts +0 -10
- package/dist/esm/tools/google-search-tool.js +0 -19
- package/dist/esm/tools/google-search-tool.js.map +0 -1
- package/dist/esm/tools/index.d.ts +0 -18
- package/dist/esm/tools/index.js +0 -21
- package/dist/esm/tools/index.js.map +0 -1
- package/dist/esm/tools/tool-converter.d.ts +0 -22
- package/dist/esm/tools/tool-converter.js +0 -66
- package/dist/esm/tools/tool-converter.js.map +0 -1
- package/dist/esm/tools/url-context-tool.d.ts +0 -10
- package/dist/esm/tools/url-context-tool.js +0 -18
- package/dist/esm/tools/url-context-tool.js.map +0 -1
- package/dist/esm/usage.d.ts +0 -67
- package/dist/esm/usage.js +0 -94
- package/dist/esm/usage.js.map +0 -1
- package/dist/esm/utils/client.d.ts +0 -17
- package/dist/esm/utils/client.js +0 -30
- package/dist/esm/utils/client.js.map +0 -1
- package/dist/esm/utils/index.d.ts +0 -1
- package/dist/esm/video/video-provider-options.d.ts +0 -90
- package/dist/esm/video/video-provider-options.js +0 -15
- package/dist/esm/video/video-provider-options.js.map +0 -1
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { MediaResolution, SafetySetting, Schema, ThinkingLevel, ToolConfig } from '@google/genai';
|
|
2
|
-
export interface GeminiToolConfigOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Tool configuration for any Tool specified in the request.
|
|
5
|
-
*/
|
|
6
|
-
toolConfig?: ToolConfig;
|
|
7
|
-
}
|
|
8
|
-
export interface GeminiSafetyOptions {
|
|
9
|
-
/**
|
|
10
|
-
* list of unique SafetySetting instances for blocking unsafe content.
|
|
11
|
-
|
|
12
|
-
This will be enforced on the GenerateContentRequest.contents and GenerateContentResponse.candidates. There should not be more than one setting for each SafetyCategory type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each SafetyCategory specified in the safetySettings. If there is no SafetySetting for a given SafetyCategory provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT, HARM_CATEGORY_CIVIC_INTEGRITY are supported
|
|
13
|
-
*/
|
|
14
|
-
safetySettings?: Array<SafetySetting>;
|
|
15
|
-
}
|
|
16
|
-
export interface GeminiCommonConfigOptions {
|
|
17
|
-
/**
|
|
18
|
-
* Configuration options for model generation and outputs.
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a stop_sequence. The stop sequence will not be included as part of the response.
|
|
22
|
-
*/
|
|
23
|
-
stopSequences?: Array<string>;
|
|
24
|
-
/**
|
|
25
|
-
* The requested modalities of the response. Represents the set of modalities that the model can return, and should be expected in the response. This is an exact match to the modalities of the response.
|
|
26
|
-
|
|
27
|
-
A model may have multiple combinations of supported modalities. If the requested modalities do not match any of the supported combinations, an error will be returned.
|
|
28
|
-
*/
|
|
29
|
-
responseModalities?: Array<'MODALITY_UNSPECIFIED' | 'TEXT' | 'IMAGE' | 'AUDIO'>;
|
|
30
|
-
/**
|
|
31
|
-
* Number of generated responses to return. If unset, this will default to 1. Please note that this doesn't work for previous generation models (Gemini 1.0 family)
|
|
32
|
-
*/
|
|
33
|
-
candidateCount?: number;
|
|
34
|
-
/**
|
|
35
|
-
* The maximum number of tokens to consider when sampling.
|
|
36
|
-
|
|
37
|
-
Gemini models use Top-p (nucleus) sampling or a combination of Top-k and nucleus sampling. Top-k sampling considers the set of topK most probable tokens. Models running with nucleus sampling don't allow topK setting.
|
|
38
|
-
|
|
39
|
-
Note: The default value varies by Model and is specified by theModel.top_p attribute returned from the getModel function. An empty topK attribute indicates that the model doesn't apply top-k sampling and doesn't allow setting topK on requests.
|
|
40
|
-
*/
|
|
41
|
-
topK?: number;
|
|
42
|
-
/** Controls randomness, range [0.0, 2.0]. Higher = more random. Use this or topP, not both. */
|
|
43
|
-
temperature?: number;
|
|
44
|
-
/** Nucleus sampling probability mass, range (0.0, 1.0]. */
|
|
45
|
-
topP?: number;
|
|
46
|
-
/** Maximum number of tokens to generate in the response. */
|
|
47
|
-
maxOutputTokens?: number;
|
|
48
|
-
/**
|
|
49
|
-
* Seed used in decoding. If not set, the request uses a randomly generated seed.
|
|
50
|
-
*/
|
|
51
|
-
seed?: number;
|
|
52
|
-
/**
|
|
53
|
-
* Presence penalty applied to the next token's logprobs if the token has already been seen in the response.
|
|
54
|
-
|
|
55
|
-
This penalty is binary on/off and not dependant on the number of times the token is used (after the first). Use frequencyPenalty for a penalty that increases with each use.
|
|
56
|
-
|
|
57
|
-
A positive penalty will discourage the use of tokens that have already been used in the response, increasing the vocabulary.
|
|
58
|
-
|
|
59
|
-
A negative penalty will encourage the use of tokens that have already been used in the response, decreasing the vocabulary.
|
|
60
|
-
*/
|
|
61
|
-
presencePenalty?: number;
|
|
62
|
-
/**
|
|
63
|
-
* Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the respponse so far.
|
|
64
|
-
|
|
65
|
-
A positive penalty will discourage the use of tokens that have already been used, proportional to the number of times the token has been used: The more a token is used, the more difficult it is for the model to use that token again increasing the vocabulary of responses.
|
|
66
|
-
|
|
67
|
-
Caution: A negative penalty will encourage the model to reuse tokens proportional to the number of times the token has been used. Small negative values will reduce the vocabulary of a response. Larger negative values will cause the model to start repeating a common token until it hits the maxOutputTokens limit.
|
|
68
|
-
*/
|
|
69
|
-
frequencyPenalty?: number;
|
|
70
|
-
/**
|
|
71
|
-
* If true, export the logprobs results in response.
|
|
72
|
-
*/
|
|
73
|
-
responseLogprobs?: boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Only valid if responseLogprobs=True. This sets the number of top logprobs to return at each decoding step in the Candidate.logprobs_result. The number must be in the range of [0, 20].
|
|
76
|
-
*/
|
|
77
|
-
logprobs?: number;
|
|
78
|
-
/**
|
|
79
|
-
* Enables enhanced civic answers. It may not be available for all models.
|
|
80
|
-
*/
|
|
81
|
-
enableEnhancedCivicAnswers?: boolean;
|
|
82
|
-
/**
|
|
83
|
-
* The speech generation config.
|
|
84
|
-
*/
|
|
85
|
-
speechConfig?: {
|
|
86
|
-
voiceConfig: {
|
|
87
|
-
prebuiltVoiceConfig: {
|
|
88
|
-
voiceName: string;
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
multiSpeakerVoiceConfig?: {
|
|
92
|
-
speakerVoiceConfigs?: Array<{
|
|
93
|
-
speaker: string;
|
|
94
|
-
voiceConfig: {
|
|
95
|
-
prebuiltVoiceConfig: {
|
|
96
|
-
voiceName: string;
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
}>;
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Language code (in BCP 47 format, e.g. "en-US") for speech synthesis.
|
|
103
|
-
|
|
104
|
-
Valid values are: de-DE, en-AU, en-GB, en-IN, en-US, es-US, fr-FR, hi-IN, pt-BR, ar-XA, es-ES, fr-CA, id-ID, it-IT, ja-JP, tr-TR, vi-VN, bn-IN, gu-IN, kn-IN, ml-IN, mr-IN, ta-IN, te-IN, nl-NL, ko-KR, cmn-CN, pl-PL, ru-RU, and th-TH.
|
|
105
|
-
*/
|
|
106
|
-
languageCode?: 'de-DE' | 'en-AU' | 'en-GB' | 'en-IN' | 'en-US' | 'es-US' | 'fr-FR' | 'hi-IN' | 'pt-BR' | 'ar-XA' | 'es-ES' | 'fr-CA' | 'id-ID' | 'it-IT' | 'ja-JP' | 'tr-TR' | 'vi-VN' | 'bn-IN' | 'gu-IN' | 'kn-IN' | 'ml-IN' | 'mr-IN' | 'ta-IN' | 'te-IN' | 'nl-NL' | 'ko-KR' | 'cmn-CN' | 'pl-PL' | 'ru-RU' | 'th-TH';
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Config for image generation. An error will be returned if this field is set for models that don't support these config options.
|
|
110
|
-
*/
|
|
111
|
-
imageConfig?: {
|
|
112
|
-
aspectRatio?: '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '9:16' | '16:9' | '21:9';
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* If specified, the media resolution specified will be used.
|
|
116
|
-
*/
|
|
117
|
-
mediaResolution?: MediaResolution;
|
|
118
|
-
}
|
|
119
|
-
export interface GeminiCachedContentOptions {
|
|
120
|
-
/**
|
|
121
|
-
* The name of the content cached to use as context to serve the prediction. Format: cachedContents/{cachedContent}
|
|
122
|
-
*/
|
|
123
|
-
cachedContent?: `cachedContents/${string}`;
|
|
124
|
-
}
|
|
125
|
-
export interface GeminiStructuredOutputOptions {
|
|
126
|
-
/**
|
|
127
|
-
* MIME type of the generated candidate text. Supported MIME types are: text/plain: (default) Text output. application/json: JSON response in the response candidates. text/x.enum: ENUM as a string response in the response candidates.
|
|
128
|
-
*/
|
|
129
|
-
responseMimeType?: string;
|
|
130
|
-
/**
|
|
131
|
-
* Output schema of the generated candidate text. Schemas must be a subset of the OpenAPI schema and can be objects, primitives or arrays.
|
|
132
|
-
|
|
133
|
-
If set, a compatible responseMimeType must also be set. Compatible MIME types: application/json: Schema for JSON response.
|
|
134
|
-
*/
|
|
135
|
-
responseSchema?: Schema;
|
|
136
|
-
/**
|
|
137
|
-
* Output schema of the generated response. This is an alternative to responseSchema that accepts JSON Schema.
|
|
138
|
-
|
|
139
|
-
If set, responseSchema must be omitted, but responseMimeType is required.
|
|
140
|
-
|
|
141
|
-
While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported:
|
|
142
|
-
|
|
143
|
-
$id
|
|
144
|
-
$defs
|
|
145
|
-
$ref
|
|
146
|
-
$anchor
|
|
147
|
-
type
|
|
148
|
-
format
|
|
149
|
-
title
|
|
150
|
-
description
|
|
151
|
-
enum (for strings and numbers)
|
|
152
|
-
items
|
|
153
|
-
prefixItems
|
|
154
|
-
minItems
|
|
155
|
-
maxItems
|
|
156
|
-
minimum
|
|
157
|
-
maximum
|
|
158
|
-
anyOf
|
|
159
|
-
oneOf (interpreted the same as anyOf)
|
|
160
|
-
properties
|
|
161
|
-
additionalProperties
|
|
162
|
-
required
|
|
163
|
-
The non-standard propertyOrdering property may also be set.
|
|
164
|
-
|
|
165
|
-
Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If $ref is set on a sub-schema, no other properties, except for than those starting as a $, may be set.
|
|
166
|
-
*/
|
|
167
|
-
responseJsonSchema?: Schema;
|
|
168
|
-
}
|
|
169
|
-
export interface GeminiThinkingOptions {
|
|
170
|
-
/**
|
|
171
|
-
* Config for thinking features. An error will be returned if this field is
|
|
172
|
-
* set for models that don't support thinking.
|
|
173
|
-
*
|
|
174
|
-
* All fields are optional so the same shape can be used for both budget-based
|
|
175
|
-
* thinking (Gemini 2.x: `includeThoughts` + `thinkingBudget`) and the newer
|
|
176
|
-
* level-based thinking (Gemini 3.x: `thinkingLevel`). The adapter reads
|
|
177
|
-
* whichever fields are present at runtime.
|
|
178
|
-
*/
|
|
179
|
-
thinkingConfig?: {
|
|
180
|
-
/**
|
|
181
|
-
* Indicates whether to include thoughts in the response. If true, thoughts
|
|
182
|
-
* are returned only when available.
|
|
183
|
-
*/
|
|
184
|
-
includeThoughts?: boolean;
|
|
185
|
-
/**
|
|
186
|
-
* The number of thoughts tokens that the model should generate.
|
|
187
|
-
*/
|
|
188
|
-
thinkingBudget?: number;
|
|
189
|
-
/**
|
|
190
|
-
* The level of thoughts tokens that the model should generate
|
|
191
|
-
* (Gemini 3.x and later).
|
|
192
|
-
*/
|
|
193
|
-
thinkingLevel?: keyof typeof ThinkingLevel;
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
export type ExternalTextProviderOptions = GeminiToolConfigOptions & GeminiSafetyOptions & GeminiCommonConfigOptions & GeminiCachedContentOptions & GeminiThinkingOptions & GeminiStructuredOutputOptions;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ProviderTool, Tool } from '@tanstack/ai';
|
|
2
|
-
export interface CodeExecutionToolConfig {
|
|
3
|
-
}
|
|
4
|
-
/** @deprecated Renamed to `CodeExecutionToolConfig`. Will be removed in a future release. */
|
|
5
|
-
export type CodeExecutionTool = CodeExecutionToolConfig;
|
|
6
|
-
export type GeminiCodeExecutionTool = ProviderTool<'gemini', 'code_execution'>;
|
|
7
|
-
export declare function convertCodeExecutionToolToAdapterFormat(_tool: Tool): {
|
|
8
|
-
codeExecution: {};
|
|
9
|
-
};
|
|
10
|
-
export declare function codeExecutionTool(): GeminiCodeExecutionTool;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { brandProviderTool } from "@tanstack/ai";
|
|
2
|
-
function convertCodeExecutionToolToAdapterFormat(_tool) {
|
|
3
|
-
return {
|
|
4
|
-
codeExecution: {}
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
function codeExecutionTool() {
|
|
8
|
-
return brandProviderTool({
|
|
9
|
-
name: "code_execution",
|
|
10
|
-
description: "",
|
|
11
|
-
metadata: {}
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
codeExecutionTool,
|
|
16
|
-
convertCodeExecutionToolToAdapterFormat
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=code-execution-tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-execution-tool.js","sources":["../../../src/tools/code-execution-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport interface CodeExecutionToolConfig {}\n\n/** @deprecated Renamed to `CodeExecutionToolConfig`. Will be removed in a future release. */\nexport type CodeExecutionTool = CodeExecutionToolConfig\n\nexport type GeminiCodeExecutionTool = ProviderTool<'gemini', 'code_execution'>\n\nexport function convertCodeExecutionToolToAdapterFormat(_tool: Tool) {\n return {\n codeExecution: {},\n }\n}\n\nexport function codeExecutionTool(): GeminiCodeExecutionTool {\n return brandProviderTool<GeminiCodeExecutionTool>({\n name: 'code_execution',\n description: '',\n metadata: {},\n })\n}\n"],"names":[],"mappings":";AAUO,SAAS,wCAAwC,OAAa;AACnE,SAAO;AAAA,IACL,eAAe,CAAA;AAAA,EAAC;AAEpB;AAEO,SAAS,oBAA6C;AAC3D,SAAO,kBAA2C;AAAA,IAChD,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU,CAAA;AAAA,EAAC,CACZ;AACH;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ComputerUse } from '@google/genai';
|
|
2
|
-
import { ProviderTool, Tool } from '@tanstack/ai';
|
|
3
|
-
export type ComputerUseToolConfig = ComputerUse;
|
|
4
|
-
/** @deprecated Renamed to `ComputerUseToolConfig`. Will be removed in a future release. */
|
|
5
|
-
export type ComputerUseTool = ComputerUseToolConfig;
|
|
6
|
-
export type GeminiComputerUseTool = ProviderTool<'gemini', 'computer_use'>;
|
|
7
|
-
export declare function convertComputerUseToolToAdapterFormat(tool: Tool): {
|
|
8
|
-
computerUse: {
|
|
9
|
-
excludedPredefinedFunctions?: string[] | undefined;
|
|
10
|
-
environment?: import('@google/genai').Environment | undefined;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export declare function computerUseTool(config: ComputerUseToolConfig): GeminiComputerUseTool;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { brandProviderTool } from "@tanstack/ai";
|
|
2
|
-
function convertComputerUseToolToAdapterFormat(tool) {
|
|
3
|
-
const metadata = tool.metadata;
|
|
4
|
-
return {
|
|
5
|
-
computerUse: {
|
|
6
|
-
...metadata.environment !== void 0 && {
|
|
7
|
-
environment: metadata.environment
|
|
8
|
-
},
|
|
9
|
-
...metadata.excludedPredefinedFunctions !== void 0 && {
|
|
10
|
-
excludedPredefinedFunctions: metadata.excludedPredefinedFunctions
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function computerUseTool(config) {
|
|
16
|
-
return brandProviderTool({
|
|
17
|
-
name: "computer_use",
|
|
18
|
-
description: "",
|
|
19
|
-
metadata: {
|
|
20
|
-
...config.environment !== void 0 && {
|
|
21
|
-
environment: config.environment
|
|
22
|
-
},
|
|
23
|
-
...config.excludedPredefinedFunctions !== void 0 && {
|
|
24
|
-
excludedPredefinedFunctions: config.excludedPredefinedFunctions
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
computerUseTool,
|
|
31
|
-
convertComputerUseToolToAdapterFormat
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=computer-use-tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"computer-use-tool.js","sources":["../../../src/tools/computer-use-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\nimport type { ComputerUse } from '@google/genai'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type ComputerUseToolConfig = ComputerUse\n\n/** @deprecated Renamed to `ComputerUseToolConfig`. Will be removed in a future release. */\nexport type ComputerUseTool = ComputerUseToolConfig\n\nexport type GeminiComputerUseTool = ProviderTool<'gemini', 'computer_use'>\n\nexport function convertComputerUseToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as ComputerUseToolConfig\n // Vendor `ComputerUse` fields are `field?: T` (no `| undefined`) under EOPT,\n // so spread each field conditionally rather than emitting explicit\n // `undefined`s on the wire payload.\n return {\n computerUse: {\n ...(metadata.environment !== undefined && {\n environment: metadata.environment,\n }),\n ...(metadata.excludedPredefinedFunctions !== undefined && {\n excludedPredefinedFunctions: metadata.excludedPredefinedFunctions,\n }),\n },\n }\n}\n\nexport function computerUseTool(\n config: ComputerUseToolConfig,\n): GeminiComputerUseTool {\n return brandProviderTool<GeminiComputerUseTool>({\n name: 'computer_use',\n description: '',\n metadata: {\n ...(config.environment !== undefined && {\n environment: config.environment,\n }),\n ...(config.excludedPredefinedFunctions !== undefined && {\n excludedPredefinedFunctions: config.excludedPredefinedFunctions,\n }),\n },\n })\n}\n"],"names":[],"mappings":";AAWO,SAAS,sCAAsC,MAAY;AAChE,QAAM,WAAW,KAAK;AAItB,SAAO;AAAA,IACL,aAAa;AAAA,MACX,GAAI,SAAS,gBAAgB,UAAa;AAAA,QACxC,aAAa,SAAS;AAAA,MAAA;AAAA,MAExB,GAAI,SAAS,gCAAgC,UAAa;AAAA,QACxD,6BAA6B,SAAS;AAAA,MAAA;AAAA,IACxC;AAAA,EACF;AAEJ;AAEO,SAAS,gBACd,QACuB;AACvB,SAAO,kBAAyC;AAAA,IAC9C,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,MACR,GAAI,OAAO,gBAAgB,UAAa;AAAA,QACtC,aAAa,OAAO;AAAA,MAAA;AAAA,MAEtB,GAAI,OAAO,gCAAgC,UAAa;AAAA,QACtD,6BAA6B,OAAO;AAAA,MAAA;AAAA,IACtC;AAAA,EACF,CACD;AACH;"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FileSearch } from '@google/genai';
|
|
2
|
-
import { ProviderTool, Tool } from '@tanstack/ai';
|
|
3
|
-
export type FileSearchToolConfig = FileSearch;
|
|
4
|
-
/** @deprecated Renamed to `FileSearchToolConfig`. Will be removed in a future release. */
|
|
5
|
-
export type FileSearchTool = FileSearchToolConfig;
|
|
6
|
-
export type GeminiFileSearchTool = ProviderTool<'gemini', 'file_search'>;
|
|
7
|
-
export declare function convertFileSearchToolToAdapterFormat(tool: Tool): {
|
|
8
|
-
fileSearch: FileSearch;
|
|
9
|
-
};
|
|
10
|
-
export declare function fileSearchTool(config: FileSearchToolConfig): GeminiFileSearchTool;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { brandProviderTool } from "@tanstack/ai";
|
|
2
|
-
function convertFileSearchToolToAdapterFormat(tool) {
|
|
3
|
-
const metadata = tool.metadata;
|
|
4
|
-
return {
|
|
5
|
-
fileSearch: metadata
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
function fileSearchTool(config) {
|
|
9
|
-
return brandProviderTool({
|
|
10
|
-
name: "file_search",
|
|
11
|
-
description: "",
|
|
12
|
-
metadata: config
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
export {
|
|
16
|
-
convertFileSearchToolToAdapterFormat,
|
|
17
|
-
fileSearchTool
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=file-search-tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-search-tool.js","sources":["../../../src/tools/file-search-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\nimport type { FileSearch } from '@google/genai'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type FileSearchToolConfig = FileSearch\n\n/** @deprecated Renamed to `FileSearchToolConfig`. Will be removed in a future release. */\nexport type FileSearchTool = FileSearchToolConfig\n\nexport type GeminiFileSearchTool = ProviderTool<'gemini', 'file_search'>\n\nexport function convertFileSearchToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as FileSearchToolConfig\n return {\n fileSearch: metadata,\n }\n}\n\nexport function fileSearchTool(\n config: FileSearchToolConfig,\n): GeminiFileSearchTool {\n return brandProviderTool<GeminiFileSearchTool>({\n name: 'file_search',\n description: '',\n metadata: config,\n })\n}\n"],"names":[],"mappings":";AAWO,SAAS,qCAAqC,MAAY;AAC/D,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,YAAY;AAAA,EAAA;AAEhB;AAEO,SAAS,eACd,QACsB;AACtB,SAAO,kBAAwC;AAAA,IAC7C,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,EAAA,CACX;AACH;"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const validateFunctionDeclarationTool = (tool) => {
|
|
2
|
-
const nameRegex = /^[a-zA-Z0-9_:.-]{1,64}$/;
|
|
3
|
-
if (tool.name === void 0 || !nameRegex.test(tool.name)) {
|
|
4
|
-
throw new Error(
|
|
5
|
-
`Invalid function name: ${tool.name}. Must be 1-64 characters long and contain only a-z, A-Z, 0-9, underscores, colons, dots, and dashes.`
|
|
6
|
-
);
|
|
7
|
-
}
|
|
8
|
-
if (tool.parameters && tool.parametersJsonSchema) {
|
|
9
|
-
throw new Error(
|
|
10
|
-
`FunctionDeclarationTool cannot have both 'parameters' and 'parametersJsonSchema' defined. Please use only one.`
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
if (tool.response && tool.responseJsonSchema) {
|
|
14
|
-
throw new Error(
|
|
15
|
-
`FunctionDeclarationTool cannot have both 'response' and 'responseJsonSchema' defined. Please use only one.`
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
function functionDeclarationTools(tools) {
|
|
20
|
-
tools.forEach(validateFunctionDeclarationTool);
|
|
21
|
-
return {
|
|
22
|
-
functionDeclarations: tools
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export {
|
|
26
|
-
functionDeclarationTools
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=function-declaration-tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"function-declaration-tool.js","sources":["../../../src/tools/function-declaration-tool.ts"],"sourcesContent":["import type { FunctionDeclaration } from '@google/genai'\n\nexport type FunctionDeclarationTool = FunctionDeclaration\n\nconst validateFunctionDeclarationTool = (tool: FunctionDeclarationTool) => {\n const nameRegex = /^[a-zA-Z0-9_:.-]{1,64}$/\n if (tool.name === undefined || !nameRegex.test(tool.name)) {\n throw new Error(\n `Invalid function name: ${tool.name}. Must be 1-64 characters long and contain only a-z, A-Z, 0-9, underscores, colons, dots, and dashes.`,\n )\n }\n\n if (tool.parameters && tool.parametersJsonSchema) {\n throw new Error(\n `FunctionDeclarationTool cannot have both 'parameters' and 'parametersJsonSchema' defined. Please use only one.`,\n )\n }\n\n if (tool.response && tool.responseJsonSchema) {\n throw new Error(\n `FunctionDeclarationTool cannot have both 'response' and 'responseJsonSchema' defined. Please use only one.`,\n )\n }\n}\n\nexport function functionDeclarationTools(\n tools: Array<FunctionDeclarationTool>,\n) {\n tools.forEach(validateFunctionDeclarationTool)\n return {\n functionDeclarations: tools,\n }\n}\n"],"names":[],"mappings":"AAIA,MAAM,kCAAkC,CAAC,SAAkC;AACzE,QAAM,YAAY;AAClB,MAAI,KAAK,SAAS,UAAa,CAAC,UAAU,KAAK,KAAK,IAAI,GAAG;AACzD,UAAM,IAAI;AAAA,MACR,0BAA0B,KAAK,IAAI;AAAA,IAAA;AAAA,EAEvC;AAEA,MAAI,KAAK,cAAc,KAAK,sBAAsB;AAChD,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AAEA,MAAI,KAAK,YAAY,KAAK,oBAAoB;AAC5C,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AACF;AAEO,SAAS,yBACd,OACA;AACA,QAAM,QAAQ,+BAA+B;AAC7C,SAAO;AAAA,IACL,sBAAsB;AAAA,EAAA;AAE1B;"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { GoogleMaps } from '@google/genai';
|
|
2
|
-
import { ProviderTool, Tool } from '@tanstack/ai';
|
|
3
|
-
export type GoogleMapsToolConfig = GoogleMaps;
|
|
4
|
-
/** @deprecated Renamed to `GoogleMapsToolConfig`. Will be removed in a future release. */
|
|
5
|
-
export type GoogleMapsTool = GoogleMapsToolConfig;
|
|
6
|
-
export type GeminiGoogleMapsTool = ProviderTool<'gemini', 'google_maps'>;
|
|
7
|
-
export declare function convertGoogleMapsToolToAdapterFormat(tool: Tool): {
|
|
8
|
-
googleMaps: GoogleMaps;
|
|
9
|
-
};
|
|
10
|
-
export declare function googleMapsTool(config?: GoogleMapsToolConfig): GeminiGoogleMapsTool;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { brandProviderTool } from "@tanstack/ai";
|
|
2
|
-
function convertGoogleMapsToolToAdapterFormat(tool) {
|
|
3
|
-
const metadata = tool.metadata;
|
|
4
|
-
return {
|
|
5
|
-
googleMaps: metadata
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
function googleMapsTool(config) {
|
|
9
|
-
return brandProviderTool({
|
|
10
|
-
name: "google_maps",
|
|
11
|
-
description: "",
|
|
12
|
-
metadata: config
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
export {
|
|
16
|
-
convertGoogleMapsToolToAdapterFormat,
|
|
17
|
-
googleMapsTool
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=google-maps-tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"google-maps-tool.js","sources":["../../../src/tools/google-maps-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\nimport type { GoogleMaps } from '@google/genai'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type GoogleMapsToolConfig = GoogleMaps\n\n/** @deprecated Renamed to `GoogleMapsToolConfig`. Will be removed in a future release. */\nexport type GoogleMapsTool = GoogleMapsToolConfig\n\nexport type GeminiGoogleMapsTool = ProviderTool<'gemini', 'google_maps'>\n\nexport function convertGoogleMapsToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as GoogleMapsToolConfig\n return {\n googleMaps: metadata,\n }\n}\n\nexport function googleMapsTool(\n config?: GoogleMapsToolConfig,\n): GeminiGoogleMapsTool {\n return brandProviderTool<GeminiGoogleMapsTool>({\n name: 'google_maps',\n description: '',\n metadata: config,\n })\n}\n"],"names":[],"mappings":";AAWO,SAAS,qCAAqC,MAAY;AAC/D,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,YAAY;AAAA,EAAA;AAEhB;AAEO,SAAS,eACd,QACsB;AACtB,SAAO,kBAAwC;AAAA,IAC7C,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,EAAA,CACX;AACH;"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { GoogleSearchRetrieval } from '@google/genai';
|
|
2
|
-
import { ProviderTool, Tool } from '@tanstack/ai';
|
|
3
|
-
export type GoogleSearchRetrievalToolConfig = GoogleSearchRetrieval;
|
|
4
|
-
/** @deprecated Renamed to `GoogleSearchRetrievalToolConfig`. Will be removed in a future release. */
|
|
5
|
-
export type GoogleSearchRetrievalTool = GoogleSearchRetrievalToolConfig;
|
|
6
|
-
export type GeminiGoogleSearchRetrievalTool = ProviderTool<'gemini', 'google_search_retrieval'>;
|
|
7
|
-
export declare function convertGoogleSearchRetrievalToolToAdapterFormat(tool: Tool): {
|
|
8
|
-
googleSearchRetrieval: GoogleSearchRetrieval;
|
|
9
|
-
};
|
|
10
|
-
export declare function googleSearchRetrievalTool(config?: GoogleSearchRetrievalToolConfig): GeminiGoogleSearchRetrievalTool;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { brandProviderTool } from "@tanstack/ai";
|
|
2
|
-
function convertGoogleSearchRetrievalToolToAdapterFormat(tool) {
|
|
3
|
-
const metadata = tool.metadata;
|
|
4
|
-
return {
|
|
5
|
-
googleSearchRetrieval: metadata
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
function googleSearchRetrievalTool(config) {
|
|
9
|
-
return brandProviderTool({
|
|
10
|
-
name: "google_search_retrieval",
|
|
11
|
-
description: "",
|
|
12
|
-
metadata: config
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
export {
|
|
16
|
-
convertGoogleSearchRetrievalToolToAdapterFormat,
|
|
17
|
-
googleSearchRetrievalTool
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=google-search-retriveal-tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"google-search-retriveal-tool.js","sources":["../../../src/tools/google-search-retriveal-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\nimport type { GoogleSearchRetrieval } from '@google/genai'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type GoogleSearchRetrievalToolConfig = GoogleSearchRetrieval\n\n/** @deprecated Renamed to `GoogleSearchRetrievalToolConfig`. Will be removed in a future release. */\nexport type GoogleSearchRetrievalTool = GoogleSearchRetrievalToolConfig\n\nexport type GeminiGoogleSearchRetrievalTool = ProviderTool<\n 'gemini',\n 'google_search_retrieval'\n>\n\nexport function convertGoogleSearchRetrievalToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as GoogleSearchRetrievalToolConfig\n return {\n googleSearchRetrieval: metadata,\n }\n}\n\nexport function googleSearchRetrievalTool(\n config?: GoogleSearchRetrievalToolConfig,\n): GeminiGoogleSearchRetrievalTool {\n return brandProviderTool<GeminiGoogleSearchRetrievalTool>({\n name: 'google_search_retrieval',\n description: '',\n metadata: config,\n })\n}\n"],"names":[],"mappings":";AAcO,SAAS,gDAAgD,MAAY;AAC1E,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,uBAAuB;AAAA,EAAA;AAE3B;AAEO,SAAS,0BACd,QACiC;AACjC,SAAO,kBAAmD;AAAA,IACxD,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,EAAA,CACX;AACH;"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { GoogleSearch } from '@google/genai';
|
|
2
|
-
import { ProviderTool, Tool } from '@tanstack/ai';
|
|
3
|
-
export type GoogleSearchToolConfig = GoogleSearch;
|
|
4
|
-
/** @deprecated Renamed to `GoogleSearchToolConfig`. Will be removed in a future release. */
|
|
5
|
-
export type GoogleSearchTool = GoogleSearchToolConfig;
|
|
6
|
-
export type GeminiGoogleSearchTool = ProviderTool<'gemini', 'google_search'>;
|
|
7
|
-
export declare function convertGoogleSearchToolToAdapterFormat(tool: Tool): {
|
|
8
|
-
googleSearch: GoogleSearch;
|
|
9
|
-
};
|
|
10
|
-
export declare function googleSearchTool(config?: GoogleSearchToolConfig): GeminiGoogleSearchTool;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { brandProviderTool } from "@tanstack/ai";
|
|
2
|
-
function convertGoogleSearchToolToAdapterFormat(tool) {
|
|
3
|
-
const metadata = tool.metadata;
|
|
4
|
-
return {
|
|
5
|
-
googleSearch: metadata
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
function googleSearchTool(config) {
|
|
9
|
-
return brandProviderTool({
|
|
10
|
-
name: "google_search",
|
|
11
|
-
description: "",
|
|
12
|
-
metadata: config
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
export {
|
|
16
|
-
convertGoogleSearchToolToAdapterFormat,
|
|
17
|
-
googleSearchTool
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=google-search-tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"google-search-tool.js","sources":["../../../src/tools/google-search-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\nimport type { GoogleSearch } from '@google/genai'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type GoogleSearchToolConfig = GoogleSearch\n\n/** @deprecated Renamed to `GoogleSearchToolConfig`. Will be removed in a future release. */\nexport type GoogleSearchTool = GoogleSearchToolConfig\n\nexport type GeminiGoogleSearchTool = ProviderTool<'gemini', 'google_search'>\n\nexport function convertGoogleSearchToolToAdapterFormat(tool: Tool) {\n const metadata = tool.metadata as GoogleSearchToolConfig\n return {\n googleSearch: metadata,\n }\n}\n\nexport function googleSearchTool(\n config?: GoogleSearchToolConfig,\n): GeminiGoogleSearchTool {\n return brandProviderTool<GeminiGoogleSearchTool>({\n name: 'google_search',\n description: '',\n metadata: config,\n })\n}\n"],"names":[],"mappings":";AAWO,SAAS,uCAAuC,MAAY;AACjE,QAAM,WAAW,KAAK;AACtB,SAAO;AAAA,IACL,cAAc;AAAA,EAAA;AAElB;AAEO,SAAS,iBACd,QACwB;AACxB,SAAO,kBAA0C;AAAA,IAC/C,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,EAAA,CACX;AACH;"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CodeExecutionTool } from './code-execution-tool.js';
|
|
2
|
-
import { ComputerUseTool } from './computer-use-tool.js';
|
|
3
|
-
import { FileSearchTool } from './file-search-tool.js';
|
|
4
|
-
import { FunctionDeclarationTool } from './function-declaration-tool.js';
|
|
5
|
-
import { GoogleMapsTool } from './google-maps-tool.js';
|
|
6
|
-
import { GoogleSearchRetrievalTool } from './google-search-retriveal-tool.js';
|
|
7
|
-
import { GoogleSearchTool } from './google-search-tool.js';
|
|
8
|
-
import { UrlContextTool } from './url-context-tool.js';
|
|
9
|
-
export { codeExecutionTool, type GeminiCodeExecutionTool, type CodeExecutionToolConfig, type CodeExecutionTool, } from './code-execution-tool.js';
|
|
10
|
-
export { computerUseTool, type GeminiComputerUseTool, type ComputerUseToolConfig, type ComputerUseTool, } from './computer-use-tool.js';
|
|
11
|
-
export { fileSearchTool, type GeminiFileSearchTool, type FileSearchToolConfig, type FileSearchTool, } from './file-search-tool.js';
|
|
12
|
-
export { functionDeclarationTools, type FunctionDeclarationTool, } from './function-declaration-tool.js';
|
|
13
|
-
export { googleMapsTool, type GeminiGoogleMapsTool, type GoogleMapsToolConfig, type GoogleMapsTool, } from './google-maps-tool.js';
|
|
14
|
-
export { googleSearchRetrievalTool, type GeminiGoogleSearchRetrievalTool, type GoogleSearchRetrievalToolConfig, type GoogleSearchRetrievalTool, } from './google-search-retriveal-tool.js';
|
|
15
|
-
export { googleSearchTool, type GeminiGoogleSearchTool, type GoogleSearchToolConfig, type GoogleSearchTool, } from './google-search-tool.js';
|
|
16
|
-
export { urlContextTool, type GeminiUrlContextTool, type UrlContextToolConfig, type UrlContextTool, } from './url-context-tool.js';
|
|
17
|
-
export type GoogleGeminiTool = CodeExecutionTool | ComputerUseTool | FileSearchTool | FunctionDeclarationTool | GoogleMapsTool | GoogleSearchRetrievalTool | GoogleSearchTool | UrlContextTool;
|
|
18
|
-
export { convertToolsToProviderFormat } from './tool-converter.js';
|
package/dist/esm/tools/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { codeExecutionTool } from "./code-execution-tool.js";
|
|
2
|
-
import { computerUseTool } from "./computer-use-tool.js";
|
|
3
|
-
import { fileSearchTool } from "./file-search-tool.js";
|
|
4
|
-
import { functionDeclarationTools } from "./function-declaration-tool.js";
|
|
5
|
-
import { googleMapsTool } from "./google-maps-tool.js";
|
|
6
|
-
import { googleSearchRetrievalTool } from "./google-search-retriveal-tool.js";
|
|
7
|
-
import { googleSearchTool } from "./google-search-tool.js";
|
|
8
|
-
import { urlContextTool } from "./url-context-tool.js";
|
|
9
|
-
import { convertToolsToProviderFormat } from "./tool-converter.js";
|
|
10
|
-
export {
|
|
11
|
-
codeExecutionTool,
|
|
12
|
-
computerUseTool,
|
|
13
|
-
convertToolsToProviderFormat,
|
|
14
|
-
fileSearchTool,
|
|
15
|
-
functionDeclarationTools,
|
|
16
|
-
googleMapsTool,
|
|
17
|
-
googleSearchRetrievalTool,
|
|
18
|
-
googleSearchTool,
|
|
19
|
-
urlContextTool
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Tool } from '@tanstack/ai';
|
|
2
|
-
import { ToolUnion } from '@google/genai';
|
|
3
|
-
/**
|
|
4
|
-
* Converts standard Tool format to Gemini-specific tool format
|
|
5
|
-
*
|
|
6
|
-
* @param tools - Array of standard Tool objects
|
|
7
|
-
* @returns Array of Gemini-specific tool definitions
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const tools: Tool[] = [{
|
|
12
|
-
* name: "get_weather",
|
|
13
|
-
* description: "Get weather for a location",
|
|
14
|
-
* inputSchema: z.object({
|
|
15
|
-
* location: z.string()
|
|
16
|
-
* })
|
|
17
|
-
* }];
|
|
18
|
-
*
|
|
19
|
-
* const geminiTools = convertToolsToProviderFormat(tools);
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export declare function convertToolsToProviderFormat<TTool extends Tool>(tools: Array<TTool> | undefined): Array<ToolUnion>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { convertCodeExecutionToolToAdapterFormat } from "./code-execution-tool.js";
|
|
2
|
-
import { convertComputerUseToolToAdapterFormat } from "./computer-use-tool.js";
|
|
3
|
-
import { convertFileSearchToolToAdapterFormat } from "./file-search-tool.js";
|
|
4
|
-
import { convertGoogleMapsToolToAdapterFormat } from "./google-maps-tool.js";
|
|
5
|
-
import { convertGoogleSearchRetrievalToolToAdapterFormat } from "./google-search-retriveal-tool.js";
|
|
6
|
-
import { convertGoogleSearchToolToAdapterFormat } from "./google-search-tool.js";
|
|
7
|
-
import { convertUrlContextToolToAdapterFormat } from "./url-context-tool.js";
|
|
8
|
-
function convertToolsToProviderFormat(tools) {
|
|
9
|
-
if (!tools || tools.length === 0) {
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
|
-
const result = [];
|
|
13
|
-
const functionDeclarations = [];
|
|
14
|
-
for (const tool of tools) {
|
|
15
|
-
const name = tool.name;
|
|
16
|
-
switch (name) {
|
|
17
|
-
case "code_execution":
|
|
18
|
-
result.push(convertCodeExecutionToolToAdapterFormat());
|
|
19
|
-
break;
|
|
20
|
-
case "computer_use":
|
|
21
|
-
result.push(convertComputerUseToolToAdapterFormat(tool));
|
|
22
|
-
break;
|
|
23
|
-
case "file_search":
|
|
24
|
-
result.push(convertFileSearchToolToAdapterFormat(tool));
|
|
25
|
-
break;
|
|
26
|
-
case "google_maps":
|
|
27
|
-
result.push(convertGoogleMapsToolToAdapterFormat(tool));
|
|
28
|
-
break;
|
|
29
|
-
case "google_search_retrieval":
|
|
30
|
-
result.push(convertGoogleSearchRetrievalToolToAdapterFormat(tool));
|
|
31
|
-
break;
|
|
32
|
-
case "google_search":
|
|
33
|
-
result.push(convertGoogleSearchToolToAdapterFormat(tool));
|
|
34
|
-
break;
|
|
35
|
-
case "url_context":
|
|
36
|
-
result.push(convertUrlContextToolToAdapterFormat());
|
|
37
|
-
break;
|
|
38
|
-
default:
|
|
39
|
-
if (!tool.description) {
|
|
40
|
-
throw new Error(
|
|
41
|
-
`Tool ${tool.name} requires a description for Gemini adapter`
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
functionDeclarations.push({
|
|
45
|
-
name: tool.name,
|
|
46
|
-
description: tool.description,
|
|
47
|
-
parameters: tool.inputSchema ?? {
|
|
48
|
-
type: "object",
|
|
49
|
-
properties: {},
|
|
50
|
-
required: []
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (functionDeclarations.length > 0) {
|
|
57
|
-
result.push({
|
|
58
|
-
functionDeclarations
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
63
|
-
export {
|
|
64
|
-
convertToolsToProviderFormat
|
|
65
|
-
};
|
|
66
|
-
//# sourceMappingURL=tool-converter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-converter.js","sources":["../../../src/tools/tool-converter.ts"],"sourcesContent":["import { convertCodeExecutionToolToAdapterFormat } from './code-execution-tool'\nimport { convertComputerUseToolToAdapterFormat } from './computer-use-tool'\nimport { convertFileSearchToolToAdapterFormat } from './file-search-tool'\nimport { convertGoogleMapsToolToAdapterFormat } from './google-maps-tool'\nimport { convertGoogleSearchRetrievalToolToAdapterFormat } from './google-search-retriveal-tool'\nimport { convertGoogleSearchToolToAdapterFormat } from './google-search-tool'\nimport { convertUrlContextToolToAdapterFormat } from './url-context-tool'\nimport type { Tool } from '@tanstack/ai'\nimport type { ToolUnion } from '@google/genai'\n\n/**\n * Converts standard Tool format to Gemini-specific tool format\n *\n * @param tools - Array of standard Tool objects\n * @returns Array of Gemini-specific tool definitions\n *\n * @example\n * ```typescript\n * const tools: Tool[] = [{\n * name: \"get_weather\",\n * description: \"Get weather for a location\",\n * inputSchema: z.object({\n * location: z.string()\n * })\n * }];\n *\n * const geminiTools = convertToolsToProviderFormat(tools);\n * ```\n */\nexport function convertToolsToProviderFormat<TTool extends Tool>(\n tools: Array<TTool> | undefined,\n): Array<ToolUnion> {\n if (!tools || tools.length === 0) {\n return []\n }\n const result: Array<ToolUnion> = []\n const functionDeclarations: Array<{\n name: string\n description?: string\n parameters?: any\n }> = []\n\n // Process each tool and group function declarations together\n for (const tool of tools) {\n const name = tool.name\n\n switch (name) {\n case 'code_execution':\n result.push(convertCodeExecutionToolToAdapterFormat(tool))\n break\n case 'computer_use':\n result.push(convertComputerUseToolToAdapterFormat(tool))\n break\n case 'file_search':\n result.push(convertFileSearchToolToAdapterFormat(tool))\n break\n case 'google_maps':\n result.push(convertGoogleMapsToolToAdapterFormat(tool))\n break\n case 'google_search_retrieval':\n result.push(convertGoogleSearchRetrievalToolToAdapterFormat(tool))\n break\n case 'google_search':\n result.push(convertGoogleSearchToolToAdapterFormat(tool))\n break\n case 'url_context':\n result.push(convertUrlContextToolToAdapterFormat(tool))\n break\n default:\n // Collect function declarations to group together\n // Description is required for Gemini function declarations\n if (!tool.description) {\n throw new Error(\n `Tool ${tool.name} requires a description for Gemini adapter`,\n )\n }\n\n // Tool schemas are already converted to JSON Schema in the ai layer\n functionDeclarations.push({\n name: tool.name,\n description: tool.description,\n parameters: tool.inputSchema ?? {\n type: 'object',\n properties: {},\n required: [],\n },\n })\n break\n }\n }\n\n // If we have function declarations, add them as a single tool\n if (functionDeclarations.length > 0) {\n result.push({\n functionDeclarations: functionDeclarations,\n })\n }\n\n return result\n}\n"],"names":[],"mappings":";;;;;;;AA6BO,SAAS,6BACd,OACkB;AAClB,MAAI,CAAC,SAAS,MAAM,WAAW,GAAG;AAChC,WAAO,CAAA;AAAA,EACT;AACA,QAAM,SAA2B,CAAA;AACjC,QAAM,uBAID,CAAA;AAGL,aAAW,QAAQ,OAAO;AACxB,UAAM,OAAO,KAAK;AAElB,YAAQ,MAAA;AAAA,MACN,KAAK;AACH,eAAO,KAAK,wCAA4C,CAAC;AACzD;AAAA,MACF,KAAK;AACH,eAAO,KAAK,sCAAsC,IAAI,CAAC;AACvD;AAAA,MACF,KAAK;AACH,eAAO,KAAK,qCAAqC,IAAI,CAAC;AACtD;AAAA,MACF,KAAK;AACH,eAAO,KAAK,qCAAqC,IAAI,CAAC;AACtD;AAAA,MACF,KAAK;AACH,eAAO,KAAK,gDAAgD,IAAI,CAAC;AACjE;AAAA,MACF,KAAK;AACH,eAAO,KAAK,uCAAuC,IAAI,CAAC;AACxD;AAAA,MACF,KAAK;AACH,eAAO,KAAK,qCAAyC,CAAC;AACtD;AAAA,MACF;AAGE,YAAI,CAAC,KAAK,aAAa;AACrB,gBAAM,IAAI;AAAA,YACR,QAAQ,KAAK,IAAI;AAAA,UAAA;AAAA,QAErB;AAGA,6BAAqB,KAAK;AAAA,UACxB,MAAM,KAAK;AAAA,UACX,aAAa,KAAK;AAAA,UAClB,YAAY,KAAK,eAAe;AAAA,YAC9B,MAAM;AAAA,YACN,YAAY,CAAA;AAAA,YACZ,UAAU,CAAA;AAAA,UAAC;AAAA,QACb,CACD;AACD;AAAA,IAAA;AAAA,EAEN;AAGA,MAAI,qBAAqB,SAAS,GAAG;AACnC,WAAO,KAAK;AAAA,MACV;AAAA,IAAA,CACD;AAAA,EACH;AAEA,SAAO;AACT;"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ProviderTool, Tool } from '@tanstack/ai';
|
|
2
|
-
export interface UrlContextToolConfig {
|
|
3
|
-
}
|
|
4
|
-
/** @deprecated Renamed to `UrlContextToolConfig`. Will be removed in a future release. */
|
|
5
|
-
export type UrlContextTool = UrlContextToolConfig;
|
|
6
|
-
export type GeminiUrlContextTool = ProviderTool<'gemini', 'url_context'>;
|
|
7
|
-
export declare function convertUrlContextToolToAdapterFormat(_tool: Tool): {
|
|
8
|
-
urlContext: {};
|
|
9
|
-
};
|
|
10
|
-
export declare function urlContextTool(): GeminiUrlContextTool;
|