fix(api.ts): add null return if provider apiKey is missing to prevent unauthorized requests
This commit is contained in:
parent
bb9b053924
commit
b91b0dd8e4
@ -66,8 +66,18 @@ export async function fetchChatCompletion({
|
||||
export async function fetchMessagesSummary({ messages, assistant }: { messages: Message[]; assistant: Assistant }) {
|
||||
const model = getTopNamingModel() || assistant.model || getDefaultModel()
|
||||
const provider = getProviderByModel(model)
|
||||
|
||||
if (!provider.apiKey) {
|
||||
return null
|
||||
}
|
||||
|
||||
const providerSdk = new ProviderSDK(provider)
|
||||
return providerSdk.summaries(messages, assistant)
|
||||
|
||||
try {
|
||||
return await providerSdk.summaries(messages, assistant)
|
||||
} catch (error: any) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export async function checkApi(provider: Provider) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user