@tanstack/ai-gemini 0.24.0 → 0.24.2
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/README.md +10 -1
- package/dist/esm/experimental/text-interactions/adapter.d.ts +8 -5
- package/dist/esm/experimental/text-interactions/adapter.js +17 -9
- package/dist/esm/experimental/text-interactions/adapter.js.map +1 -1
- package/dist/esm/tools/code-execution-tool.js +3 -3
- package/dist/esm/tools/code-execution-tool.js.map +1 -1
- package/dist/esm/tools/computer-use-tool.js +4 -4
- package/dist/esm/tools/computer-use-tool.js.map +1 -1
- package/dist/esm/tools/file-search-tool.js +4 -4
- package/dist/esm/tools/file-search-tool.js.map +1 -1
- package/dist/esm/tools/gemini-provider-tool.d.ts +16 -0
- package/dist/esm/tools/gemini-provider-tool.js +42 -0
- package/dist/esm/tools/gemini-provider-tool.js.map +1 -0
- package/dist/esm/tools/google-maps-tool.js +4 -4
- package/dist/esm/tools/google-maps-tool.js.map +1 -1
- package/dist/esm/tools/google-search-retriveal-tool.js +4 -4
- package/dist/esm/tools/google-search-retriveal-tool.js.map +1 -1
- package/dist/esm/tools/google-search-tool.js +4 -4
- package/dist/esm/tools/google-search-tool.js.map +1 -1
- package/dist/esm/tools/tool-converter.js +5 -2
- package/dist/esm/tools/tool-converter.js.map +1 -1
- package/dist/esm/tools/url-context-tool.js +3 -3
- package/dist/esm/tools/url-context-tool.js.map +1 -1
- package/package.json +3 -3
- package/src/experimental/text-interactions/adapter.ts +31 -18
- package/src/tools/code-execution-tool.ts +9 -6
- package/src/tools/computer-use-tool.ts +19 -13
- package/src/tools/file-search-tool.ts +13 -7
- package/src/tools/gemini-provider-tool.ts +60 -0
- package/src/tools/google-maps-tool.ts +13 -7
- package/src/tools/google-search-retriveal-tool.ts +15 -7
- package/src/tools/google-search-tool.ts +13 -7
- package/src/tools/tool-converter.ts +5 -4
- package/src/tools/url-context-tool.ts +9 -6
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
brandGeminiProviderTool,
|
|
3
|
+
getGeminiProviderToolMetadata,
|
|
4
|
+
} from './gemini-provider-tool'
|
|
2
5
|
import type { GoogleSearch } from '@google/genai'
|
|
3
6
|
import type { ProviderTool, Tool } from '@tanstack/ai'
|
|
4
7
|
|
|
@@ -10,7 +13,7 @@ export type GoogleSearchTool = GoogleSearchToolConfig
|
|
|
10
13
|
export type GeminiGoogleSearchTool = ProviderTool<'gemini', 'google_search'>
|
|
11
14
|
|
|
12
15
|
export function convertGoogleSearchToolToAdapterFormat(tool: Tool) {
|
|
13
|
-
const metadata = tool
|
|
16
|
+
const metadata = getGeminiProviderToolMetadata(tool) as GoogleSearchToolConfig
|
|
14
17
|
return {
|
|
15
18
|
googleSearch: metadata,
|
|
16
19
|
}
|
|
@@ -19,9 +22,12 @@ export function convertGoogleSearchToolToAdapterFormat(tool: Tool) {
|
|
|
19
22
|
export function googleSearchTool(
|
|
20
23
|
config?: GoogleSearchToolConfig,
|
|
21
24
|
): GeminiGoogleSearchTool {
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
return brandGeminiProviderTool<GeminiGoogleSearchTool>(
|
|
26
|
+
{
|
|
27
|
+
name: 'google_search',
|
|
28
|
+
description: '',
|
|
29
|
+
metadata: config,
|
|
30
|
+
},
|
|
31
|
+
'google_search',
|
|
32
|
+
)
|
|
27
33
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { assertUniqueToolNames } from '@tanstack/ai/adapter-internals'
|
|
1
2
|
import { convertCodeExecutionToolToAdapterFormat } from './code-execution-tool'
|
|
2
3
|
import { convertComputerUseToolToAdapterFormat } from './computer-use-tool'
|
|
3
4
|
import { convertFileSearchToolToAdapterFormat } from './file-search-tool'
|
|
5
|
+
import { getGeminiProviderToolKind } from './gemini-provider-tool'
|
|
4
6
|
import { convertGoogleMapsToolToAdapterFormat } from './google-maps-tool'
|
|
5
7
|
import { convertGoogleSearchRetrievalToolToAdapterFormat } from './google-search-retriveal-tool'
|
|
6
8
|
import { convertGoogleSearchToolToAdapterFormat } from './google-search-tool'
|
|
@@ -33,6 +35,7 @@ export function convertToolsToProviderFormat<TTool extends Tool>(
|
|
|
33
35
|
if (!tools || tools.length === 0) {
|
|
34
36
|
return []
|
|
35
37
|
}
|
|
38
|
+
assertUniqueToolNames(tools)
|
|
36
39
|
const result: Array<ToolUnion> = []
|
|
37
40
|
const functionDeclarations: Array<{
|
|
38
41
|
name: string
|
|
@@ -42,9 +45,7 @@ export function convertToolsToProviderFormat<TTool extends Tool>(
|
|
|
42
45
|
|
|
43
46
|
// Process each tool and group function declarations together
|
|
44
47
|
for (const tool of tools) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
switch (name) {
|
|
48
|
+
switch (getGeminiProviderToolKind(tool)) {
|
|
48
49
|
case 'code_execution':
|
|
49
50
|
result.push(convertCodeExecutionToolToAdapterFormat(tool))
|
|
50
51
|
break
|
|
@@ -66,7 +67,7 @@ export function convertToolsToProviderFormat<TTool extends Tool>(
|
|
|
66
67
|
case 'url_context':
|
|
67
68
|
result.push(convertUrlContextToolToAdapterFormat(tool))
|
|
68
69
|
break
|
|
69
|
-
|
|
70
|
+
case undefined:
|
|
70
71
|
// Collect function declarations to group together
|
|
71
72
|
// Description is required for Gemini function declarations
|
|
72
73
|
if (!tool.description) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { brandGeminiProviderTool } from './gemini-provider-tool'
|
|
2
2
|
import type { ProviderTool, Tool } from '@tanstack/ai'
|
|
3
3
|
|
|
4
4
|
export interface UrlContextToolConfig {}
|
|
@@ -15,9 +15,12 @@ export function convertUrlContextToolToAdapterFormat(_tool: Tool) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export function urlContextTool(): GeminiUrlContextTool {
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
return brandGeminiProviderTool<GeminiUrlContextTool>(
|
|
19
|
+
{
|
|
20
|
+
name: 'url_context',
|
|
21
|
+
description: '',
|
|
22
|
+
metadata: {},
|
|
23
|
+
},
|
|
24
|
+
'url_context',
|
|
25
|
+
)
|
|
23
26
|
}
|