-
Notifications
You must be signed in to change notification settings - Fork 661
feat: Add support for 1M token limit in conversation history calculations and update model options #828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Add support for 1M token limit in conversation history calculations and update model options #828
Conversation
…ions and update model options
|
@AshAnand34 is attempting to deploy a commit to the LangChain Team on Vercel. A member of the Team first needs to authorize it. |
|
I don't think it will work as you propose it. there is no model "claude-sonnet-4-1m" "anthropic-beta": "context-1m-2025-08-07", |
|
You also need to update the costs according. Prompts ≤ 200K | $3 / MTok | $15 / MTok |
| // }, | ||
| // { | ||
| // label: "Claude Opus 4 (Extended Thinking)", | ||
| // value: "anthropic:extended-thinking:claude-opus-4-0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#833 specifically creating the new model to do a function lookup instead of reliance on the static implementation
// Canonical metadata for all supported models
export type ModelFamily = "Anthropic Claude" | "OpenAI GPT" | "Google Gemini" | "DeepSeek" | "Qwen" | "Meta Llama" | "Grok" | "Other";
export interface ModelMetadata {
label: string;
modelName: string;
modelFamily: ModelFamily;
maxInternalTokens: number | undefined;
contextWindow: number;
notableFeatures?: string[];
costPerMillionTokens?: {
input: number;
output: number;
};
}
export const MODEL_METADATA: Record<string, ModelMetadata> = {
"anthropic:claude-sonnet-4-1m": {
label: "Claude Sonnet 4 (1M Context)",
modelName: "anthropic:claude-sonnet-4-1m",
modelFamily: "Anthropic Claude",
maxInternalTokens: 1_000_000,
contextWindow: 1_000_000,
notableFeatures: ["1M token context", "Best for long conversations"],
costPerMillionTokens: { input: 3.0, output: 15.0 },
},
"anthropic:claude-opus-4-1": {
label: "Claude Opus 4.1",
modelName: "anthropic:claude-opus-4-1",
modelFamily: "Anthropic Claude",
maxInternalTokens: 200_000,
contextWindow: 200_000,
notableFeatures: ["High accuracy", "Fast output"],
costPerMillionTokens: { input: 15.0, output: 75.0 },
},
"openai:gpt-4o": {
label: "GPT-4o",
modelName: "openai:gpt-4o",
modelFamily: "OpenAI GPT",
maxInternalTokens: 128_000,
contextWindow: 128_000,
notableFeatures: ["Multimodal", "Fast inference"],
costPerMillionTokens: { input: 2.5, output: 10.0 },
},
"google-genai:gemini-2.5-pro": {
label: "Gemini 2.5 Pro",
modelName: "google-genai:gemini-2.5-pro",
modelFamily: "Google Gemini",
maxInternalTokens: undefined,
contextWindow: 1_048_576,
notableFeatures: ["Multimodal", "1M token context window", "Integrated with Google products"],
costPerMillionTokens: { input: 2.5, output: 15.0 },
},
"deepseek:v3.1": {
label: "DeepSeek V3.1",
modelName: "deepseek:v3.1",
modelFamily: "DeepSeek",
maxInternalTokens: 671_000_000,
contextWindow: 128_000,
notableFeatures: ["High-performance MoE", "Specialized in coding and reasoning"],
costPerMillionTokens: { input: 0.14, output: 0.28 },
},
"qwen:3-1m": {
label: "Qwen 3 (1M Context)",
modelName: "qwen:3-1m",
modelFamily: "Qwen",
maxInternalTokens: 1_000_000,
contextWindow: 1_000_000,
notableFeatures: ["Ultra-long context", "Multilingual", "MoE architecture"],
costPerMillionTokens: { input: 0.20, output: 0.60 },
},
"meta:llama-4-scout": {
label: "Llama 4 Scout",
modelName: "meta:llama-4-scout",
modelFamily: "Meta Llama",
maxInternalTokens: 109_000_000_000,
contextWindow: 10_000_000,
notableFeatures: ["10M context window", "Multimodal (text, image, video)", "Open-weight"],
costPerMillionTokens: { input: 0.11, output: 0.34 },
},
"grok:4": {
label: "Grok 4",
modelName: "grok:4",
modelFamily: "Grok",
maxInternalTokens: undefined,
contextWindow: 256_000,
notableFeatures: ["Multimodal", "Real-time web searches", "Advanced reasoning"],
costPerMillionTokens: { input: 3.0, output: 15.0 },
},
// Add other models here
};
// Utility to get model attributes
export function getMaxInternalTokensForModel(modelName: string): number {
const model = MODEL_METADATA[modelName];
if (!model) {
throw new Error(`Unknown model: ${modelName}`);
}
return model.maxInternalTokens ?? model.contextWindow;
}
export function getModelMetadata(modelName: string): ModelMetadata {
const model = MODEL_METADATA[modelName];
if (!model) {
throw new Error(`Unknown model: ${modelName}`);
}
return model;
}
Resolves Issue #826 (1M token support for claude sonnet)