Skip to content
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

chore: setup docs #75

Merged
merged 8 commits into from
Oct 10, 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
17 changes: 17 additions & 0 deletions .github/scripts/deploy_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

uv sync --only-dev

echo $GCP_KEY | base64 -d >> gcp_creds.json
gcloud auth activate-service-account --key-file gcp_creds.json
gcloud config set project ds-internal-db-ally

# Build the documentation
uv run mkdocs build

# Upload built docs to a bucket
gcloud storage cp -r site/* gs://ragbits-documentation

# Invalidate cached content in the CDN
gcloud compute url-maps invalidate-cdn-cache ragbits-documentation-lb \
--path "/*" --async
32 changes: 32 additions & 0 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Deploy documentation

on:
release:
branches: [main]
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
container: gcr.io/google.com/cloudsdktool/google-cloud-cli:latest
environment: documentation
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: "0.4.10"
- name: Cache Dependencies
uses: actions/cache@v3
with:
path: ~/.cache/uv
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Deploy docs
run: ./.github/scripts/deploy_docs.sh
env:
GCP_KEY: ${{ secrets.GCP_KEY }}

1 change: 1 addition & 0 deletions .license-whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Python Software Foundation License, MIT License
Unlicense
Proprietary License
Historical Permission Notice and Disclaimer (HPND)
ISC
7 changes: 7 additions & 0 deletions docs/api_reference/core/embeddings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Embeddings

::: ragbits.core.embeddings.Embeddings

::: ragbits.core.embeddings.LocalEmbeddings

::: ragbits.core.embeddings.LiteLLMEmbeddings
7 changes: 7 additions & 0 deletions docs/api_reference/core/llms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# LLMs

::: ragbits.core.llms.LLM

::: ragbits.core.llms.LocalLLM

::: ragbits.core.llms.LiteLLM
3 changes: 3 additions & 0 deletions docs/api_reference/core/prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Prompt

::: ragbits.core.prompt.Prompt
9 changes: 9 additions & 0 deletions docs/api_reference/core/vector_store.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Vector Store

::: ragbits.core.vector_store.VectorDBEntry

::: ragbits.core.vector_store.VectorStore

::: ragbits.core.vector_store.InMemoryVectorStore

::: ragbits.core.vector_store.ChromaDBStore
7 changes: 7 additions & 0 deletions docs/api_reference/document_search/documents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Documents and Elements

::: ragbits.document_search.documents.document.Document

::: ragbits.document_search.documents.element.Element

::: ragbits.document_search.documents.sources.Source
3 changes: 3 additions & 0 deletions docs/api_reference/document_search/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Document Search

::: ragbits.document_search.DocumentSearch
3 changes: 3 additions & 0 deletions docs/api_reference/document_search/ingestion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Document Processing

::: ragbits.document_search.ingestion.document_processor.DocumentProcessorRouter
91 changes: 91 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
hide:
- navigation
---

# ragbits docs

<style>
.md-content .md-typeset h1 { display: none; }
</style>

<div align="center" markdown="span">
![ragbits logo](./assets/ragbits.png#only-light){ width="50%" }
![ragbits logo](./assets/ragbits.png#only-dark){ width="50%" }
</div>

<p align="center">
<em size="">Building blocks for rapid development of GenAI applications.</em>
</p>

<div align="center">

<a href="https://pypi.org/project/ragbits" target="_blank">
<img alt="PyPI - License" src="https://img.shields.io/pypi/l/ragbits">
</a>

<a href="https://pypi.org/project/ragbits" target="_blank">
<img alt="PyPI - Version" src="https://img.shields.io/pypi/v/ragbits">
</a>

<a href="https://pypi.org/project/ragbits" target="_blank">
<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/ragbits">
</a>

</div>
---

**ragbits** is a Python package that offers essential "bits" for building powerful Retrieval-Augmented Generation (RAG)
applications.

**ragbits** prioritizes an exceptional developer experience by providing a simple and intuitive API.
It also includes a comprehensive set of tools for seamlessly building, testing, and deploying your RAG applications
efficiently.

## Installation

You can install the latest version of **ragbits** using pip:

```bash
pip install ragbits
```

Additionally, you can install one of the extensions to **ragbits**:

- `ragbits[document-search]` - provides tools for building document search applications.

## Quickstart

To build the simplest documents search, you can use the following code snippet:

```python
import asyncio

from ragbits.core.embeddings import LiteLLMEmbeddings
from ragbits.core.vector_store import InMemoryVectorStore
from ragbits.document_search import DocumentSearch
from ragbits.document_search.documents.document import DocumentMeta

documents = [
DocumentMeta.create_text_document_from_literal("RIP boiled water. You will be mist."),
DocumentMeta.create_text_document_from_literal(
"Why doesn't James Bond fart in bed? Because it would blow his cover."
),
DocumentMeta.create_text_document_from_literal(
"Why programmers don't like to swim? Because they're scared of the floating points."
),
]


async def main():
document_search = DocumentSearch(embedder=LiteLLMEmbeddings(), vector_store=InMemoryVectorStore())

for document in documents:
await document_search.ingest_document(document)

return await document_search.search("I'm boiling my water and I need a joke")


if __name__ == "__main__":
print(asyncio.run(main()))
```
24 changes: 24 additions & 0 deletions docs/integrations/promptfoo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Promptfoo Integration

Ragbits' `Prompt` abstraction can be seamlessly integrated with the `promptfoo` tool. After installing `promptfoo` as
specified in the [promptfoo documentation](https://www.promptfoo.dev/docs/installation/), you can generate promptfoo
configuration files for all the prompts discovered by our autodiscover mechanism by running the following command:

```bash
rbts prompts generate-promptfoo-configs
```

This command will generate a YAML files in the directory specified by `--target-path` (`promptfooconfigs` by
default). The generated file should look like this:

```yaml
prompts:
- file:///path/to/your/prompt:PromptClass.to_promptfoo
```

You can then edit the generated file to add your custom `promptfoo` configurations. Once your `promptfoo` configuration
file is ready, you can run `promptfoo` with the following command:

```bash
promptfoo -c /path/to/generated/promptfoo-config.yaml eval
```
7 changes: 7 additions & 0 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:root {
--md-primary-fg-color: #00b0e0;
}

.md-header__title {
margin-left: 0.5rem !important;
}
110 changes: 110 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
site_name: ragbits docs
site_description: Library for fast RAG application development
site_url: https://ragbits.deepsense.ai
repo_name: deepsense-ai/ragbits
repo_url: https://github.com/deepsense-ai/ragbits
copyright: Copyright &copy; 2024 deepsense.ai
nav:
- rabgbits: index.md
- How-to Guides:
- integrations/promptfoo.md
- API Reference:
- Core:
- api_reference/core/prompt.md
- api_reference/core/llms.md
- api_reference/core/embeddings.md
- api_reference/core/vector_store.md
- Document Search:
- api_reference/document_search/index.md
- api_reference/document_search/documents.md
- api_reference/document_search/ingestion.md

theme:
name: material
icon:
repo: fontawesome/brands/github
palette:
- media: "(prefers-color-scheme)"
toggle:
icon: material/lightbulb-auto
name: Switch to light mode
- media: '(prefers-color-scheme: light)'
scheme: default
primary: primary
toggle:
icon: material/lightbulb
name: Switch to dark mode
- media: '(prefers-color-scheme: dark)'
scheme: slate
primary: primary
toggle:
icon: material/lightbulb-outline
name: Switch to system preference
features:
- navigation.footer
- navigation.tabs
- navigation.tabs.sticky
- navigation.top
- content.code.annotate
- content.code.copy
extra_css:
- stylesheets/extra.css
markdown_extensions:
- pymdownx.highlight:
anchor_linenums: true
line_spans: __span
pygments_lang_class: true
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
- admonition
- pymdownx.superfences
- pymdownx.snippets
- pymdownx.inlinehilite
- attr_list
- md_in_html
- pymdownx.details
- def_list
- pymdownx.tasklist:
custom_checkbox: true
- pymdownx.tabbed:
alternate_style: true
- toc:
permalink: "#"
plugins:
- search
- autorefs:
enable: true
- mkdocstrings:
handlers:
python:
options:
show_root_heading: true
show_if_no_docstring: true
inherited_members: true
members_order: source
separate_signature: true
unwrap_annotated: true
filters:
- "!^_"
merge_init_into_class: true
docstring_section_style: spacy
signature_crossrefs: true
show_symbol_type_heading: true
show_symbol_type_toc: true
show_signature_annotations: true
extra:
social:
- icon: fontawesome/brands/github
link: https://github.com/deepsense-ai
- icon: fontawesome/brands/x-twitter
link: https://x.com/deepsense_ai
- icon: fontawesome/brands/linkedin
link: https://linkedin.com/company/deepsense-ai
- icon: fontawesome/brands/youtube
link: https://youtube.com/@deepsenseai
- icon: fontawesome/brands/medium
link: https://medium.com/deepsense-ai
- icon: fontawesome/solid/globe
link: https://deepsense.ai
2 changes: 1 addition & 1 deletion packages/ragbits-core/examples/chromadb_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import chromadb

from ragbits.core.embeddings.litellm import LiteLLMEmbeddings
from ragbits.core.embeddings import LiteLLMEmbeddings
from ragbits.core.vector_store.chromadb_store import ChromaDBStore
from ragbits.document_search import DocumentSearch
from ragbits.document_search.documents.document import DocumentMeta
Expand Down
5 changes: 5 additions & 0 deletions packages/ragbits-core/src/ragbits/core/embeddings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .base import Embeddings
from .litellm import LiteLLMEmbeddings
from .local import LocalEmbeddings

__all__ = ["Embeddings", "LiteLLMEmbeddings", "LocalEmbeddings"]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
except ImportError:
HAS_LITELLM = False

from ragbits.core.embeddings.base import Embeddings
from ragbits.core.embeddings import Embeddings
from ragbits.core.embeddings.exceptions import EmbeddingConnectionError, EmbeddingResponseError, EmbeddingStatusError


Expand Down
2 changes: 1 addition & 1 deletion packages/ragbits-core/src/ragbits/core/embeddings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
except ImportError:
HAS_LOCAL_EMBEDDINGS = False

from ragbits.core.embeddings.base import Embeddings
from ragbits.core.embeddings import Embeddings


class LocalEmbeddings(Embeddings):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .base import VectorDBEntry, VectorStore
from .chromadb_store import ChromaDBStore
from .in_memory import InMemoryVectorStore

__all__ = ["VectorStore", "VectorDBEntry", "InMemoryVectorStore", "ChromaDBStore"]
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
except ImportError:
HAS_CHROMADB = False

from ragbits.core.embeddings.base import Embeddings
from ragbits.core.vector_store.base import VectorStore
from ragbits.core.vector_store.in_memory import VectorDBEntry
from ragbits.core.embeddings import Embeddings
from ragbits.core.vector_store import VectorDBEntry, VectorStore


class ChromaDBStore(VectorStore):
Expand Down
Loading
Loading