Skip to content

Commit 30b80da

Browse files
authored
Merge pull request #58 from red-hat-data-services/sync-midstream-2
[sync] Sync midstream
2 parents a38e534 + 60b2c12 commit 30b80da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+5016
-840
lines changed

.github/pull.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: "1"
2+
rules:
3+
- base: main
4+
upstream: trustyai-explainability:main
5+
mergeMethod: merge
6+
mergeUnstable: false
7+
label: "bot/merge-upstream"
8+
conflictLabel: "merge-conflict"

.github/workflows/docs.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Build and Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: [main, docs]
6+
paths:
7+
- 'docs/**'
8+
- 'antora-playbook.yml'
9+
- '.github/workflows/docs.yml'
10+
pull_request:
11+
branches: [main]
12+
paths:
13+
- 'docs/**'
14+
- 'antora-playbook.yml'
15+
- '.github/workflows/docs.yml'
16+
17+
permissions:
18+
contents: read
19+
pages: write
20+
id-token: write
21+
22+
concurrency:
23+
group: "pages"
24+
cancel-in-progress: false
25+
26+
jobs:
27+
build:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Setup Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: '18'
39+
cache: 'npm'
40+
41+
- name: Install Antora
42+
run: |
43+
npm install -g @antora/[email protected] @antora/[email protected]
44+
npm install @asciidoctor/tabs
45+
46+
- name: Build documentation
47+
run: antora antora-playbook.yml
48+
49+
- name: Upload documentation artifact
50+
uses: actions/upload-pages-artifact@v3
51+
with:
52+
path: ./docs-dist
53+
54+
deploy:
55+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/docs'
56+
environment:
57+
name: github-pages
58+
url: ${{ steps.deployment.outputs.page_url }}
59+
runs-on: ubuntu-latest
60+
needs: build
61+
steps:
62+
- name: Setup Pages
63+
uses: actions/configure-pages@v4
64+
65+
- name: Deploy to GitHub Pages
66+
id: deployment
67+
uses: actions/deploy-pages@v4

