feat: add OpenAI model support

Adds support for OpenAI models, allowing users to leverage various OpenAI models directly from the application. This includes custom OpenAI models and OpenAI-specific configurations for seamless integration.
This commit is contained in:
n4ze3m
2024-09-29 19:57:26 +05:30
parent 2a2610afb8
commit c8620637f8
9 changed files with 97 additions and 31 deletions

View File

@@ -18,6 +18,11 @@ export const generateID = () => {
export const removeModelPrefix = (id: string) => {
return id.replace(/^model-/, "")
}
export const isCustomModel = (model: string) => {
const customModelRegex = /_model-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{3,4}-[a-f0-9]{4}/
return customModelRegex.test(model)
}
export class ModelDb {
db: chrome.storage.StorageArea
@@ -174,3 +179,30 @@ export const isLookupExist = async (lookup: string) => {
const model = models.find((model) => model.lookup === lookup)
return model ? true : false
}
export const ollamaFormatAllCustomModels = async () => {
const allModles = await getAllCustomModels()
const ollamaModels = allModles.map((model) => {
return {
name: model.name,
model: model.id,
modified_at: "",
provider: "custom",
size: 0,
digest: "",
details: {
parent_model: "",
format: "",
family: "",
families: [],
parameter_size: "",
quantization_level: ""
}
}
})
return ollamaModels
}