Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added DALL-E models and gpt-4-1106-preview #341

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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