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 { myProvider } from '@/lib/ai/models';
|
||||||
import { createDocumentHandler } from '@/lib/blocks/server';
|
import { createDocumentHandler } from '@/lib/blocks/server';
|
||||||
import { saveDocument } from '@/lib/db/queries';
|
|
||||||
import { experimental_generateImage } from 'ai';
|
import { experimental_generateImage } from 'ai';
|
||||||
|
|
||||||
export const imageDocumentHandler = createDocumentHandler<'image'>({
|
export const imageDocumentHandler = createDocumentHandler<'image'>({
|
||||||
kind: 'image',
|
kind: 'image',
|
||||||
onCreateDocument: async ({ id, title, dataStream, session }) => {
|
onCreateDocument: async ({ title, dataStream }) => {
|
||||||
let draftContent = '';
|
let draftContent = '';
|
||||||
|
|
||||||
const { image } = await experimental_generateImage({
|
const { image } = await experimental_generateImage({
|
||||||
|
|
@ -21,23 +20,13 @@ export const imageDocumentHandler = createDocumentHandler<'image'>({
|
||||||
content: image.base64,
|
content: image.base64,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (session?.user?.id) {
|
|
||||||
await saveDocument({
|
|
||||||
id,
|
|
||||||
title,
|
|
||||||
kind: 'image',
|
|
||||||
content: draftContent,
|
|
||||||
userId: session.user.id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return draftContent;
|
return draftContent;
|
||||||
},
|
},
|
||||||
onUpdateDocument: async ({ description, dataStream }) => {
|
onUpdateDocument: async ({ description, dataStream }) => {
|
||||||
let draftContent = '';
|
let draftContent = '';
|
||||||
|
|
||||||
const { image } = await experimental_generateImage({
|
const { image } = await experimental_generateImage({
|
||||||
model: myProvider.imageModel('image-model'),
|
model: myProvider.imageModel('small-model'),
|
||||||
prompt: description,
|
prompt: description,
|
||||||
n: 1,
|
n: 1,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,6 @@ export function Chat({
|
||||||
mutate('/api/history');
|
mutate('/api/history');
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.log(error);
|
|
||||||
toast.error('An error occured, please try again!');
|
toast.error('An error occured, please try again!');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ function PureMessages({
|
||||||
ref={messagesContainerRef}
|
ref={messagesContainerRef}
|
||||||
className="flex flex-col min-w-0 gap-6 flex-1 overflow-y-scroll pt-4"
|
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) => (
|
{messages.map((message, index) => (
|
||||||
<PreviewMessage
|
<PreviewMessage
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ export const myProvider = customProvider({
|
||||||
'block-model': openai('gpt-4o-mini'),
|
'block-model': openai('gpt-4o-mini'),
|
||||||
},
|
},
|
||||||
imageModels: {
|
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