fix: use correct image model id (#761)
This commit is contained in:
parent
cf4ab9a4a7
commit
5e059844a2
4 changed files with 5 additions and 16 deletions
|
|
@ -1,11 +1,10 @@
|
|||
import { myProvider } from '@/lib/ai/models';
|
||||
import { createDocumentHandler } from '@/lib/blocks/server';
|
||||
import { saveDocument } from '@/lib/db/queries';
|
||||
import { experimental_generateImage } from 'ai';
|
||||
|
||||
export const imageDocumentHandler = createDocumentHandler<'image'>({
|
||||
kind: 'image',
|
||||
onCreateDocument: async ({ id, title, dataStream, session }) => {
|
||||
onCreateDocument: async ({ title, dataStream }) => {
|
||||
let draftContent = '';
|
||||
|
||||
const { image } = await experimental_generateImage({
|
||||
|
|
@ -21,23 +20,13 @@ export const imageDocumentHandler = createDocumentHandler<'image'>({
|
|||
content: image.base64,
|
||||
});
|
||||
|
||||
if (session?.user?.id) {
|
||||
await saveDocument({
|
||||
id,
|
||||
title,
|
||||
kind: 'image',
|
||||
content: draftContent,
|
||||
userId: session.user.id,
|
||||
});
|
||||
}
|
||||
|
||||
return draftContent;
|
||||
},
|
||||
onUpdateDocument: async ({ description, dataStream }) => {
|
||||
let draftContent = '';
|
||||
|
||||
const { image } = await experimental_generateImage({
|
||||
model: myProvider.imageModel('image-model'),
|
||||
model: myProvider.imageModel('small-model'),
|
||||
prompt: description,
|
||||
n: 1,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ export function Chat({
|
|||
mutate('/api/history');
|
||||
},
|
||||
onError: (error) => {
|
||||
console.log(error);
|
||||
toast.error('An error occured, please try again!');
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ function PureMessages({
|
|||
ref={messagesContainerRef}
|
||||
className="flex flex-col min-w-0 gap-6 flex-1 overflow-y-scroll pt-4"
|
||||
>
|
||||
{/* {messages.length === 0 && <Overview />} */}
|
||||
{messages.length === 0 && <Overview />}
|
||||
|
||||
{messages.map((message, index) => (
|
||||
<PreviewMessage
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ export const myProvider = customProvider({
|
|||
'block-model': openai('gpt-4o-mini'),
|
||||
},
|
||||
imageModels: {
|
||||
'small-model': openai.image('dall-e-3'),
|
||||
'small-model': openai.image('dall-e-2'),
|
||||
'large-model': openai.image('dall-e-3'),
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue