diff --git a/gitbutler-ui/src/lib/backend/summarizer.ts b/gitbutler-ui/src/lib/backend/summarizer.ts index 2e66164ec..dab15d8f5 100644 --- a/gitbutler-ui/src/lib/backend/summarizer.ts +++ b/gitbutler-ui/src/lib/backend/summarizer.ts @@ -1,8 +1,8 @@ -import { getAnthropicKey, getAnthropicModel, getModelKind, getOpenAIKey, getOpenAIModel, getTokenOption, KeyOption, ModelKind } from './summarizer_settings'; +import { getAnthropicKey, getAnthropicModel, getModelKind, getOpenAIKey, getOpenAIModel, getKeyOption, KeyOption, ModelKind } from './summarizer_settings'; import { type AIProvider, ButlerAIProvider, - OpenAIProvider as AnthropicAIProvider, + AnthropicAIProvider, OpenAIProvider } from '$lib/backend/aiProviders'; import { getCloudApiClient, type User } from '$lib/backend/cloud'; @@ -99,9 +99,9 @@ interface SummarizerContext { // Secondly, if the user has opted to bring their own key but hasn't provided one, it will return undefined export async function buildSummarizer(context: SummarizerContext): Promise { const modelKind = await getModelKind(); - const tokenOption = await getTokenOption(); + const keyOption = await getKeyOption(); - if (tokenOption === KeyOption.ButlerAPI) { + if (keyOption === KeyOption.ButlerAPI) { if (!context.user) return; const aiProvider = new ButlerAIProvider(getCloudApiClient(), context.user, modelKind); diff --git a/gitbutler-ui/src/lib/backend/summarizer_settings.ts b/gitbutler-ui/src/lib/backend/summarizer_settings.ts index 839e4484a..62ebeeb42 100644 --- a/gitbutler-ui/src/lib/backend/summarizer_settings.ts +++ b/gitbutler-ui/src/lib/backend/summarizer_settings.ts @@ -42,12 +42,12 @@ export function setModelKind(modelKind: ModelKind) { const tokenOptionConfigKey = 'tokenOption'; -export async function getTokenOption(): Promise { +export async function getKeyOption(): Promise { const tokenKind = (await gitGetConfig(tokenOptionConfigKey)) as KeyOption | undefined; return tokenKind || KeyOption.ButlerAPI; } -export function setTokenOption(tokenOption: KeyOption) { +export function setKeyOption(tokenOption: KeyOption) { return gitSetConfig(tokenOptionConfigKey, tokenOption); } @@ -80,7 +80,7 @@ export async function getAnthropicKey(): Promise { return key || undefined; } -export function setAnthropicToken(token: string) { +export function setAnthropicKey(token: string) { return gitSetConfig(anthropicKeyConfigKey, token); } diff --git a/gitbutler-ui/src/lib/components/AISettings.svelte b/gitbutler-ui/src/lib/components/AISettings.svelte new file mode 100644 index 000000000..98127fa0d --- /dev/null +++ b/gitbutler-ui/src/lib/components/AISettings.svelte @@ -0,0 +1,125 @@ + + + + Model Kind + + GitButler supports OpenAI and Anthropic for various summerization tasks, either proxied via the GitButler servers or in a bring your own key configuration. + + + + + + + Key Configuration + + GitButler can either be configured to be proxied via the GitButler servers or to use your own key. + + + + + {#if keyOption?.value === KeyOption.BringYourOwn} + {#if modelKind?.value == ModelKind.Anthropic} + + + + {:else if modelKind?.value == ModelKind.OpenAI} + + + + {/if} + {/if} + diff --git a/gitbutler-ui/src/routes/settings/+page.svelte b/gitbutler-ui/src/routes/settings/+page.svelte index 470003294..2204343ee 100644 --- a/gitbutler-ui/src/routes/settings/+page.svelte +++ b/gitbutler-ui/src/routes/settings/+page.svelte @@ -25,6 +25,7 @@ import { getContext } from 'svelte'; import type { PageData } from './$types'; import { goto } from '$app/navigation'; + import AiSettings from '$lib/components/AISettings.svelte'; const userSettings = getContext(SETTINGS_CONTEXT) as SettingsStore; @@ -335,35 +336,7 @@ {:else if currentSection === 'ai'} - - AI Provider - - GitButler uses a a connection to its API to provide AI functionality, but supports - additional providers - - - -
- - -
-
+
{/if}