const base64File = await getFileAsBase64("src/testt.jpg");
console.log(base64File);
const filePart = {
inline_data: {
data: base64File,
mimeType: "image/jpeg",
},
};
const textPart = {
text: `
exampleeee
`,
};
const request = {
contents: [{ role: "user", parts: [textPart, filePart] }],
};
const resp = await generativeModel.generateContent(request); <----- type error
This is my file and the example is from the site. I dunno why it is causing
rgument of type '{ contents: { role: string; parts: ({ inline_data: { data: string; mimeType: string; }; } | { text: string; })[]; }[]; }' is not assignable to parameter of type 'string | GenerateContentRequest'.
where have I done wrong here?
In TypeScript, you can enforce the FileDataPart type as:
import { VertexAI, FileDataPart } from '@google-cloud/vertexai';
const filePart: FileDataPart = {
file_data: {
file_uri: fileUri,
mime_type: 'image/jpeg',
},
};
or InlineDataPart as:
import { VertexAI, InlineDataPart } from '@google-cloud/vertexai';
const filePart: InlineDataPart = {
inline_data: {
data: base64File,
mime_type: 'image/jpeg',
},
};