Skip to content

Commit 659ea47

Browse files
author
Mateusz Haligowski
authored
Merge pull request #15 from Preemo-Inc/copybara-update-master
Project import generated by Copybara.
2 parents 91c7854 + 8e89ea4 commit 659ea47

File tree

5 files changed

+51
-8
lines changed

5 files changed

+51
-8
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ GRADIENT_WORKSPACE_ID=...
1616
1. Clone this repo
1717
2. Run `poetry install`
1818
3. Run any of the following:
19-
- `poetry run fine_tune`
19+
- `poetry run blocks`
2020
- `poetry run embeddings`
21+
- `poetry run fine_tune`
2122
- `poetry run guidance`
22-
- `poetry run blocks`
23+
- `poetry run rag`
2324

2425
## Example
2526

gradient_sdk_python_example/blocks.py

+13
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,18 @@ def run_extract_pdf_example(*, gradient: Gradient) -> None:
224224
print("================\n")
225225

226226

227+
def run_transcribe_example(*, gradient: Gradient) -> None:
228+
filepath = "resources/Life_Kit.mp3"
229+
print("==== Audio Transcription ====")
230+
print(f"Filepath: {filepath}\n")
231+
232+
print("Transcribing audio from the file...")
233+
result = gradient.transcribe_audio(filepath=filepath)
234+
235+
print(f"Text: {result['text']}")
236+
print("================\n")
237+
238+
227239
def main() -> None:
228240
gradient = Gradient()
229241

@@ -233,6 +245,7 @@ def main() -> None:
233245
run_personalize_example(gradient=gradient)
234246
run_extract_example(gradient=gradient)
235247
run_extract_pdf_example(gradient=gradient)
248+
run_transcribe_example(gradient=gradient)
236249

237250
gradient.close()
238251

gradient_sdk_python_example/rag.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
from dotenv import load_dotenv
3+
from gradientai import Gradient
4+
5+
load_dotenv()
6+
7+
8+
def main():
9+
gradient = Gradient()
10+
11+
rag_collection = gradient.create_rag_collection(
12+
filepaths=[
13+
"resources/Lorem_Ipsum.pdf",
14+
],
15+
name="My RAG collection",
16+
slug="bge-large",
17+
)
18+
print(f"Created RAG collection with id: {rag_collection.id_}")
19+
20+
rag_collection.add_files(filepaths=["resources/Life_Kit.mp3"])
21+
print(f"Added file to RAG Collection with id: {rag_collection.id_}")
22+
23+
gradient.close()
24+
25+
26+
if __name__ == "__main__":
27+
main()

pyproject.toml

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[tool.poetry]
2-
name = "gradient-sdk-python-example"
3-
version = "0.1.0"
4-
description = ""
52
authors = ["Gradient developers"]
6-
readme = "README.md"
3+
description = ""
4+
name = "gradient-sdk-python-example"
75
packages = [{include = "gradient_sdk_python_example"}]
6+
readme = "README.md"
7+
version = "0.1.0"
88

99
[tool.poetry.dependencies]
1010
gradientai = "^1.2.0"
@@ -16,10 +16,11 @@ black = "22.3.0"
1616
mypy = "1.3.0"
1717

1818
[tool.poetry.scripts]
19+
blocks = "gradient_sdk_python_example.blocks:main"
1920
embeddings = "gradient_sdk_python_example.embeddings:main"
2021
fine_tune = "gradient_sdk_python_example.fine_tune:main"
2122
guidance = "gradient_sdk_python_example.guidance:main"
22-
blocks = "gradient_sdk_python_example.blocks:main"
23+
rag = "gradient_sdk_python_example.rag:main"
2324

2425
[tool.black]
2526
black = "22.3.0"
@@ -35,5 +36,6 @@ warn_return_any = true
3536
warn_unused_ignores = true
3637

3738
[build-system]
38-
requires = ["poetry-core"]
3939
build-backend = "poetry.core.masonry.api"
40+
requires = ["poetry-core"]
41+

resources/Life_Kit.mp3

1.22 MB
Binary file not shown.

0 commit comments

Comments
 (0)