Skip to content

Commit bb421cf

Browse files
committed
test: add openai compatible tests for responses, vector stores and files api
1 parent a49ee47 commit bb421cf

File tree

3 files changed

+498
-42
lines changed

3 files changed

+498
-42
lines changed

tests/llama_stack/conftest.py

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ocp_resources.deployment import Deployment
1111
from ocp_resources.llama_stack_distribution import LlamaStackDistribution
1212
from ocp_resources.namespace import Namespace
13+
from ocp_resources.config_map import ConfigMap
1314
from simple_logger.logger import get_logger
1415

1516
from tests.llama_stack.utils import create_llama_stack_distribution, wait_for_llama_stack_client_ready
@@ -81,22 +82,186 @@ def llama_stack_server_config(
8182
},
8283
{"name": "FMS_ORCHESTRATOR_URL", "value": fms_orchestrator_url},
8384
],
85+
"command": ["/bin/sh", "-c", "llama stack run /etc/llama-stack/run.yaml"],
8486
"name": "llama-stack",
8587
"port": 8321,
8688
},
8789
"distribution": {"name": "rh-dev"},
90+
"userConfig": {"configMapName": "rag-llama-stack-config-map"},
8891
"storage": {
8992
"size": "20Gi",
9093
},
9194
}
9295

