Skip to content

Commit

Permalink
Project import generated by Copybara. (#14)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: d6ab2c37b23d06d8a69e15e97ed552d66fa4b40e
  • Loading branch information
gradient-ai-bot authored Apr 4, 2024
1 parent 1d2c9ad commit 5a6bdf3
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ GRADIENT_WORKSPACE_ID=...
1. Clone this repo
2. Run `yarn install`
3. Run any of the following:
- `yarn fine-tune`
- `yarn blocks`
- `yarn embeddings`
- `yarn fine-tune`
- `yarn guidance`
- `yarn blocks`
- `yarn rag`

## Example

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"description": "",
"main": "dist/index.js",
"scripts": {
"blocks": "ts-node -r dotenv/config src/blocks.ts",
"embeddings": "ts-node -r dotenv/config src/embeddings.ts",
"fine-tune": "ts-node -r dotenv/config src/fineTune.ts",
"guidance": "ts-node -r dotenv/config src/guidance.ts",
"blocks": "ts-node -r dotenv/config src/blocks.ts",
,
"rag": "ts-node -r dotenv/config src/rag.ts",
"test": "true"
},
"repository": {
Expand Down
Binary file added resources/Life_Kit.mp3
Binary file not shown.
17 changes: 17 additions & 0 deletions src/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ const runExtractPdfExample = async ({
console.log("================\n");
};

const runTranscribeExample = async ({
gradient,
}: {
gradient: Gradient;
}): Promise<void> => {
const filepath = "resources/Life_Kit.mp3";
console.log("==== Audio Transcription ====");
console.log(`Filepath: ${filepath}\n`);

console.log("Transcribing audio from the file...");
const { text } = await gradient.transcribeAudio({ filepath });

console.log(`Text: ${text}`);
console.log("================\n");
};

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

Expand All @@ -225,6 +241,7 @@ const main = async () => {
await runPersonalizeExample({ gradient });
await runExtractExample({ gradient });
await runExtractPdfExample({ gradient });
await runTranscribeExample({ gradient });
};

main()
Expand Down
24 changes: 24 additions & 0 deletions src/rag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Gradient } from "@gradientai/nodejs-sdk";

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

const ragCollection = await gradient.createRagCollection({
filepaths: ["resources/Lorem_Ipsum.pdf"],
name: "My RAG Collection",
slug: "bge-large",
});
console.log(`Created RAG Collection with id: ${ragCollection.id}`);

await ragCollection.addFiles({
filepaths: ["resources/Life_Kit.mp3"],
});
console.log(`Added file to RAG Collection with id: ${ragCollection.id}`);
};

main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(() => process.exit());

0 comments on commit 5a6bdf3

Please sign in to comment.