Skip to content

Commit 69d1eaf

Browse files
authored
Merge branch 'main' into update-notebook-link
2 parents 094785f + b542009 commit 69d1eaf

File tree

8 files changed

+219
-270
lines changed

8 files changed

+219
-270
lines changed

demos/basic_demo.ipynb

Lines changed: 109 additions & 186 deletions
Large diffs are not rendered by default.

distribution/run.yaml

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
version: "2"
2-
image_name: trustyai_ragas_distro_remote
1+
version: 2
2+
image_name: trustyai_ragas_distro
33
apis:
4-
- eval
5-
- inference
6-
- files
7-
- benchmarks
8-
- telemetry
9-
- datasetio
4+
- eval
5+
- inference
6+
- files
7+
- benchmarks
8+
- datasetio
109
providers:
1110
eval:
1211
- provider_id: ${env.KUBEFLOW_LLAMA_STACK_URL:+trustyai_ragas_remote}
@@ -22,41 +21,59 @@ providers:
2221
llama_stack_url: ${env.KUBEFLOW_LLAMA_STACK_URL}
2322
base_image: ${env.KUBEFLOW_BASE_IMAGE}
2423
pipelines_api_token: ${env.KUBEFLOW_PIPELINES_TOKEN:=}
24+
kvstore:
25+
namespace: ragas
26+
backend: kv_default
2527
- provider_id: ${env.EMBEDDING_MODEL:+trustyai_ragas_inline}
2628
provider_type: inline::trustyai_ragas
2729
module: llama_stack_provider_ragas.inline
2830
config:
2931
embedding_model: ${env.EMBEDDING_MODEL}
30-
datasetio:
31-
- provider_id: localfs
32-
provider_type: inline::localfs
33-
config:
3432
kvstore:
35-
type: sqlite
36-
namespace: null
37-
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/trustyai_ragas_distro_remote}/localfs_datasetio.db
33+
namespace: ragas
34+
backend: kv_default
35+
datasetio:
36+
- provider_id: localfs
37+
provider_type: inline::localfs
38+
config:
39+
kvstore:
40+
namespace: datasetio::localfs
41+
backend: kv_default
3842
inference:
3943
- provider_id: ollama
4044
provider_type: remote::ollama
4145
config:
4246
url: ${env.OLLAMA_URL:=http://localhost:11434}
43-
telemetry:
44-
- provider_id: meta-reference
45-
provider_type: inline::meta-reference
46-
config:
47-
service_name: "${env.OTEL_SERVICE_NAME:=\u200B}"
48-
sinks: ${env.TELEMETRY_SINKS:=console,sqlite}
49-
sqlite_db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/trustyai_ragas_distro_remote}/trace_store.db
50-
otel_exporter_otlp_endpoint: ${env.OTEL_EXPORTER_OTLP_ENDPOINT:=}
5147
files:
52-
- provider_id: meta-reference-files
53-
provider_type: inline::localfs
54-
config:
55-
storage_dir: ${env.FILES_STORAGE_DIR:=~/.llama/distributions/trustyai_ragas_distro_remote/files}
56-
metadata_store:
57-
type: sqlite
58-
db_path: ${env.METADATA_STORE_DB_PATH:=~/.llama/distributions/trustyai_ragas_distro_remote}/registry.db}
59-
models:
48+
- provider_id: meta-reference-files
49+
provider_type: inline::localfs
50+
config:
51+
storage_dir: ${env.FILES_STORAGE_DIR:=~/.llama/distributions/trustyai_ragas_distro/files}
52+
metadata_store:
53+
table_name: files_metadata
54+
backend: sql_default
55+
storage:
56+
backends:
57+
kv_default:
58+
type: kv_sqlite
59+
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/trustyai_ragas_distro}/kvstore.db
60+
sql_default:
61+
type: sql_sqlite
62+
db_path: ${env.SQLITE_STORE_DIR:=~/.llama/distributions/trustyai_ragas_distro}/sql_store.db
63+
stores:
64+
metadata:
65+
namespace: registry
66+
backend: kv_default
67+
inference:
68+
table_name: inference_store
69+
backend: sql_default
70+
max_write_queue_size: 10000
71+
num_writers: 4
72+
conversations:
73+
table_name: openai_conversations
74+
backend: sql_default
75+
registered_resources:
76+
models:
6077
- metadata:
6178
embedding_dimension: 384
6279
model_id: all-MiniLM-L6-v2
@@ -68,6 +85,13 @@ models:
6885
provider_id: ollama
6986
provider_model_id: granite3.3:2b
7087
model_type: llm
88+
shields: []
89+
vector_dbs: []
90+
datasets: []
91+
scoring_fns: []
92+
benchmarks: []
93+
tool_groups: []
7194
server:
72-
host: localhost
7395
port: 8321
96+
telemetry:
97+
enabled: true

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "llama-stack-provider-ragas"
7-
version = "0.4.1"
7+
version = "0.4.2"
88
description = "Ragas evaluation as an out-of-tree Llama Stack provider"
99
readme = "README.md"
1010
requires-python = ">=3.12"
@@ -25,7 +25,7 @@ authors = [
2525
keywords = ["llama-stack", "ragas", "evaluation"]
2626
dependencies = [
2727
"setuptools-scm",
28-
"llama-stack>=0.2.23",
28+
"llama-stack>0.2.23",
2929
"greenlet==3.2.4", # inline/files/localfs errors saying greenlet not found
3030
"ragas==0.3.0",
3131
"pandas<2.3.0",
@@ -39,7 +39,7 @@ homepage = "https://github.com/trustyai-explainability/llama-stack-provider-raga
3939
repository = "https://github.com/trustyai-explainability/llama-stack-provider-ragas"
4040

4141
[project.optional-dependencies]
42-
remote = ["kfp>=2.5.0", "kfp-kubernetes>=2.0.0", "s3fs>=2024.12.0", "kubernetes>=30.0.0"]
42+
remote = ["kfp>=2.5.0", "kfp-kubernetes>=2.0.0", "kfp-pipeline-spec>=2.0.0", "kfp-server-api>=2.0.0", "s3fs>=2024.12.0", "kubernetes>=30.0.0"]
4343
distro = ["opentelemetry-api", "opentelemetry-exporter-otlp", "aiosqlite", "ollama", "uvicorn"]
4444
dev = [
4545
"llama-stack-provider-ragas[distro]",

src/llama_stack_provider_ragas/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ class RagasProviderBaseConfig(BaseModel):
3333

3434
# Looking for the model?
3535
# It's in the benchmark config's eval_candidate.
36-
# You set it as part of the call to `client.eval.run_eval`.
36+
# You set it as part of the call to `client.alpha.eval.run_eval`.
3737

3838
# Looking for the sampling params?
3939
# It's in the benchmark config's eval_candidate.
40-
# You set them as part of the call to `client.eval.run_eval`.
40+
# You set them as part of the call to `client.alpha.eval.run_eval`.
4141

4242
# Looking for the dataset?
4343
# It's in the benchmark config's dataset_id.

src/llama_stack_provider_ragas/inline/wrappers_inline.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33

44
from langchain_core.language_models.llms import Generation, LLMResult
55
from langchain_core.prompt_values import PromptValue
6-
from llama_stack.apis.inference import SamplingParams, TopPSamplingStrategy
6+
from llama_stack.apis.inference import (
7+
OpenAICompletionRequestWithExtraBody,
8+
OpenAIEmbeddingsRequestWithExtraBody,
9+
SamplingParams,
10+
TopPSamplingStrategy,
11+
)
712
from ragas.embeddings.base import BaseRagasEmbeddings
813
from ragas.llms.base import BaseRagasLLM
914
from ragas.run_config import RunConfig
@@ -39,10 +44,11 @@ def embed_documents(self, texts: list[str]) -> list[list[float]]:
3944
async def aembed_documents(self, texts: list[str]) -> list[list[float]]:
4045
"""Embed documents using Llama Stack inference API."""
4146
try:
42-
response = await self.inference_api.openai_embeddings(
47+
request = OpenAIEmbeddingsRequestWithExtraBody(
4348
model=self.embedding_model_id,
4449
input=texts,
4550
)
51+
response = await self.inference_api.openai_embeddings(request)
4652
return [data.embedding for data in response.data]
4753
except Exception as e:
4854
logger.error(f"Document embedding failed: {str(e)}")
@@ -51,10 +57,11 @@ async def aembed_documents(self, texts: list[str]) -> list[list[float]]:
5157
async def aembed_query(self, text: str) -> list[float]:
5258
"""Embed query using Llama Stack inference API."""
5359
try:
54-
response = await self.inference_api.openai_embeddings(
60+
request = OpenAIEmbeddingsRequestWithExtraBody(
5561
model=self.embedding_model_id,
5662
input=text,
5763
)
64+
response = await self.inference_api.openai_embeddings(request)
5865
return response.data[0].embedding # type: ignore
5966
except Exception as e:
6067
logger.error(f"Query embedding failed: {str(e)}")
@@ -109,7 +116,7 @@ async def agenerate_text(
109116
# sampling params for this generation should be set via the benchmark config
110117
# we will ignore the temperature and stop params passed in here
111118
for _ in range(n):
112-
response = await self.inference_api.openai_completion(
119+
request = OpenAICompletionRequestWithExtraBody(
113120
model=self.model_id,
114121
prompt=prompt.to_string(),
115122
max_tokens=self.sampling_params.max_tokens
@@ -125,6 +132,7 @@ async def agenerate_text(
125132
else None,
126133
stop=self.sampling_params.stop if self.sampling_params else None,
127134
)
135+
response = await self.inference_api.openai_completion(request)
128136

129137
if not response.choices:
130138
logger.warning("Completion response returned no choices")

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def model():
3535

3636
@pytest.fixture
3737
def embedding_model():
38-
return "all-MiniLM-L6-v2"
38+
return "ollama/all-minilm:latest"
3939

4040

4141
@pytest.fixture

tests/test_inline_evaluation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_single_metric_evaluation(
3939
provider_id=PROVIDER_ID_INLINE,
4040
)
4141

42-
job = lls_client.eval.run_eval(
42+
job = lls_client.alpha.eval.run_eval(
4343
benchmark_id=benchmark_id,
4444
benchmark_config={
4545
"eval_candidate": {

0 commit comments

Comments
 (0)