diff --git a/README.md b/README.md index b3ad2af..6a38e6c 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ Alle Werte sind in den Raycast-Einstellungen pro Extension einstellbar. - `Ausgabe der Schnellbefehle` — `In die Zwischenablage kopieren` (Default) oder `Am Cursor einfügen` - `Eigener Name` — Default-Signatur für AI-generierte Email-Antworten, im Antwort-Befehl pro Aufruf überschreibbar -Das KI-Modell ist keine Preference: jeder AI-Befehl zeigt ein `KI-Modell`-Dropdown mit dem aktuellen Modell-Katalog aus `src/ai.ts`. Die Auswahl wird in `LocalStorage` (`velum.ai.last-model`) persistiert und ist beim nächsten Aufruf in jedem AI-Befehl vorausgewählt. +Jeder KI-Befehl bezieht die Auswahl im Feld **KI-Modell** aus `AI.Model` der installierten Raycast-Version. Mit **Raycast-Standard** verwendet Velum das Standardmodell der Raycast-API. Velum merkt sich die letzte Auswahl für alle KI-Befehle. Fehlt das gespeicherte Modell im API-Katalog, ist beim nächsten Aufruf **Raycast-Standard** ausgewählt. - `Maximale Anzahl gespeicherter Sitzungen` — älteste werden geprunt (Default 20) - `Raycast nach Kopieren/Einfügen schließen` — Auto-Close und Pop-To-Root nach AI-Workflow-Abschluss (Default an) diff --git a/src/ai-views.tsx b/src/ai-views.tsx index b3902a2..90596b2 100644 --- a/src/ai-views.tsx +++ b/src/ai-views.tsx @@ -15,7 +15,7 @@ import { } from "@raycast/api"; import { marked } from "marked"; import { type ReactNode, useEffect, useRef, useState } from "react"; -import type { Creativity } from "./ai"; +import { resolveRaycastModel, type Creativity } from "./ai"; import { getPreferences } from "./preferences"; import type { VelumSession } from "./types"; import { markdownCodeBlock, mappingDetailTable, sessionSubtitle } from "./ui"; @@ -143,7 +143,7 @@ export function AiStreamResult(props: PseudoStageProps) { try { const prompt = buildPrompt(pseudonymizedText, instructions); const stream = AI.ask(prompt, { - model: model as AI.Model, + model: resolveRaycastModel(model), creativity, signal: controller.signal, }); diff --git a/src/ai.ts b/src/ai.ts index 64f63bd..01bc0f6 100644 --- a/src/ai.ts +++ b/src/ai.ts @@ -1,4 +1,4 @@ -import { LocalStorage } from "@raycast/api"; +import { AI, LocalStorage } from "@raycast/api"; export type Creativity = "none" | "low" | "medium" | "high"; @@ -9,86 +9,29 @@ export const CREATIVITY_OPTIONS: Creativity[] = [ "high", ]; -export type ModelOption = { value: string; title: string }; - -export const MODEL_OPTIONS: ModelOption[] = [ - { value: "anthropic-claude-opus-4-7", title: "Claude 4.7 Opus" }, - { value: "anthropic-claude-sonnet-4-6", title: "Claude 4.6 Sonnet" }, - { value: "anthropic-claude-opus-4-6", title: "Claude 4.6 Opus" }, - { value: "anthropic-claude-sonnet-4-5", title: "Claude 4.5 Sonnet" }, - { value: "anthropic-claude-opus-4-5", title: "Claude 4.5 Opus" }, - { value: "anthropic-claude-4-5-haiku", title: "Claude 4.5 Haiku" }, - { value: "anthropic-claude-sonnet-4", title: "Claude 4 Sonnet" }, - { value: "openai-gpt-5.4", title: "OpenAI GPT-5.4" }, - { value: "openai-gpt-5.4-mini", title: "OpenAI GPT-5.4 Mini" }, - { value: "openai-gpt-5.4-nano", title: "OpenAI GPT-5.4 Nano" }, - { value: "openai-gpt-5.3-instant", title: "OpenAI GPT-5.3 Instant" }, - { value: "openai-gpt-5.3-codex", title: "OpenAI GPT-5.3 Codex" }, - { value: "openai-gpt-5.2", title: "OpenAI GPT-5.2" }, - { value: "openai-gpt-5.2-instant", title: "OpenAI GPT-5.2 Instant" }, - { value: "openai-gpt-5.1", title: "OpenAI GPT-5.1" }, - { value: "openai-gpt-5.1-instant", title: "OpenAI GPT-5.1 Instant" }, - { value: "openai-gpt-5.1-codex", title: "OpenAI GPT-5.1 Codex" }, - { value: "openai_o1-gpt-5", title: "OpenAI GPT-5" }, - { value: "openai-gpt-5-mini", title: "OpenAI GPT-5 Mini" }, - { value: "openai-gpt-5-nano", title: "OpenAI GPT-5 Nano" }, - { value: "openai-gpt-4.1", title: "OpenAI GPT-4.1" }, - { value: "openai-gpt-4.1-mini", title: "OpenAI GPT-4.1 Mini" }, - { value: "openai-gpt-4.1-nano", title: "OpenAI GPT-4.1 Nano" }, - { value: "openai-gpt-4o", title: "OpenAI GPT-4o" }, - { value: "openai-gpt-4o-mini", title: "OpenAI GPT-4o mini" }, - { value: "openai_o1-o3", title: "OpenAI o3" }, - { value: "openai_o1-o3-mini", title: "OpenAI o3-mini" }, - { value: "openai_o1-o4-mini", title: "OpenAI o4-mini" }, - { value: "openai_o1-o1", title: "OpenAI o1" }, - { value: "google-gemini-3.1-pro", title: "Google Gemini 3.1 Pro" }, - { value: "google-gemini-3-flash", title: "Google Gemini 3 Flash" }, - { - value: "google-gemini-3.1-flash-lite", - title: "Google Gemini 3.1 Flash Lite", - }, - { value: "google-gemini-2.5-pro", title: "Google Gemini 2.5 Pro" }, - { value: "google-gemini-2.5-flash", title: "Google Gemini 2.5 Flash" }, - { - value: "google-gemini-2.5-flash-lite", - title: "Google Gemini 2.5 Flash Lite", - }, - { value: "xai-grok-4.20", title: "xAI Grok 4.20" }, - { value: "xai-grok-4", title: "xAI Grok 4" }, - { value: "xai-grok-4-fast", title: "xAI Grok 4 Fast" }, - { value: "xai-grok-4-1-fast", title: "xAI Grok 4.1 Fast" }, - { value: "xai-grok-code-fast", title: "xAI Grok Code Fast" }, - { value: "perplexity-sonar-pro", title: "Perplexity Sonar Pro" }, - { value: "perplexity-sonar", title: "Perplexity Sonar" }, - { value: "mistral-mistral-large-latest", title: "Mistral Large" }, - { value: "mistral-mistral-medium-latest", title: "Mistral Medium" }, - { value: "mistral-mistral-small-latest", title: "Mistral Small" }, - { value: "mistral-codestral-latest", title: "Mistral Codestral" }, - { value: "mistral-open-mistral-nemo", title: "Mistral Nemo" }, - { value: "groq-llama-3.3-70b-versatile", title: "Groq Llama 3.3 70B" }, - { - value: "groq-meta-llama/llama-4-scout-17b-16e-instruct", - title: "Groq Llama 4 Scout", - }, - { value: "groq-llama-3.1-8b-instant", title: "Groq Llama 3.1 8B" }, - { value: "groq-qwen/qwen3-32b", title: "Groq Qwen3 32B" }, - { value: "groq-openai/gpt-oss-120b", title: "Groq GPT-OSS 120B" }, - { value: "groq-openai/gpt-oss-20b", title: "Groq GPT-OSS 20B" }, - { value: "together-deepseek-ai/DeepSeek-R1", title: "DeepSeek R1" }, - { value: "together-deepseek-ai/DeepSeek-V3", title: "DeepSeek V3" }, - { value: "together-moonshotai/Kimi-K2.5", title: "Kimi K2.5" }, -]; - +export const DEFAULT_MODEL = "__raycast_default__"; const LAST_MODEL_STORAGE_KEY = "velum.ai.last-model"; -export const DEFAULT_MODEL: string = MODEL_OPTIONS[0].value; +// Raycast lists current names before compatibility aliases for the same model ID. +const raycastModels = new Map(); +for (const [name, value] of Object.entries(AI.Model)) { + if (!raycastModels.has(value)) { + raycastModels.set(value, { value, title: name.replaceAll("_", " ") }); + } +} + +export const MODEL_OPTIONS = [ + { value: DEFAULT_MODEL, title: "Raycast-Standard" }, + ...raycastModels.values(), +]; + +export function resolveRaycastModel(selection: string): AI.Model | undefined { + return raycastModels.get(selection)?.value; +} export async function getLastUsedModel(): Promise { const stored = await LocalStorage.getItem(LAST_MODEL_STORAGE_KEY); - if (stored && MODEL_OPTIONS.some((option) => option.value === stored)) { - return stored; - } - return DEFAULT_MODEL; + return stored && raycastModels.has(stored) ? stored : DEFAULT_MODEL; } export async function setLastUsedModel(model: string): Promise { diff --git a/src/reply-email.tsx b/src/reply-email.tsx index 130d74f..e501dc2 100644 --- a/src/reply-email.tsx +++ b/src/reply-email.tsx @@ -20,6 +20,7 @@ import { DEFAULT_MODEL, getLastUsedModel, MODEL_OPTIONS, + resolveRaycastModel, setLastUsedModel, } from "./ai"; import { getPreferences } from "./preferences"; @@ -560,7 +561,7 @@ function ReplyResult(props: StageProps) { instructions: props.instructions, }); const stream = AI.ask(prompt, { - model: props.model as AI.Model, + model: resolveRaycastModel(props.model), creativity: props.creativity, signal: controller.signal, }); diff --git a/src/summarize-email.tsx b/src/summarize-email.tsx index f62caaa..864fd45 100644 --- a/src/summarize-email.tsx +++ b/src/summarize-email.tsx @@ -27,6 +27,7 @@ import { DEFAULT_MODEL, getLastUsedModel, MODEL_OPTIONS, + resolveRaycastModel, setLastUsedModel, } from "./ai"; import { buildSummaryPrompt, type Creativity } from "./summarize"; @@ -354,7 +355,7 @@ function SummarizeEmailResult({ try { const prompt = buildSummaryPrompt(pseudonymizedText, instructions); const stream = AI.ask(prompt, { - model: model as AI.Model, + model: resolveRaycastModel(model), creativity, signal: controller.signal, }); diff --git a/src/summarize.ts b/src/summarize.ts index 4cf6f42..f069c20 100644 --- a/src/summarize.ts +++ b/src/summarize.ts @@ -1,4 +1,5 @@ import { AI } from "@raycast/api"; +import { resolveRaycastModel } from "./ai"; export type Creativity = "none" | "low" | "medium" | "high"; @@ -54,7 +55,7 @@ export async function runSummaryStream( ): Promise { let buffer = ""; const stream = AI.ask(options.prompt, { - model: options.model as AI.Model, + model: resolveRaycastModel(options.model), creativity: options.creativity, signal: options.signal, });