Template
Improve chat navigation, model selection, and streaming
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import type { UIMessage } from "ai";
|
||||
|
||||
type MessagePart = UIMessage["parts"][number];
|
||||
type ReasoningPart = Extract<MessagePart, { type: "reasoning" }>;
|
||||
|
||||
export function getTextContent(parts: MessagePart[]): string {
|
||||
return parts
|
||||
.filter((p) => p.type === "text")
|
||||
.map((p) => p.text || "")
|
||||
.join("");
|
||||
}
|
||||
|
||||
export function getReasoningPart(parts: MessagePart[]): ReasoningPart | undefined {
|
||||
return parts.find((p): p is ReasoningPart => p.type === "reasoning");
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
export const openRouterModels = [
|
||||
{ id: 'anthropic/claude-opus-5', name: 'Claude Opus 5' },
|
||||
{ id: 'anthropic/claude-opus-5-fast', name: 'Claude Opus 5 (Fast)' },
|
||||
{ id: 'anthropic/claude-sonnet-5', name: 'Claude Sonnet 5' },
|
||||
{ id: 'anthropic/claude-fable-5', name: 'Claude Fable 5' },
|
||||
{ id: 'openai/gpt-6-astra-pro', name: 'GPT-6 Astra Pro' },
|
||||
{ id: 'openai/gpt-5.6-luna', name: 'GPT-5.6 Luna' },
|
||||
{ id: 'openai/gpt-5.6-luna-pro', name: 'GPT-5.6 Luna Pro' },
|
||||
{ id: 'openai/gpt-5.6-sol', name: 'GPT-5.6 Sol' },
|
||||
{ id: 'openai/gpt-5.6-sol-pro', name: 'GPT-5.6 Sol Pro' },
|
||||
{ id: 'openai/gpt-5.6-terra', name: 'GPT-5.6 Terra' },
|
||||
{ id: 'openai/gpt-5.6-terra-pro', name: 'GPT-5.6 Terra Pro' },
|
||||
{ id: 'google/gemini-3.8-flash', name: 'Gemini 3.8 Flash' },
|
||||
{ id: 'x-ai/grok-4.6', name: 'Grok 4.6' },
|
||||
{ id: 'z-ai/glm-5.3', name: 'GLM 5.3' },
|
||||
{ id: 'moonshotai/kimi-k3', name: 'Kimi K3' },
|
||||
{ id: 'minimax/minimax-m3', name: 'MiniMax M3' },
|
||||
{ id: 'deepseek/deepseek-v4-pro', name: 'DeepSeek V4 Pro 0423' },
|
||||
{ id: 'deepseek/deepseek-v4-flash-0731', name: 'DeepSeek V4 Flash 0731' },
|
||||
{ id: 'meta/muse-spark-1.1', name: 'Muse Spark 1.1' },
|
||||
{ id: 'qwen/qwen3.8-max', name: 'Qwen3.8 Max' },
|
||||
] as const;
|
||||
|
||||
export type OpenRouterModelId = (typeof openRouterModels)[number]['id'];
|
||||
|
||||
export const DEFAULT_OPENROUTER_MODEL_ID: OpenRouterModelId = 'openai/gpt-5.6-luna-pro';
|
||||
|
||||
export function isOpenRouterModelId(value: unknown): value is OpenRouterModelId {
|
||||
return typeof value === 'string' && openRouterModels.some((model) => model.id === value);
|
||||
}
|
||||
Reference in New Issue
Block a user