in src/pdf_summary/index.ts [73:102]
private async generate(data: string) {
this.generating = true;
try {
const response = await ai.models.generateContentStream({
model: 'gemini-2.0-flash-exp',
contents: {
role: 'USER',
parts: [
{
text: `can you summarize this PDF in ${this.numWords} words at the comprehension level of ${this.level}?`,
},
{
inlineData: {
mimeType: 'application/pdf',
data,
},
},
],
},
});
for await (const chunk of response) {
this.summarization += chunk.text;
this.markdown = unsafeHTML(marked.parse(this.summarization));
}
} catch (e) {
this.error = 'Something went wrong.';
}
this.generating = false;
}