feat: add model management UI

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.
This commit is contained in:
n4ze3m
2024-09-29 19:12:19 +05:30
parent e2e3655c47
commit 2a2610afb8
10 changed files with 729 additions and 161 deletions

25
src/libs/openai.ts Normal file
View File

@@ -0,0 +1,25 @@
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
}