Skip to content

Commit

Permalink
Merge pull request #341 from MitchBoss/main
Browse files Browse the repository at this point in the history
Added DALL-E models and gpt-4-1106-preview
  • Loading branch information
Niek authored Nov 7, 2023
2 parents 445ae05 + ccb46b5 commit eb4c746
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
64 changes: 64 additions & 0 deletions src/lib/providers/openai/models.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ const gpt432k = {
completion: 0.00012, // $0.12 per 1000 tokens completion
max: 32768 // 32k max token buffer
}
const gpt4120kpreview = {
...chatModelBase,
prompt: 0.00003, // $0.03 per 1000 tokens prompt
completion: 0.00006, // $0.06 per 1000 tokens completion
max: 128000 // 128k max token buffer
}
export const chatModels : Record<string, ModelDetail> = {
'gpt-3.5-turbo': { ...gpt35 },
Expand All @@ -90,6 +96,7 @@ export const chatModels : Record<string, ModelDetail> = {
'gpt-4': { ...gpt4 },
'gpt-4-0314': { ...gpt4 },
'gpt-4-0613': { ...gpt4 },
'gpt-4-1106-preview': { ...gpt4120kpreview },
'gpt-4-32k': { ...gpt432k },
'gpt-4-32k-0314': { ...gpt432k },
'gpt-4-32k-0613': { ...gpt432k }
Expand Down Expand Up @@ -128,6 +135,63 @@ export const imageModels : Record<string, ModelDetail> = {
opt: {
size: '256x256'
}
},
'dall-e-3-1024x1024': {
...imageModelBase,
type: 'image',
completion: 0.04, // $0.040 per image
opt: {
model: 'dall-e-3',
size: '1024x1024'
}
},
'dall-e-3-1024x1792-Portrait': {
...imageModelBase,
type: 'image',
completion: 0.08, // $0.080 per image
opt: {
model: 'dall-e-3',
size: '1024x1792'
}
},
'dall-e-3-1792x1024-Landscape': {
...imageModelBase,
type: 'image',
completion: 0.08, // $0.080 per image
opt: {
model: 'dall-e-3',
size: '1792x1024'
}
},
'dall-e-3-1024x1024-HD': {
...imageModelBase,
type: 'image',
completion: 0.08, // $0.080 per image
opt: {
model: 'dall-e-3',
size: '1024x1024',
quality: 'hd'
}
},
'dall-e-3-1024x1792-Portrait-HD': {
...imageModelBase,
type: 'image',
completion: 0.12, // $0.080 per image
opt: {
model: 'dall-e-3',
size: '1024x1792',
quality: 'hd'
}
},
'dall-e-3-1792x1024-Landscape-HD': {
...imageModelBase,
type: 'image',
completion: 0.12, // $0.080 per image
opt: {
model: 'dall-e-3',
size: '1792x1024',
quality: 'hd'
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/lib/providers/openai/request.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ type RequestImageGeneration = {
n?: number;
size?: string;
response_format?: keyof ResponseImageDetail;
model?: string;
quality?: string;
style?: string;
}
export const imageRequest = async (
Expand All @@ -118,11 +121,17 @@ export const imageRequest = async (
const imageModel = chatSettings.imageGenerationModel
const imageModelDetail = getModelDetail(imageModel)
const size = imageModelDetail.opt?.size || '256x256'
const model = imageModelDetail.opt?.model
const style = imageModelDetail.opt?.style
const quality = imageModelDetail.opt?.quality
const request: RequestImageGeneration = {
prompt,
response_format: 'b64_json',
size,
n: count
n: count,
...(model ? { model } : {}),
...(style ? { style } : {}),
...(quality ? { quality } : {})
}
// fetchEventSource doesn't seem to throw on abort,
// so we deal with it ourselves
Expand Down

0 comments on commit eb4c746

Please sign in to comment.