.github/workflows/release.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Publish to PyPi
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
pypi:
7+
name: Publish to PyPI
8+
runs-on: ubuntu-latest
9+
environment:
10+
name: pypi
11+
url: https://pypi.org/p/llama-stack-provider-ragas
12+
permissions:
13+
id-token: write
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v5
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version-file: "pyproject.toml"
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v6
23+
- name: Build
24+
run: uv build
25+
- name: Local smoke test (wheel)
26+
run: uv run --isolated --no-project --with dist/*.whl -- python -c "import llama_stack_provider_ragas"
27+
- name: Local smoke test (source distribution)
28+
run: uv run --isolated --no-project --with dist/*.tar.gz -- python -c "import llama_stack_provider_ragas"
29+
- name: Publish
30+
run: uv publish
31+
- name: Test install from pypi
32+
run: |
33+
uv run --isolated --no-project --with llama-stack-provider-ragas -- python -c "import llama_stack_provider_ragas; import importlib.metadata; print(f'LLS Ragas Provider Version: {importlib.metadata.version(\"llama-stack-provider-ragas\")}')"

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,7 @@ _build/
9595

9696
# Local development notes
9797
notes.org
98+
99+
# Documentation
100+
docs-dist/
101+
node_modules/

.vscode/launch.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@
66
"configurations": [
77

88
{
9-
"name": "Debug Ragas Distribution",
9+
"name": "Debug Ragas Distribution -- Remote",
1010
"type": "debugpy",
1111
"request": "launch",
1212
"module": "llama_stack.cli.llama",
13-
"args": ["stack", "run", "distribution/run.yaml"],
13+
"args": ["stack", "run", "distribution/run-remote.yaml"],
14+
"cwd": "${workspaceFolder}",
15+
"envFile": "${workspaceFolder}/.env",
16+
"justMyCode": false
17+
},
18+
{
19+
"name": "Debug Ragas Distribution -- Inline",
20+
"type": "debugpy",
21+
"request": "launch",
22+
"module": "llama_stack.cli.llama",
23+
"args": ["stack", "run", "distribution/run-inline.yaml"],
1424
"cwd": "${workspaceFolder}",
1525
"envFile": "${workspaceFolder}/.env",
1626
"justMyCode": false

Containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ WORKDIR /usr/local/src/kfp/components
55

66
COPY . .
77

8-
RUN pip install --no-cache-dir -e .
8+
RUN pip install --no-cache-dir -e ".[remote]"

README.md

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
# `trustyai-ragas` <br> Ragas as an Out-of-Tree Llama Stack Provider
1+
<p align="center">
2+
<img src="https://raw.githubusercontent.com/trustyai-explainability/llama-stack-provider-ragas/main/docs/_static/provider-logo.png" alt="Llama Stack Provider" height="120">
3+
</p>
4+
5+
# Ragas as an External Provider for Llama Stack
6+
7+
[![PyPI version](https://img.shields.io/pypi/v/llama_stack_provider_ragas.svg)](https://pypi.org/project/llama-stack-provider-ragas/)
28

3-
⚠️ Warning! This project is in early stages of development!
49

510
## About
611
This repository implements [Ragas](https://github.com/explodinggradients/ragas) as an out-of-tree [Llama Stack](https://github.com/meta-llama/llama-stack) evaluation provider.
@@ -34,24 +39,58 @@ There are two versions of the provider:
3439
```bash
3540
uv pip install -e ".[dev]"
3641
```
37-
- Run the Llama Stack server with the distribution configs. The distribution is a simple LS distribution that uses Ollama for inference and embeddings, and includes both the inline and remote Ragas providers. Counting the number of `run`s in this command is left as an exercise for the reader:
38-
```bash
39-
dotenv run uv run llama stack run distribution/run.yaml
40-
```
42+
- The sample LS distributions (one for inline and one for remote provider) is a simple LS distribution that uses Ollama for inference and embeddings. See the provider-specific sections below for setup and run commands.
43+
44+
### Remote provider (default)
45+
46+
Create a `.env` file with the following:
47+
```bash
48+
# Required for both inline and remote
49+
EMBEDDING_MODEL=all-MiniLM-L6-v2
50+
51+
# Required for remote provider
52+
KUBEFLOW_LLAMA_STACK_URL=<your-llama-stack-url>
53+
KUBEFLOW_PIPELINES_ENDPOINT=<your-kfp-endpoint>
54+
KUBEFLOW_NAMESPACE=<your-namespace>
55+
KUBEFLOW_BASE_IMAGE=quay.io/diegosquayorg/my-ragas-provider-image:latest
56+
KUBEFLOW_PIPELINES_TOKEN=<your-pipelines-token>
57+
KUBEFLOW_RESULTS_S3_PREFIX=s3://my-bucket/ragas-results
58+
KUBEFLOW_S3_CREDENTIALS_SECRET_NAME=<secret-name>
59+
```
60+
61+
Where:
62+
- `KUBEFLOW_LLAMA_STACK_URL`: The URL of the llama stack server that the remote provider will use to run the evaluation (LLM generations and embeddings, etc.). If you are running Llama Stack locally, you can use [ngrok](https://ngrok.com/) to expose it to the remote provider.
63+
- `KUBEFLOW_PIPELINES_ENDPOINT`: You can get this via `kubectl get routes -A | grep -i pipeline` on your Kubernetes cluster.
64+
- `KUBEFLOW_NAMESPACE`: The name of the data science project where the Kubeflow Pipelines server is running.
65+
- `KUBEFLOW_PIPELINES_TOKEN`: Kubeflow Pipelines token with access to submit pipelines. If not provided, the token will be read from the local kubeconfig file.
66+
- `KUBEFLOW_BASE_IMAGE`: The image used to run the Ragas evaluation in the remote provider. See `Containerfile` for details. There is a public version of this image at `quay.io/diegosquayorg/my-ragas-provider-image:latest`.
67+
- `KUBEFLOW_RESULTS_S3_PREFIX`: S3 location (bucket and prefix folder) where evaluation results will be stored, e.g., `s3://my-bucket/ragas-results`.
68+
- `KUBEFLOW_S3_CREDENTIALS_SECRET_NAME`: Name of the Kubernetes secret containing AWS credentials with write access to the S3 bucket. Create with:
69+
```bash
70+
oc create secret generic <secret-name> \
71+
--from-literal=AWS_ACCESS_KEY_ID=your-access-key \
72+
--from-literal=AWS_SECRET_ACCESS_KEY=your-secret-key \
73+
--from-literal=AWS_DEFAULT_REGION=us-east-1
74+
```
75+
76+
Run the server:
77+
```bash
78+
dotenv run uv run llama stack run distribution/run-remote.yaml
79+
```
80+
81+
### Inline provider (need to specify `.inline` in the module name)
4182
42-
### Inline provider
83+
Create a `.env` file with the required environment variable:
84+
```bash
85+
EMBEDDING_MODEL=all-MiniLM-L6-v2
86+
```
4387
44-
### Remote provider
45-
- Create a `.env` file with the following:
46-
- `LLAMA_STACK_URL`
47-
- This is the url of the llama stack server that the remote provider will use to run the evaluation (LLM generations and embeddings, etc.). If you are running Llama Stack locally, you can use [ngrok](https://ngrok.com/) to expose it to the remote provider.
48-
- `KUBEFLOW_PIPELINES_ENDPOINT`
49-
- You can get this via `kubectl get routes -A | grep -i pipeline` on your Kubernetes cluster.
50-
- `KUBEFLOW_NAMESPACE`
51-
- This is the name of the data science project where the Kubeflow Pipelines server is running.
52-
- `KUBEFLOW_BASE_IMAGE`
53-
- This is the image used to run the Ragas evaluation in the remote provider. See `Containerfile` for details. There is a public version of this image at `quay.io/diegosquayorg/my-ragas-provider-image:latest`.
88+
Run the server:
89+
```bash
90+
dotenv run uv run llama stack run distribution/run-inline.yaml
91+
```
5492
93+
You will notice that `run-inline.yaml` file has the module name as `llama_stack_provider_ragas.inline`, in order to specify the inline provider.
5594
5695
## Usage
5796
See the demos in the `demos` directory.

antora-playbook.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
site:
2+
title: Ragas provider for Llama Stack
3+
url: https://trustyai-explainability.github.io/llama-stack-provider-ragas
4+
start_page: llama-stack-provider-ragas::index.adoc
5+
6+
content:
7+
sources:
8+
- url: ./
9+
branches: HEAD
10+
start_path: docs
11+
12+
ui:
13+
bundle:
14+
url: https://gitlab.com/antora/antora-ui-default/-/jobs/artifacts/HEAD/raw/build/ui-bundle.zip?job=bundle-stable
15+
snapshot: true
16+
17+
asciidoc:
18+
attributes:
19+
source-highlighter: highlight.js
20+
page-pagination: true
21+
hide-uri-scheme: true
22+
extensions:
23+
- '@asciidoctor/tabs'
24+
- 'asciidoctor-kroki'
25+
26+
output:
27+
dir: ./docs-dist

0 commit comments

Comments
 (0)