This commit introduces a new UI for managing models within the OpenAI integration. This UI allows users to view, add, and delete OpenAI models associated with their OpenAI providers. It includes functionality to fetch and refresh model lists, as well as to search for specific models. These changes enhance the user experience by offering greater control over their OpenAI model interactions. This commit also includes improvements to the existing OpenAI configuration UI, enabling users to seamlessly manage multiple OpenAI providers and associated models.
26 lines
414 B
TypeScript
26 lines
414 B
TypeScript
type Model = {
|
|
id: string
|
|
name?: string
|
|
}
|
|
|
|
export const getAllOpenAIModels = async (baseUrl: string, apiKey?: string) => {
|
|
const url = `${baseUrl}/models`
|
|
const headers = apiKey
|
|
? {
|
|
Authorization: `Bearer ${apiKey}`
|
|
}
|
|
: {}
|
|
|
|
const res = await fetch(url, {
|
|
headers
|
|
})
|
|
|
|
if (!res.ok) {
|
|
return []
|
|
}
|
|
|
|
const data = (await res.json()) as { data: Model[] }
|
|
|
|
return data.data
|
|
}
|