Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ import { Agent } from "jsr:@alphaxiv/agents";
import { geminiModel } from "jsr:@alphaxiv/agents/gemini";

const paperExtractor = new Agent({
model: geminiModel({ model: "gemini-2.0-flash" }),
model: geminiModel({ model: "gemini-3.5-flash-lite" }),
instructions: "Extract the paper title and abstract from the raw text.",
output: z.object({
title: z.string(),
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"imports": {
"@anthropic-ai/sdk": "npm:@anthropic-ai/sdk@^0.90.0",
"@google/genai": "npm:@google/genai@^1.48.0",
"@google/genai": "npm:@google/genai@^3.4.0",
"@lino/pdf-parse": "jsr:@lino/pdf-parse@^0.3.2",
"@std/assert": "jsr:@std/assert@^1.0.19",
"@std/async": "jsr:@std/async@^1.2.0",
Expand Down
60 changes: 23 additions & 37 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/structured-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import z from "zod";
import { Agent } from "../mod.ts";

const agent = new Agent({
model: "gemini:gemini-2.0-flash",
model: "gemini:gemini-3.5-flash-lite",
instructions:
"You are an expert at extracting out the title and abstract from raw text from the pdf of a research paper. The user will give you the raw text.",
output: z.object({
Expand Down
38 changes: 38 additions & 0 deletions src/adapters/anthropic/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@ function extended<const T extends readonly [ThinkingLevel, ...ThinkingLevel[]]>(

const anthropicModelThinkingSupportDefinition = {
// Adaptive thinking only (effort controls thinking intensity)
"claude-fable-5-2": adaptive({
levels: ["low", "medium", "high", "xhigh", "max"],
default: "high",
}),
"claude-fable-5-1": adaptive({
levels: ["low", "medium", "high", "xhigh", "max"],
default: "high",
}),
"claude-fable-5": adaptive({
levels: ["low", "medium", "high", "xhigh", "max"],
default: "high",
}),

// Verified organizations only
"claude-mythos-5-2": adaptive({
levels: ["low", "medium", "high", "xhigh", "max"],
default: "high",
}),
"claude-mythos-5-1": adaptive({
levels: ["low", "medium", "high", "xhigh", "max"],
default: "high",
}),

"claude-opus-5-5": adaptive({
levels: ["low", "medium", "high", "xhigh", "max"],
default: "medium",
Expand All @@ -90,10 +113,18 @@ const anthropicModelThinkingSupportDefinition = {
levels: ["low", "medium", "high", "max"],
default: "high",
}),
"claude-sonnet-5-5": adaptive({
levels: ["low", "medium", "high", "xhigh", "max"],
default: "high",
}),
"claude-sonnet-5": adaptive({
levels: ["low", "medium", "high", "xhigh", "max"],
default: "high",
}),
"claude-haiku-5-5": adaptive({
levels: ["low", "medium", "high", "xhigh", "max"],
default: "medium",
}),

// Both adaptive thinking (default) and extended thinking (opt-in via thinkingLevel)
"claude-sonnet-4-6": adaptiveOrExtended({
Expand Down Expand Up @@ -187,12 +218,19 @@ export type SupportsInterleaved<TModel extends AnthropicModels> = ModelConfig<TM
* Model support for native structured ouput.
*/
export const anthropicModelStructuredOutputSupport = {
"claude-fable-5-2": true,
"claude-fable-5-1": true,
"claude-fable-5": true,
"claude-mythos-5-2": true,
"claude-mythos-5-1": true,
"claude-opus-5-5": true,
"claude-opus-5": true,
"claude-opus-4-8": true,
"claude-opus-4-7": true,
"claude-opus-4-6": true,
"claude-sonnet-5-5": true,
"claude-sonnet-5": true,
"claude-haiku-5-5": true,
"claude-sonnet-4-6": true,

"claude-opus-4-5": true,
Expand Down
7 changes: 7 additions & 0 deletions src/adapters/anthropic/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ export interface ExtendedThinkingSupport<T extends string> {
}

export interface AnthropicModelThinkingSupportMap {
"claude-fable-5-2": AdaptiveThinkingSupport<"low" | "medium" | "high" | "xhigh" | "max">;
"claude-fable-5-1": AdaptiveThinkingSupport<"low" | "medium" | "high" | "xhigh" | "max">;
"claude-fable-5": AdaptiveThinkingSupport<"low" | "medium" | "high" | "xhigh" | "max">;
"claude-mythos-5-2": AdaptiveThinkingSupport<"low" | "medium" | "high" | "xhigh" | "max">;
"claude-mythos-5-1": AdaptiveThinkingSupport<"low" | "medium" | "high" | "xhigh" | "max">;
"claude-opus-5-5": AdaptiveThinkingSupport<"low" | "medium" | "high" | "xhigh" | "max">;
"claude-opus-5": AdaptiveThinkingSupport<"low" | "medium" | "high" | "xhigh" | "max">;
"claude-opus-4-8": AdaptiveThinkingSupport<"low" | "medium" | "high" | "xhigh" | "max">;
"claude-opus-4-7": AdaptiveThinkingSupport<"low" | "medium" | "high" | "xhigh" | "max">;
"claude-opus-4-6": AdaptiveThinkingSupport<"low" | "medium" | "high" | "max">;
"claude-sonnet-5-5": AdaptiveThinkingSupport<"low" | "medium" | "high" | "xhigh" | "max">;
"claude-sonnet-5": AdaptiveThinkingSupport<"low" | "medium" | "high" | "xhigh" | "max">;
"claude-haiku-5-5": AdaptiveThinkingSupport<"low" | "medium" | "high" | "xhigh" | "max">;
"claude-sonnet-4-6": AdaptiveOrExtendedThinkingSupport<
"adaptive" | "low" | "medium" | "high",
"low" | "medium" | "high"
Expand Down
2 changes: 2 additions & 0 deletions src/adapters/gemini/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export function geminiModel<zO, zI, TModel extends GoogleModels>(options: {
apiKey: options.apiKey ?? requireEnv("GEMINI_API_KEY"),
httpOptions: {
baseUrl: options.baseUrl,
// @google/genai 3.x defaults to v1, which lacks some preview models and features.
apiVersion: "v1beta",
},
},
thinkingConfig: getThinkingConfig(options.model, options.thinkingLevel),
Expand Down
22 changes: 17 additions & 5 deletions src/adapters/google_genai/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type GoogleThinkingLevel =
| "low"
| "medium"
| "high"
| "xhigh"
| "dynamic";

type ThinkingLevelOptions<T extends readonly GoogleThinkingLevel[]> = {
Expand Down Expand Up @@ -44,6 +45,18 @@ function thinkingLevel<const T extends readonly [GoogleThinkingLevel, ...GoogleT
}

const googleModelSupportedThinkingLevelsDefinition = {
"gemini-4-hydrogen": thinkingLevel({
levels: ["low", "medium", "high", "xhigh"],
default: "high",
}),
"gemini-4-carbon": thinkingLevel({
levels: ["low", "medium", "high"],
default: "medium",
}),
"gemini-4-argon": thinkingLevel({
levels: ["low", "medium", "high"],
default: "medium",
}),
"gemini-3.8-flash": thinkingLevel({
levels: ["low", "medium", "high"],
default: "medium",
Expand Down Expand Up @@ -89,11 +102,6 @@ const googleModelSupportedThinkingLevelsDefinition = {
"gemini-2.5-flash-lite": legacyThinkingBudget(),
"gemini-2.5-flash-lite-preview-09-2025": legacyThinkingBudget(),
"gemini-2.5-flash-native-audio-preview-12-2025": legacyThinkingBudget(),
// No thinking support
"gemini-2.0-flash": thinkingUnsupported(),
"gemini-2.0-flash-001": thinkingUnsupported(),
"gemini-2.0-flash-lite": thinkingUnsupported(),
"gemini-2.0-flash-lite-001": thinkingUnsupported(),
} as const satisfies GoogleModelSupportedThinkingLevelsMap;

export const googleModelSupportedThinkingLevels: GoogleModelSupportedThinkingLevelsMap =
Expand All @@ -110,6 +118,8 @@ const legacyThinkingBudgets: Record<GoogleThinkingLevel, number> = {
low: 1024,
medium: 8192,
high: 24576,
// No legacy-budget model accepts xhigh; the entry only satisfies the Record type.
xhigh: 24576,
dynamic: -1,
} as const;

Expand All @@ -131,6 +141,8 @@ export function getGenAiThinkingLevel(thinkingLevel: SupportedThinkingLevel<Goog
return GenAiThinkingLevel.MEDIUM;
case "high":
return GenAiThinkingLevel.HIGH;
case "xhigh":
return GenAiThinkingLevel.XHIGH;
case "dynamic":
case "off":
console.warn(
Expand Down
7 changes: 3 additions & 4 deletions src/adapters/google_genai/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export interface GoogleThinkingLevelSupport<T extends string> {
}

export interface GoogleModelSupportedThinkingLevelsMap {
"gemini-4-hydrogen": GoogleThinkingLevelSupport<"low" | "medium" | "high" | "xhigh">;
"gemini-4-carbon": GoogleThinkingLevelSupport<"low" | "medium" | "high">;
"gemini-4-argon": GoogleThinkingLevelSupport<"low" | "medium" | "high">;
"gemini-3.8-flash": GoogleThinkingLevelSupport<"low" | "medium" | "high">;
"gemini-3.7-flash": GoogleThinkingLevelSupport<"low" | "medium" | "high">;
"gemini-3.6-flash": GoogleThinkingLevelSupport<"minimal" | "low" | "medium" | "high">;
Expand All @@ -35,8 +38,4 @@ export interface GoogleModelSupportedThinkingLevelsMap {
"gemini-2.5-flash-lite": LegacyGoogleThinkingSupport;
"gemini-2.5-flash-lite-preview-09-2025": LegacyGoogleThinkingSupport;
"gemini-2.5-flash-native-audio-preview-12-2025": LegacyGoogleThinkingSupport;
"gemini-2.0-flash": UnsupportedGoogleThinkingSupport;
"gemini-2.0-flash-001": UnsupportedGoogleThinkingSupport;
"gemini-2.0-flash-lite": UnsupportedGoogleThinkingSupport;
"gemini-2.0-flash-lite-001": UnsupportedGoogleThinkingSupport;
}
Loading
Loading