diff --git a/src/renderer/src/hooks/useProvider.ts b/src/renderer/src/hooks/useProvider.ts index 9fac27da..3b474292 100644 --- a/src/renderer/src/hooks/useProvider.ts +++ b/src/renderer/src/hooks/useProvider.ts @@ -47,7 +47,7 @@ export function useProvider(id: string) { return { provider, - models: provider.models, + models: provider?.models || [], updateProvider: (provider: Provider) => dispatch(updateProvider(provider)), addModel: (model: Model) => dispatch(addModel({ providerId: id, model })), removeModel: (model: Model) => dispatch(removeModel({ providerId: id, model })) diff --git a/src/renderer/src/utils/index.ts b/src/renderer/src/utils/index.ts index 017cfcf9..1aa3f91b 100644 --- a/src/renderer/src/utils/index.ts +++ b/src/renderer/src/utils/index.ts @@ -94,7 +94,7 @@ export function droppableReorder(list: T[], startIndex: number, endIndex: num } export function firstLetter(str: string): string { - const match = str.match(/\p{L}\p{M}*|\p{Emoji_Presentation}|\p{Emoji}\uFE0F/u) + const match = str?.match(/\p{L}\p{M}*|\p{Emoji_Presentation}|\p{Emoji}\uFE0F/u) return match ? match[0] : '' }