@opencode-ai/ai
Advanced tools
@@ -9,5 +9,12 @@ import { Schema } from "effect"; | ||
| readonly [key: string]: unknown; | ||
| readonly cachedContent?: string; | ||
| readonly safetySettings?: ReadonlyArray<{ | ||
| readonly category: "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY" | (string & {}); | ||
| readonly threshold: "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF" | (string & {}); | ||
| }>; | ||
| readonly serviceTier?: "standard" | "flex" | "priority" | (string & {}); | ||
| readonly thinkingConfig?: { | ||
| readonly thinkingBudget?: number; | ||
| readonly includeThoughts?: boolean; | ||
| readonly thinkingLevel?: "minimal" | "low" | "medium" | "high" | (string & {}); | ||
| }; | ||
@@ -19,2 +26,3 @@ } | ||
| declare const GeminiBody: Schema.Struct<{ | ||
| cachedContent: Schema.optional<Schema.String>; | ||
| contents: Schema.$Array<Schema.Struct<{ | ||
@@ -52,2 +60,7 @@ readonly role: Schema.Literals<readonly ["user", "model"]>; | ||
| }>>; | ||
| safetySettings: Schema.optional<Schema.$Array<Schema.Struct<{ | ||
| readonly category: Schema.String; | ||
| readonly threshold: Schema.String; | ||
| }>>>; | ||
| serviceTier: Schema.optional<Schema.String>; | ||
| systemInstruction: Schema.optional<Schema.Struct<{ | ||
@@ -80,2 +93,3 @@ readonly parts: Schema.$Array<Schema.Struct<{ | ||
| readonly includeThoughts: Schema.optional<Schema.Boolean>; | ||
| readonly thinkingLevel: Schema.optional<Schema.String>; | ||
| }>>; | ||
@@ -140,2 +154,3 @@ }>>; | ||
| readonly includeThoughts?: boolean | undefined; | ||
| readonly thinkingLevel?: string | undefined; | ||
| } | undefined; | ||
@@ -155,2 +170,8 @@ readonly maxOutputTokens?: number | undefined; | ||
| } | undefined; | ||
| readonly cachedContent?: string | undefined; | ||
| readonly safetySettings?: readonly { | ||
| readonly category: string; | ||
| readonly threshold: string; | ||
| }[] | undefined; | ||
| readonly serviceTier?: string | undefined; | ||
| }, string, { | ||
@@ -254,2 +275,3 @@ readonly candidates?: readonly { | ||
| readonly includeThoughts?: boolean | undefined; | ||
| readonly thinkingLevel?: string | undefined; | ||
| } | undefined; | ||
@@ -269,3 +291,9 @@ readonly maxOutputTokens?: number | undefined; | ||
| } | undefined; | ||
| readonly cachedContent?: string | undefined; | ||
| readonly safetySettings?: readonly { | ||
| readonly category: string; | ||
| readonly threshold: string; | ||
| }[] | undefined; | ||
| readonly serviceTier?: string | undefined; | ||
| }, import("../route/transport/http").HttpPrepared<string>>; | ||
| export * as Gemini from "./gemini"; |
@@ -76,3 +76,8 @@ import { Effect, Schema } from "effect"; | ||
| includeThoughts: Schema.optional(Schema.Boolean), | ||
| thinkingLevel: Schema.optional(Schema.String), | ||
| }); | ||
| const GeminiSafetySetting = Schema.Struct({ | ||
| category: Schema.String, | ||
| threshold: Schema.String, | ||
| }); | ||
| const GeminiGenerationConfig = Schema.Struct({ | ||
@@ -87,3 +92,6 @@ maxOutputTokens: Schema.optional(Schema.Number), | ||
| const GeminiBodyFields = { | ||
| cachedContent: Schema.optional(Schema.String), | ||
| contents: Schema.Array(GeminiContent), | ||
| safetySettings: optionalArray(GeminiSafetySetting), | ||
| serviceTier: Schema.optional(Schema.String), | ||
| systemInstruction: Schema.optional(GeminiSystemInstruction), | ||
@@ -253,13 +261,28 @@ tools: optionalArray(GeminiTool), | ||
| const resolveOptions = (request) => { | ||
| const value = request.providerOptions?.gemini?.thinkingConfig; | ||
| if (!ProviderShared.isRecord(value)) | ||
| return {}; | ||
| const input = request.providerOptions?.gemini; | ||
| const value = input?.thinkingConfig; | ||
| const thinkingConfig = { | ||
| thinkingBudget: typeof value.thinkingBudget === "number" ? value.thinkingBudget : undefined, | ||
| includeThoughts: typeof value.includeThoughts === "boolean" ? value.includeThoughts : undefined, | ||
| thinkingBudget: ProviderShared.isRecord(value) && typeof value.thinkingBudget === "number" ? value.thinkingBudget : undefined, | ||
| includeThoughts: ProviderShared.isRecord(value) && typeof value.includeThoughts === "boolean" | ||
| ? value.includeThoughts | ||
| : ProviderShared.isRecord(value) | ||
| ? true | ||
| : undefined, | ||
| thinkingLevel: ProviderShared.isRecord(value) && typeof value.thinkingLevel === "string" ? value.thinkingLevel : undefined, | ||
| }; | ||
| return { | ||
| cachedContent: typeof input?.cachedContent === "string" ? input.cachedContent : undefined, | ||
| safetySettings: mapSafetySettings(input?.safetySettings), | ||
| serviceTier: typeof input?.serviceTier === "string" ? input.serviceTier : undefined, | ||
| thinkingConfig: Object.values(thinkingConfig).some((item) => item !== undefined) ? thinkingConfig : undefined, | ||
| }; | ||
| }; | ||
| function mapSafetySettings(value) { | ||
| if (!Array.isArray(value)) | ||
| return undefined; | ||
| const settings = value.flatMap((item) => ProviderShared.isRecord(item) && typeof item.category === "string" && typeof item.threshold === "string" | ||
| ? [{ category: item.category, threshold: item.threshold }] | ||
| : []); | ||
| return settings; | ||
| } | ||
| const fromRequest = Effect.fn("Gemini.fromRequest")(function* (request) { | ||
@@ -279,3 +302,6 @@ const hasTools = request.tools.length > 0; | ||
| return { | ||
| cachedContent: options.cachedContent, | ||
| contents: yield* lowerMessages(request), | ||
| safetySettings: options.safetySettings, | ||
| serviceTier: options.serviceTier, | ||
| systemInstruction: request.system.length === 0 ? undefined : { parts: [{ text: ProviderShared.joinText(request.system) }] }, | ||
@@ -282,0 +308,0 @@ tools: hasTools |
@@ -77,2 +77,3 @@ import type { ProviderPackage } from "../provider-package"; | ||
| readonly includeThoughts?: boolean | undefined; | ||
| readonly thinkingLevel?: string | undefined; | ||
| } | undefined; | ||
@@ -92,2 +93,8 @@ readonly maxOutputTokens?: number | undefined; | ||
| } | undefined; | ||
| readonly cachedContent?: string | undefined; | ||
| readonly safetySettings?: readonly { | ||
| readonly category: string; | ||
| readonly threshold: string; | ||
| }[] | undefined; | ||
| readonly serviceTier?: string | undefined; | ||
| }, import("../route/transport/http").HttpPrepared<string>>[]; | ||
@@ -94,0 +101,0 @@ export declare const configure: (input?: Config) => { |
@@ -60,2 +60,3 @@ import type { RouteDefaultsInput } from "../route/client"; | ||
| readonly includeThoughts?: boolean | undefined; | ||
| readonly thinkingLevel?: string | undefined; | ||
| } | undefined; | ||
@@ -75,2 +76,8 @@ readonly maxOutputTokens?: number | undefined; | ||
| } | undefined; | ||
| readonly cachedContent?: string | undefined; | ||
| readonly safetySettings?: readonly { | ||
| readonly category: string; | ||
| readonly threshold: string; | ||
| }[] | undefined; | ||
| readonly serviceTier?: string | undefined; | ||
| }, import("../route/transport/http").HttpPrepared<string>>[]; | ||
@@ -77,0 +84,0 @@ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & { |
+3
-3
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "version": "0.0.0-next-16570", | ||
| "version": "0.0.0-next-16573", | ||
| "name": "@opencode-ai/ai", | ||
@@ -33,3 +33,3 @@ "type": "module", | ||
| "@effect/platform-node": "4.0.0-beta.101", | ||
| "@opencode-ai/http-recorder": "0.0.0-next-16570", | ||
| "@opencode-ai/http-recorder": "0.0.0-next-16573", | ||
| "@tsconfig/bun": "1.0.9", | ||
@@ -43,3 +43,3 @@ "@types/bun": "1.3.13", | ||
| "@smithy/util-utf8": "4.2.2", | ||
| "@opencode-ai/schema": "0.0.0-next-16570", | ||
| "@opencode-ai/schema": "0.0.0-next-16573", | ||
| "aws4fetch": "1.0.20", | ||
@@ -46,0 +46,0 @@ "effect": "4.0.0-beta.101", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1081447
0.32%25243
0.27%+ Added
- Removed