@effect-uai/google 0.9.0 → 0.11.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/dist/Gemini.d.mts +4 -2
- package/dist/Gemini.d.mts.map +1 -1
- package/dist/Gemini.mjs +18 -6
- package/dist/Gemini.mjs.map +1 -1
- package/dist/GeminiEmbedding.mjs +1 -1
- package/dist/GeminiEmbedding.mjs.map +1 -1
- package/dist/GeminiSynthesizer.d.mts.map +1 -1
- package/dist/GeminiSynthesizer.mjs +2 -2
- package/dist/GeminiSynthesizer.mjs.map +1 -1
- package/dist/GeminiSynthesizer.test.mjs +1 -1
- package/dist/GeminiTools.d.mts +42 -0
- package/dist/GeminiTools.d.mts.map +1 -0
- package/dist/GeminiTools.mjs +64 -0
- package/dist/GeminiTools.mjs.map +1 -0
- package/dist/GoogleDeepResearch.d.mts +70 -0
- package/dist/GoogleDeepResearch.d.mts.map +1 -0
- package/dist/GoogleDeepResearch.mjs +269 -0
- package/dist/GoogleDeepResearch.mjs.map +1 -0
- package/dist/LyriaGenerator.mjs +1 -1
- package/dist/LyriaGenerator.mjs.map +1 -1
- package/dist/LyriaGenerator.test.mjs +1 -1
- package/dist/codec.d.mts +22 -5
- package/dist/codec.d.mts.map +1 -1
- package/dist/codec.mjs +52 -30
- package/dist/codec.mjs.map +1 -1
- package/dist/{dist-DMsg8YLb.mjs → dist-CWoAuwS9.mjs} +7 -7
- package/dist/{dist-DMsg8YLb.mjs.map → dist-CWoAuwS9.mjs.map} +1 -1
- package/dist/geminiSpeechCodec.test.mjs +1 -1
- package/dist/geminiTools.test.d.mts +1 -0
- package/dist/geminiTools.test.mjs +80 -0
- package/dist/geminiTools.test.mjs.map +1 -0
- package/dist/index.d.mts +4 -2
- package/dist/index.mjs +3 -1
- package/dist/models.d.mts +11 -1
- package/dist/models.d.mts.map +1 -1
- package/package.json +8 -4
- package/src/Gemini.ts +21 -3
- package/src/GeminiEmbedding.ts +1 -1
- package/src/GeminiSynthesizer.ts +4 -2
- package/src/GeminiTools.ts +95 -0
- package/src/GoogleDeepResearch.ts +446 -0
- package/src/LyriaGenerator.ts +1 -1
- package/src/codec.ts +81 -28
- package/src/geminiTools.test.ts +88 -0
- package/src/index.ts +2 -0
- package/src/models.ts +15 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Effect, Option, Result, Schema } from "effect"
|
|
2
|
+
import * as Tool from "@effect-uai/core/Tool"
|
|
3
|
+
import { descriptorsOf, providerToolsOf } from "@effect-uai/core/Tool"
|
|
4
|
+
import { describe, expect, it } from "vitest"
|
|
5
|
+
import { WireChunk, buildRequestBody } from "./codec.js"
|
|
6
|
+
import { codeExecutionTool, googleSearchTool, renderProviderTools } from "./GeminiTools.js"
|
|
7
|
+
|
|
8
|
+
const localTool = Tool.make({
|
|
9
|
+
name: "get_weather",
|
|
10
|
+
description: "Look up the weather.",
|
|
11
|
+
inputSchema: Tool.fromEffectSchema(Schema.Struct({ city: Schema.String })),
|
|
12
|
+
run: ({ city }) => Effect.succeed(`sunny in ${city}`),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const build = (toolkit: Record<string, Tool.AnyTool>) => {
|
|
16
|
+
const entries = Result.getOrThrow(renderProviderTools(providerToolsOf(toolkit)))
|
|
17
|
+
return buildRequestBody([], Option.none(), descriptorsOf(toolkit), entries)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe("Gemini provider tools", () => {
|
|
21
|
+
it("renders google_search to the native googleSearch entry", () => {
|
|
22
|
+
const body = build({ google_search: googleSearchTool })
|
|
23
|
+
expect(body.tools).toEqual([{ googleSearch: {} }])
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it("renders a mixed toolkit to both a functionDeclarations entry and the native entry", () => {
|
|
27
|
+
const body = build({ get_weather: localTool, code_execution: codeExecutionTool })
|
|
28
|
+
expect(body.tools).toEqual([
|
|
29
|
+
{
|
|
30
|
+
functionDeclarations: [
|
|
31
|
+
expect.objectContaining({ name: "get_weather", description: "Look up the weather." }),
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
{ codeExecution: {} },
|
|
35
|
+
])
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it("omits toolConfig for a grounding-only request (no forced function-calling mode)", () => {
|
|
39
|
+
const body = build({ google_search: googleSearchTool })
|
|
40
|
+
expect(body.toolConfig).toBeUndefined()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it("sets toolConfig when a function declaration is present", () => {
|
|
44
|
+
const body = build({ get_weather: localTool, google_search: googleSearchTool })
|
|
45
|
+
expect(body.toolConfig).toEqual({ functionCallingConfig: { mode: "AUTO" } })
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it("fails on a foreign provider tool", () => {
|
|
49
|
+
const foreign = Tool.provider({
|
|
50
|
+
name: "web_search",
|
|
51
|
+
description: "Anthropic web search.",
|
|
52
|
+
inputSchema: Tool.noInput,
|
|
53
|
+
provider: "anthropic",
|
|
54
|
+
config: { type: "web_search_20250305" },
|
|
55
|
+
})
|
|
56
|
+
const result = renderProviderTools(providerToolsOf({ web_search: foreign }))
|
|
57
|
+
expect(Result.isFailure(result)).toBe(true)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it("fails on an unrecognized config kind", () => {
|
|
61
|
+
const bogus = Tool.provider({
|
|
62
|
+
name: "mystery",
|
|
63
|
+
description: "Unknown Gemini tool.",
|
|
64
|
+
inputSchema: Tool.noInput,
|
|
65
|
+
provider: "gemini",
|
|
66
|
+
config: { kind: "telepathy" },
|
|
67
|
+
})
|
|
68
|
+
const result = renderProviderTools(providerToolsOf({ mystery: bogus }))
|
|
69
|
+
expect(Result.isFailure(result)).toBe(true)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it("decodes a grounded chunk without throwing (groundingMetadata is dropped)", () => {
|
|
73
|
+
const grounded = {
|
|
74
|
+
candidates: [
|
|
75
|
+
{
|
|
76
|
+
content: { role: "model", parts: [{ text: "Grounded answer." }] },
|
|
77
|
+
groundingMetadata: {
|
|
78
|
+
webSearchQueries: ["effect ts"],
|
|
79
|
+
groundingChunks: [{ web: { uri: "https://example.com", title: "Example" } }],
|
|
80
|
+
},
|
|
81
|
+
finishReason: "STOP",
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
}
|
|
85
|
+
const chunk = Schema.decodeUnknownSync(WireChunk)(grounded)
|
|
86
|
+
expect(chunk.candidates?.[0]?.content?.parts?.[0]).toEqual({ text: "Grounded answer." })
|
|
87
|
+
})
|
|
88
|
+
})
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * as Gemini from "./Gemini.js"
|
|
2
|
+
export * as GeminiTools from "./GeminiTools.js"
|
|
2
3
|
export * as GeminiEmbedding from "./GeminiEmbedding.js"
|
|
3
4
|
export * as GeminiSynthesizer from "./GeminiSynthesizer.js"
|
|
5
|
+
export * as GoogleDeepResearch from "./GoogleDeepResearch.js"
|
|
4
6
|
export * as LyriaGenerator from "./LyriaGenerator.js"
|
|
5
7
|
export * as codec from "./codec.js"
|
|
6
8
|
export * from "./models.js"
|
package/src/models.ts
CHANGED
|
@@ -17,6 +17,21 @@ export type GoogleModel =
|
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
18
18
|
| (string & {})
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Deep-research agent identifiers for the Interactions API (`POST
|
|
22
|
+
* /v1beta/interactions`). `-preview` is the fast tier, `-max-` the
|
|
23
|
+
* comprehensive one. Preview surface: verify against live docs before relying on
|
|
24
|
+
* exact ids. The `(string & {})` tail accepts any string so a renamed agent
|
|
25
|
+
* works without an SDK update.
|
|
26
|
+
*
|
|
27
|
+
* Reference: https://ai.google.dev/gemini-api/docs/interactions/deep-research
|
|
28
|
+
*/
|
|
29
|
+
export type GoogleDeepResearchModel =
|
|
30
|
+
| "deep-research-preview-04-2026"
|
|
31
|
+
| "deep-research-max-preview-04-2026"
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
33
|
+
| (string & {})
|
|
34
|
+
|
|
20
35
|
/**
|
|
21
36
|
* Known Gemini embedding model identifiers.
|
|
22
37
|
*
|