Skip to content

Commit 9f3b267

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

File tree

3 files changed

+499
-42
lines changed

3 files changed

+499
-42
lines changed

tests/llama_stack/conftest.py

Lines changed: 166 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,187 @@ 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

9396

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

0 commit comments

Comments
 (0)