Fix isAnyProvider and don't make it a hard block (#93)

This commit is contained in:
Will Chen
2025-05-06 12:13:03 -07:00
committed by GitHub
parent 7c0ce1d45b
commit 390496f8f8
4 changed files with 17 additions and 13 deletions

View File

@@ -349,10 +349,7 @@ export function ChatInput({ chatId }: { chatId?: number }) {
) : (
<button
onClick={handleSubmit}
disabled={
(!inputValue.trim() && attachments.length === 0) ||
!isAnyProviderSetup()
}
disabled={!inputValue.trim() && attachments.length === 0}
className="px-2 py-2 mt-1 mr-2 hover:bg-(--background-darkest) text-(--sidebar-accent-fg) rounded-lg disabled:opacity-50"
>
<SendIcon size={20} />

View File

@@ -131,6 +131,7 @@ export const PROVIDER_TO_ENV_VAR: Record<string, string> = {
openai: "OPENAI_API_KEY",
anthropic: "ANTHROPIC_API_KEY",
google: "GEMINI_API_KEY",
openrouter: "OPENROUTER_API_KEY",
};
export const ALLOWED_ENV_VARS = Object.keys(PROVIDER_TO_ENV_VAR).map(

View File

@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from "react";
import { atom, useAtom } from "jotai";
import { userSettingsAtom, envVarsAtom } from "@/atoms/appAtoms";
import { IpcClient } from "@/ipc/ipc_client";
import type { UserSettings } from "@/lib/schemas";
import { cloudProviders, type UserSettings } from "@/lib/schemas";
import { usePostHog } from "posthog-js/react";
const PROVIDER_TO_ENV_VAR: Record<string, string> = {
@@ -103,9 +103,10 @@ export function useSettings() {
updateSettings,
isProviderSetup,
isAnyProviderSetup: () => {
return Object.keys(PROVIDER_TO_ENV_VAR).some((provider) =>
isProviderSetup(provider)
);
// Technically we should check for ollama and lmstudio being setup, but
// practically most users will want to use a cloud provider (at least
// some of the time)
return cloudProviders.some((provider) => isProviderSetup(provider));
},
refreshSettings: () => {
return loadInitialData();

View File

@@ -26,10 +26,7 @@ export type ChatSummary = z.infer<typeof ChatSummarySchema>;
*/
export const ChatSummariesSchema = z.array(ChatSummarySchema);
/**
* Zod schema for model provider
*/
export const ModelProviderSchema = z.enum([
const providers = [
"openai",
"anthropic",
"google",
@@ -37,7 +34,15 @@ export const ModelProviderSchema = z.enum([
"openrouter",
"ollama",
"lmstudio",
]);
] as const;
/**
* Zod schema for model provider
*/
export const ModelProviderSchema = z.enum(providers);
export const cloudProviders = providers.filter(
(provider) => provider !== "ollama" && provider !== "lmstudio"
);
/**
* Type derived from the ModelProviderSchema