Add OpenAI-compatible assistant provider

This commit is contained in:
reidellawfirm committed 2026-10-31 16:01:25 -05:00
1 parent a5eda29368
commit 77e8a86196
19 files changed
+807 -23

No files matched your search

+38 -2
View File
@@ -18,6 +18,7 @@ import {
} from "~/assistant/models";
import { isLocalModelReady } from "../native/llama";
import { normalizeWhisperServerUrl } from "../native/whisper-server-stt";
import { normalizeOpenAiCompatibleUrl } from "../native/openai-chat";
import { isValidSpotifyClientId, SPOTIFY_CLIENT_ID_KEY } from "../native/spotify-auth";
import { drawRightValueMenuItem, drawToggleMenuItem, MenuItem, openModalMenu } from "./menu";
import { ANIMATION_SPEEDS, animationSpeedLabel, scaleAnimationDuration, type AnimationSpeed } from "./animation-speed";
@@ -942,7 +943,7 @@ export const assistantBackendSetting = new ConfigSettingEnum<AssistantBackendKin
values: global.isIOS ? ["direct"] : ["direct", "external"],
formatValue: (value) => assistantBackendLabels[value] ?? value,
description:
global.isIOS ? "Cloud models called with your OpenAI or Anthropic API key. Add your key in Settings > API Keys." : "Who answers assistant queries: an LLM called from the phone (a cloud API with your key, or the downloaded on-phone model), or your own long-running agent (e.g. OpenClaw) reached through the faceclaw-agent-bridge plugin.",
global.isIOS ? "Cloud models called through OpenAI, Anthropic, or your configured OpenAI-compatible API." : "Who answers assistant queries: an LLM called from the phone (a cloud API with your key, or the downloaded on-phone model), or your own long-running agent (e.g. OpenClaw) reached through the faceclaw-agent-bridge plugin.",
});
export const assistantHermesUrlSetting = new ConfigSettingString({
@@ -1008,6 +1009,40 @@ export const assistantAllowProactiveSetting = new ConfigSettingBoolean({
"Let the external agent use glasses tools outside of a conversation, e.g. showing an alert when a long-running job finishes. Rate-limited; only tools marked proactive-safe are allowed.",
});
export const assistantOpenAiCompatibleUrlSetting = new ConfigSettingString({
id: "assistant-openai-compatible-url",
label: "Compatible API URL",
storageKey: "assistant.openAiCompatibleUrl",
defaultValue: "",
editorTitle: "OpenAI-compatible API root",
glassesEditTitle: "Edit compatible API URL",
formatValue: (value) => value || "(not set)",
validate: (value) => (!value.trim() || normalizeOpenAiCompatibleUrl(value) ? null : "Enter an http:// or https:// API root."),
description: "Explicit API root for the OpenAI-compatible Chat Completions assistant. Venice: https://api.venice.ai/api/v1. Open WebUI: https://your-host/api. The provider's path is not guessed.",
});
export const assistantOpenAiCompatibleKeySetting = new ConfigSettingString({
id: "assistant-openai-compatible-key",
label: "Compatible API key",
storageKey: "assistant.openAiCompatibleKey",
defaultValue: "",
editorTitle: "OpenAI-compatible API key (optional)",
glassesEditTitle: "Edit compatible API key",
formatValue: (value) => (value ? `${value.slice(0, 6)}...` : "(none)"),
description: "Bearer key sent only to the compatible assistant URL above. Optional for private servers that do not require authentication.",
});
export const assistantOpenAiCompatibleModelSetting = new ConfigSettingString({
id: "assistant-openai-compatible-model",
label: "Compatible model ID",
storageKey: "assistant.openAiCompatibleModel",
defaultValue: "",
editorTitle: "OpenAI-compatible model ID",
glassesEditTitle: "Edit compatible model ID",
formatValue: (value) => value || "(not set)",
description: "Exact model ID sent to the compatible provider. For glasses tools, choose a model that supports function calling.",
});
export const elevenLabsApiKeySetting = new ConfigSettingString({
id: "elevenlabs-api-key",
label: "ElevenLabs key",
@@ -1112,11 +1147,12 @@ export const assistantModelSetting = new ConfigSettingEnum<AssistantModel>({
if (provider === "anthropic") return anthropicApiKeySetting.get().trim().length === 0;
if (provider === "openai") return openAiApiKeySetting.get().trim().length === 0;
if (provider === "local") return !isLocalModelReady();
if (provider === "openai-compatible") return !assistantOpenAiCompatibleUrlSetting.get().trim() || !assistantOpenAiCompatibleModelSetting.get().trim();
if (provider === "hermes") return assistantHermesUrlSetting.get().trim().length === 0;
return false;
},
description:
global.isIOS ? "Model used by the voice assistant. Auto prefers Terra with an OpenAI key, then Sonnet with an Anthropic key." : "Model used by the voice assistant. Auto prefers Terra when an OpenAI key is set, then Sonnet when an Anthropic key is set, then the downloaded on-phone model.",
global.isIOS ? "Model used by the assistant. OpenAI-compatible uses the URL, model ID, and optional key below. Auto only considers the built-in providers." : "Model used by the assistant. OpenAI-compatible uses the URL, model ID, and optional key below. Auto only considers the built-in providers.",
});
export const mapboxApiKeySetting = new ConfigSettingString({
+6
View File
@@ -42,6 +42,9 @@ import {
assistantBridgePortSetting,
assistantBridgeTokenSetting,
assistantModelSetting,
assistantOpenAiCompatibleKeySetting,
assistantOpenAiCompatibleModelSetting,
assistantOpenAiCompatibleUrlSetting,
assistantSkipConfirmationSetting,
batteryDisplayModeSetting,
brightnessSetting,
@@ -148,6 +151,9 @@ function settingsSections(): SettingsSection[] {
enumSettingMenuItem(assistantModelSetting),
textSettingMenuItem(assistantHermesUrlSetting),
textSettingMenuItem(assistantHermesKeySetting),
textSettingMenuItem(assistantOpenAiCompatibleUrlSetting),
textSettingMenuItem(assistantOpenAiCompatibleModelSetting),
textSettingMenuItem(assistantOpenAiCompatibleKeySetting),
...(!global.isIOS ? [localModelMenuItem()] : []),
toggleSettingMenuItem(assistantSkipConfirmationSetting),
// iOS has no local LLM or agent bridge yet.
+7 -1
View File
@@ -38,6 +38,9 @@ import {
assistantBridgePortSetting,
assistantBridgeTokenSetting,
assistantModelSetting,
assistantOpenAiCompatibleKeySetting,
assistantOpenAiCompatibleModelSetting,
assistantOpenAiCompatibleUrlSetting,
assistantSkipConfirmationSetting,
batteryIndicatorSettingsKey,
brightnessSetting,
@@ -1720,6 +1723,9 @@ class Shell {
openai: openAiApiKeySetting.get(),
hermesUrl: assistantHermesUrlSetting.get(),
hermesKey: assistantHermesKeySetting.get(),
openAiCompatibleUrl: assistantOpenAiCompatibleUrlSetting.get(),
openAiCompatibleKey: assistantOpenAiCompatibleKeySetting.get(),
openAiCompatibleModel: assistantOpenAiCompatibleModelSetting.get(),
});
if (llm && reasoning !== "default" && llm.effort) llm.effort = reasoning;
return llm ? { kind: "direct", llm } : null;
@@ -1749,7 +1755,7 @@ class Shell {
this.showAlert(
assistantBackendSetting.get() === "external"
? "Configure the agent bridge host and token in Settings."
: global.isIOS ? "Set an OpenAI or Anthropic API key in Settings." : "Set an API key or download the on-phone model in Settings.",
: global.isIOS ? "Configure an assistant model in Settings." : "Set an API key or download the on-phone model in Settings.",
);
return;
}