Skip to content

Commit

Permalink
Merge pull request #226 from in-c0/main
Browse files Browse the repository at this point in the history
Fix to TypeError: Cannot read properties of undefined (reading 'config') (setting 'apiKey')
  • Loading branch information
givebest authored Oct 14, 2024
2 parents bd9e870 + 6ec8707 commit 0b3f77f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ export async function getProviderConfigs(): Promise<ProviderConfigs> {
const randomIndex = configKeys.length > 0 ? Math.floor(Math.random() * configKeys.length) : 0;
const apiKey = configKeys[randomIndex] ?? ''
result[configKey].apiKey = apiKey
if (!result[configKey]) {
result[configKey] = {}
}
result[configKey].apiKey = apiKey

return {
provider,
configs: {
Expand Down
9 changes: 9 additions & 0 deletions src/options/ProviderSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ function ProviderSelect() {
if (query.isLoading) {
return <Spinner />
}

if (query.error) {
return <div>Error loading provider configurations.</div>
}

if (!query.data || !query.data.config) {
return <div>No provider configurations found.</div>
}

return <ConfigPanel config={query.data!.config} models={models} />
}

Expand Down

0 comments on commit 0b3f77f

Please sign in to comment.