96+
@pytest.fixture(scope="class")
97+
def llama_stack_config_map(
98+
admin_client: DynamicClient,
99+
model_namespace: Namespace,
100+
) -> Generator[ConfigMap, Any, Any]:
101+
with ConfigMap(
102+
client=admin_client,
103+
namespace=model_namespace.name,
104+
name="rag-llama-stack-config-map",
105+
data={
106+
"run.yaml": """version: 2
107+
image_name: rh
108+
apis:
109+
- agents
110+
- datasetio
111+
- eval
112+
- inference
113+
- safety
114+
- files
115+
- scoring
116+
- telemetry
117+
- tool_runtime
118+
- vector_io
119+
providers:
120+
inference:
121+
- provider_id: vllm-inference
122+
provider_type: remote::vllm
123+
config:
124+
url: ${env.VLLM_URL:=http://localhost:8000/v1}
125+
max_tokens: ${env.VLLM_MAX_TOKENS:=4096}
126+
api_token: ${env.VLLM_API_TOKEN:=fake}
127+
tls_verify: ${env.VLLM_TLS_VERIFY:=true}
128+
- provider_id: sentence-transformers
129+
provider_type: inline::sentence-transformers
130+
config: {}
131+
vector_io:
132+
- provider_id: milvus
133+
provider_type: inline::milvus
134+
config:
135+
db_path: /opt/app-root/src/.llama/distributions/rh/milvus.db
136+
kvstore:
137+
type: sqlite
138+
namespace: null
139+
db_path: /opt/app-root/src/.llama/distributions/rh/milvus_registry.db
140+
files:
141+
- provider_id: meta-reference-files
142+
provider_type: inline::localfs
143+
config:
144+
storage_dir: /opt/app-root/src/.llama/distributions/rh/files
145+
metadata_store:
146+
type: sqlite
147+
db_path: /opt/app-root/src/.llama/distributions/rh/files/files_metadata.db
148+
safety:
149+
- provider_id: trustyai_fms
150+
provider_type: remote::trustyai_fms
151+
config:
152+
orchestrator_url: ${env.FMS_ORCHESTRATOR_URL:=}
153+
ssl_cert_path: ${env.FMS_SSL_CERT_PATH:=}
154+
shields: {}
155+
agents:
156+
- provider_id: meta-reference
157+
provider_type: inline::meta-reference
158+
config:
159+
persistence_store:
160+
type: sqlite
161+
namespace: null
162+
db_path: /opt/app-root/src/.llama/distributions/rh/agents_store.db
163+
responses_store:
164+
type: sqlite
165+
db_path: /opt/app-root/src/.llama/distributions/rh/responses_store.db
166+
eval:
167+
- provider_id: trustyai_lmeval
168+
provider_type: remote::trustyai_lmeval
169+
config:
170+
use_k8s: True
171+
base_url: ${env.VLLM_URL:=http://localhost:8000/v1}
172+
datasetio:
173+
- provider_id: huggingface
174+
provider_type: remote::huggingface
175+
config:
176+
kvstore:
177+
type: sqlite
178+
namespace: null
179+
db_path: /opt/app-root/src/.llama/distributions/rh/huggingface_datasetio.db
180+
- provider_id: localfs
181+
provider_type: inline::localfs
182+
config:
183+
kvstore:
184+
type: sqlite
185+
namespace: null
186+
db_path: /opt/app-root/src/.llama/distributions/rh/localfs_datasetio.db
187+
scoring:
188+
- provider_id: basic
189+
provider_type: inline::basic
190+
config: {}
191+
- provider_id: llm-as-judge
192+
provider_type: inline::llm-as-judge
193+
config: {}
194+
- provider_id: braintrust
195+
provider_type: inline::braintrust
196+
config:
197+
openai_api_key: ${env.OPENAI_API_KEY:=}
198+
telemetry:
199+
- provider_id: meta-reference
200+
provider_type: inline::meta-reference
201+
config:
202+
service_name: "${env.OTEL_SERVICE_NAME:=\u200B}"
203+
sinks: ${env.TELEMETRY_SINKS:=console,sqlite}
204+
sqlite_db_path: /opt/app-root/src/.llama/distributions/rh/trace_store.db
205+
otel_exporter_otlp_endpoint: ${env.OTEL_EXPORTER_OTLP_ENDPOINT:=}
206+
tool_runtime:
207+
- provider_id: brave-search
208+
provider_type: remote::brave-search
209+
config:
210+
api_key: ${env.BRAVE_SEARCH_API_KEY:=}
211+
max_results: 3
212+
- provider_id: tavily-search
213+
provider_type: remote::tavily-search
214+
config:
215+
api_key: ${env.TAVILY_SEARCH_API_KEY:=}
216+
max_results: 3
217+
- provider_id: rag-runtime
218+
provider_type: inline::rag-runtime
219+
config: {}
220+
- provider_id: model-context-protocol
221+
provider_type: remote::model-context-protocol
222+
config: {}
223+
metadata_store:
224+
type: sqlite
225+
db_path: /opt/app-root/src/.llama/distributions/rh/registry.db
226+
inference_store:
227+
type: sqlite
228+
db_path: /opt/app-root/src/.llama/distributions/rh/inference_store.db
229+
models:
230+
- metadata: {}
231+
model_id: ${env.INFERENCE_MODEL}
232+
provider_id: vllm-inference
233+
model_type: llm
234+
- metadata:
235+
embedding_dimension: 768
236+
model_id: granite-embedding-125m
237+
provider_id: sentence-transformers
238+
provider_model_id: ibm-granite/granite-embedding-125m-english
239+
model_type: embedding
240+
shields: []
241+
vector_dbs: []
242+
datasets: []
243+
scoring_fns: []
244+
benchmarks: []
245+
tool_groups:
246+
- toolgroup_id: builtin::websearch
247+
provider_id: tavily-search
248+
- toolgroup_id: builtin::rag
249+
provider_id: rag-runtime
250+
server:
251+
port: 8321
252+
external_providers_dir: /opt/app-root/src/.llama/providers.d"""
253+
},
254+
) as config_map:
255+
yield config_map
256+
93257

94258
@pytest.fixture(scope="class")
95259
def llama_stack_distribution(
96260
admin_client: DynamicClient,
97261
model_namespace: Namespace,
98262
enabled_llama_stack_operator: DataScienceCluster,
99263
llama_stack_server_config: Dict[str, Any],
264+
llama_stack_config_map: ConfigMap,
100265
) -> Generator[LlamaStackDistribution, None, None]:
101266
with create_llama_stack_distribution(
102267
client=admin_client,

0 commit comments

Comments
 (0)