Skip to content

Commit

Permalink
Anthropic: show model refresh button when missing key
Browse files Browse the repository at this point in the history
  • Loading branch information
enricoros committed Nov 6, 2023
1 parent 87f0bf1 commit a9d97b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/modules/llms/transports/server/anthropic.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ export function anthropicAccess(access: AnthropicAccessSchema, apiPath: string):

// API key
const anthropicKey = access.anthropicKey || process.env.ANTHROPIC_API_KEY || '';

// break for the missing key only on the default host
if (!anthropicKey)
throw new Error('Missing Anthropic API Key. Add it on the UI (Models Setup) or server side (your deployment).');
if (!access.anthropicHost && !process.env.ANTHROPIC_API_HOST)
throw new Error('Missing Anthropic API Key. Add it on the UI (Models Setup) or server side (your deployment).');

// API host
let anthropicHost = fixupHost(access.anthropicHost || process.env.ANTHROPIC_API_HOST || DEFAULT_ANTHROPIC_HOST, apiPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function AnthropicSourceSetup(props: { sourceId: DModelSourceId }) {
const needsUserKey = !ModelVendorAnthropic.hasServerKey;
const keyValid = isValidAnthropicApiKey(anthropicKey);
const keyError = (/*needsUserKey ||*/ !!anthropicKey) && !keyValid;
const shallFetchSucceed = anthropicKey ? keyValid : !needsUserKey;
const shallFetchSucceed = anthropicKey ? keyValid : (!needsUserKey || !!anthropicHost);

// fetch models
const { isFetching, refetch, isError, error } = apiQuery.llmAnthropic.listModels.useQuery({
Expand Down

1 comment on commit a9d97b9

@vercel
Copy link

@vercel vercel bot commented on a9d97b9 Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

big-agi – ./

big-agi-enricoros.vercel.app
get.big-agi.com
big-agi-git-main-enricoros.vercel.app

Please sign in to comment.