Skip to content

Commit

Permalink
Project import generated by Copybara. (#13)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: d69d5f3d0391408859deeefcb268a1a00a265e38
  • Loading branch information
gradient-ai-bot authored Mar 5, 2024
1 parent 7795f14 commit 1d2c9ad
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Binary file added resources/Lorem_Ipsum.pdf
Binary file not shown.
24 changes: 21 additions & 3 deletions src/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const runSummarizeExample = async ({

console.log("Summarizing document...");
const resultWithLength = await gradient.summarize({
document: document,
document,
length: "long",
});
console.log(`Summary: ${resultWithLength.summary}`);
Expand Down Expand Up @@ -127,7 +127,7 @@ const runAnalyzeSentimentExample = async ({

console.log("Analyzing sentiment...");
const { sentiment } = await gradient.analyzeSentiment({
document: document,
document,
examples,
});
console.log(`Sentiment: ${sentiment}`);
Expand Down Expand Up @@ -192,13 +192,30 @@ const runExtractExample = async ({

console.log("Extracting entity from document...");
const { entity } = await gradient.extract({
document: document,
document,
schema,
});
console.log(`Entity: ${JSON.stringify(entity, null, 2)}`);
console.log("================\n");
};

const runExtractPdfExample = async ({
gradient,
}: {
gradient: Gradient;
}): Promise<void> => {
const filepath = "resources/Lorem_Ipsum.pdf";
console.log("==== PDF Extraction ====");
console.log(`Filepath: ${filepath}\n`);

console.log("Extracting content from the PDF...");
const { pages, text } = await gradient.extractPdf({ filepath });

console.log(`Text: ${text}`);
console.log(`Pages: ${JSON.stringify(pages, null, 2)}`);
console.log("================\n");
};

const main = async () => {
const gradient = new Gradient({});

Expand All @@ -207,6 +224,7 @@ const main = async () => {
await runAnalyzeSentimentExample({ gradient });
await runPersonalizeExample({ gradient });
await runExtractExample({ gradient });
await runExtractPdfExample({ gradient });
};

main()
Expand Down

0 comments on commit 1d2c9ad

Please sign in to comment.