Skip to content

Project import generated by Copybara. #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 `poetry install`
3. Run any of the following:
- `poetry run fine_tune`
- `poetry run blocks`
- `poetry run embeddings`
- `poetry run fine_tune`
- `poetry run guidance`
- `poetry run blocks`
- `poetry run rag`

## Example

Expand Down
13 changes: 13 additions & 0 deletions gradient_sdk_python_example/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,18 @@ def run_extract_pdf_example(*, gradient: Gradient) -> None:
print("================\n")


def run_transcribe_example(*, gradient: Gradient) -> None:
filepath = "resources/Life_Kit.mp3"
print("==== Audio Transcription ====")
print(f"Filepath: {filepath}\n")

print("Transcribing audio from the file...")
result = gradient.transcribe_audio(filepath=filepath)

print(f"Text: {result['text']}")
print("================\n")


def main() -> None:
gradient = Gradient()

Expand All @@ -233,6 +245,7 @@ def main() -> None:
run_personalize_example(gradient=gradient)
run_extract_example(gradient=gradient)
run_extract_pdf_example(gradient=gradient)
run_transcribe_example(gradient=gradient)

gradient.close()

Expand Down
27 changes: 27 additions & 0 deletions gradient_sdk_python_example/rag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
from dotenv import load_dotenv
from gradientai import Gradient

load_dotenv()


def main():
gradient = Gradient()

rag_collection = gradient.create_rag_collection(
filepaths=[
"resources/Lorem_Ipsum.pdf",
],
name="My RAG collection",
slug="bge-large",
)
print(f"Created RAG collection with id: {rag_collection.id_}")

rag_collection.add_files(filepaths=["resources/Life_Kit.mp3"])
print(f"Added file to RAG Collection with id: {rag_collection.id_}")

gradient.close()


if __name__ == "__main__":
main()
14 changes: 8 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[tool.poetry]
name = "gradient-sdk-python-example"
version = "0.1.0"
description = ""
authors = ["Gradient developers"]
readme = "README.md"
description = ""
name = "gradient-sdk-python-example"
packages = [{include = "gradient_sdk_python_example"}]
readme = "README.md"
version = "0.1.0"

[tool.poetry.dependencies]
gradientai = "^1.2.0"
Expand All @@ -16,10 +16,11 @@ black = "22.3.0"
mypy = "1.3.0"

[tool.poetry.scripts]
blocks = "gradient_sdk_python_example.blocks:main"
embeddings = "gradient_sdk_python_example.embeddings:main"
fine_tune = "gradient_sdk_python_example.fine_tune:main"
guidance = "gradient_sdk_python_example.guidance:main"
blocks = "gradient_sdk_python_example.blocks:main"
rag = "gradient_sdk_python_example.rag:main"

[tool.black]
black = "22.3.0"
Expand All @@ -35,5 +36,6 @@ warn_return_any = true
warn_unused_ignores = true

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core"]

Binary file added resources/Life_Kit.mp3
Binary file not shown.