Skip to content

Commit 8215998

Browse files
committed
🐛 Fix response variable declaration to prevent potential runtime errors in AnthropicProvider
1 parent 4d2e271 commit 8215998

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

src/features/studio/components/StudioModelSelector.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313

1414
import { useState, useMemo, useCallback, useEffect } from 'react'
15+
import { useNavigate } from 'react-router-dom'
1516
import {
1617
Button,
1718
Dropdown,
@@ -24,14 +25,13 @@ import {
2425
} from '@heroui/react'
2526

2627
import { Icon } from '@/components/Icon'
27-
import { useAddLLMProviderModal } from '@/components/AddLLMProviderModal'
2828
import { useLLMModelStore } from '@/stores/llmModelStore'
2929
import { LLMService } from '@/lib/llm'
3030
import { CredentialService } from '@/lib/credential-service'
3131
import { inferLocalModelCapabilities } from '@/lib/llm/models'
3232
import { getModel as getModelFromModelsDev } from '@/lib/models-dev'
3333
import type { NormalizedModel } from '@/lib/models-dev/types'
34-
import { type Lang, useI18n } from '@/i18n'
34+
import { type Lang, useI18n, useUrl } from '@/i18n'
3535
import type { Credential } from '@/types'
3636
import type { IconName } from '@/lib/types'
3737

@@ -145,7 +145,8 @@ export function StudioModelSelector({
145145
onVideoModelChange,
146146
}: StudioModelSelectorProps) {
147147
const { t } = useI18n(localI18n)
148-
const openAddProviderModal = useAddLLMProviderModal((state) => state.open)
148+
const navigate = useNavigate()
149+
const url = useUrl()
149150
const credentials = useLLMModelStore((state) => state.credentials)
150151

151152
// View mode: 'providers' shows provider list, 'models' shows model list for a provider
@@ -417,7 +418,13 @@ export function StudioModelSelector({
417418
variant="flat"
418419
color="warning"
419420
className="min-w-0 px-2 h-8"
420-
onPress={openAddProviderModal}
421+
onPress={() =>
422+
navigate(
423+
url(
424+
`${location.pathname}${location.search}#settings/providers/add`,
425+
),
426+
)
427+
}
421428
startContent={<Icon name="Plus" size="sm" />}
422429
>
423430
<span className="text-xs">{t('Select model')}</span>
@@ -652,7 +659,13 @@ export function StudioModelSelector({
652659
key="add-provider"
653660
startContent={<Icon name="Plus" size="sm" />}
654661
textValue={t('Select model')}
655-
onPress={openAddProviderModal}
662+
onPress={() =>
663+
navigate(
664+
url(
665+
`${location.pathname}${location.search}#settings/providers/add`,
666+
),
667+
)
668+
}
656669
closeOnSelect
657670
>
658671
{t('Add provider')}

src/lib/llm/providers/anthropic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export class AnthropicProvider implements LLMProviderInterface {
238238
}
239239

240240
// Retry fetch up to 2 times on network failures (TypeError: Failed to fetch)
241-
let response: Response
241+
let response!: Response
242242
let lastError: Error | null = null
243243
for (let attempt = 0; attempt < 3; attempt++) {
244244
try {
@@ -433,7 +433,7 @@ export class AnthropicProvider implements LLMProviderInterface {
433433
}
434434

435435
// Retry fetch up to 2 times on network failures (TypeError: Failed to fetch)
436-
let response: Response
436+
let response!: Response
437437
let lastError: Error | null = null
438438
for (let attempt = 0; attempt < 3; attempt++) {
439439
try {

0 commit comments

Comments
 (0)