11# Instructions
22
3- Setup and run the Opik vs elastic-evals-sdk-python PoC.
3+ This PoC demonstrates how Agent Builder can use the ` kbn/evals ` Python SDK for dataset
4+ management, experiment tracing, and evaluator score ingestion—capabilities previously
5+ handled through Opik—and how to build custom evaluators.
46
5- ## 1. Python environment
7+ ## 1. Dependencies
68
7- From the SDK repo root:
8-
9- ``` bash
10- cd elastic-evals-sdk-python
11- uv sync --extra dev --extra runner --extra poc
12- source .venv/bin/activate
13- ```
14-
15- ## 2. Dependencies
16-
17- ``` bash
18- uv add --optional poc datasets pandas python-dotenv ipykernel elasticsearch opik loguru
19- uv sync --extra poc
20- ```
21-
22- Orca must be importable. Clone the ` orca ` repo as a sibling of ` elastic-evals-sdk-python/ ` so the layout is:
9+ ` run2.py ` uses external Orca evaluators. Clone the ` orca ` repo as a sibling of
10+ ` elastic-evals-sdk-python/ ` so the layout is:
2311
2412```
2513── elastic-evals-sdk-python/
2614── orca/
2715```
2816
29- Then install it editable and register it under the ` poc ` extra:
17+ ## 2. Python environment
18+
19+ From the SDK repo root:
3020
3121``` bash
32- uv add --optional poc --editable ../orca
22+ uv sync --group dev --extra runner --extra poc
23+ source .venv/bin/activate
3324```
3425
3526Register the venv as a Jupyter kernel. Only needed if your notebook/IDE doesn't pick up ` .venv ` automatically:
@@ -40,21 +31,50 @@ uv run python -m ipykernel install --user --name elastic-evals-poc
4031
4132## 3. Secrets
4233
43- Retrieve the API keys (Opik, OpenRouter, HuggingFace) from Vault, then fill them into ` .env ` :
34+ Create ` .env ` next to ` .env.example ` :
35+
36+ ``` bash
37+ cp examples/opik_vs_elastic/.env.example examples/opik_vs_elastic/.env
38+ ```
39+
40+ Set the local URLs, ` ELASTICSEARCH_API_KEY ` , ` KIBANA_API_KEY ` , ` CONNECTOR_ID ` ,
41+ and ` EVALUATION_CONNECTOR_ID ` . The Opik variables are used when ` run2.py ` runs
42+ the tracked external Orca evaluators. Retrieve internal credentials from Vault
43+ when needed:
4444
4545``` bash
4646VAULT_ADDR=https://secrets.elastic.co:8200 vault login --method oidc
4747```
4848
49- ## 4. GCP access
49+ The public Hugging Face dataset does not require an API key.
50+
51+ ## 4. Data source and sample size
52+
53+ Set these values near the top of the script before running it:
54+
55+ ``` python
56+ USE_ENTIRE_DATASET = False
57+ DATASET_SAMPLE_SIZE = 10
58+ USE_GCP = False
59+ ```
60+
61+ With ` USE_GCP = False ` , the scripts load the public ` Wix/WixQA ` dataset and
62+ knowledge base from Hugging Face. Set ` USE_GCP = True ` to use the internal GCS
63+ files. ` DATASET_SAMPLE_SIZE ` is ignored when ` USE_ENTIRE_DATASET ` is ` True ` .
64+ The entire knowledge base is always indexed.
65+
66+ The available examples and their order may differ between Hugging Face and GCS.
67+ ` run.py ` defaults to 10 examples and ` run2.py ` defaults to 3.
68+
69+ ## 5. GCP access
5070
51- Only needed if you import data from a GCP bucket (e.g. ` gs://agent-builder-data-science-datasets/... ` ) . Authenticate with your ` @elastic.co ` account:
71+ Only needed when ` USE_GCP = True ` . Authenticate with your ` @elastic.co ` account:
5272
5373``` bash
5474gcloud auth application-default login
5575```
5676
57- ## 5 . Local stack
77+ ## 6 . Local stack
5878
5979Use a separate terminal for each service and leave it running.
6080
@@ -128,25 +148,40 @@ curl --silent --show-error \
128148 http://localhost:5601/dev/api/status
129149```
130150
131- ## 6 . Elasticsearch API key
151+ ## 7 . Elasticsearch API key
132152
133- ` run.py ` authenticates to Elasticsearch with ` ELASTICSEARCH_API_KEY ` (and reuses the
134- same key for Kibana, which validates Elasticsearch API keys). Create one against your
135- cluster and paste the ` encoded ` field into ` ELASTICSEARCH_API_KEY ` in ` .env ` :
153+ Both scripts authenticate to Elasticsearch and Kibana. Create an API key against
154+ the local cluster and paste the ` encoded ` field into both
155+ ` ELASTICSEARCH_API_KEY ` and ` KIBANA_API_KEY ` in ` .env ` :
136156
137157``` bash
138158curl -u elastic:changeme -XPOST http://localhost:9200/_security/api_key \
139159 -H ' Content-Type: application/json' -d ' {"name":"evals-poc"}'
140160```
141161
142- This step is ** optional** — skip it if you already have a valid ` ELASTICSEARCH_API_KEY `
143- for the cluster in ` ES_URL ` . It's required when the key is missing or invalid, e.g.
144- after starting a fresh local Elasticsearch (` yarn es snapshot ` ): API keys are
145- cluster-specific, so a key from a previous cluster returns ` 401 ` .
162+ This step is optional if both variables already contain a valid key for the
163+ current cluster. API keys are cluster-specific, so a key from a previous local
164+ Elasticsearch snapshot returns ` 401 ` .
146165
147- ## 7. Run the PoC
166+ ## 8. Run the PoC
167+
168+ ### ` run.py ` : managed workflow
169+
170+ Demonstrates the higher-level workflow. It uses
171+ ` ElasticEvalsClient.run_experiment() ` to execute the selected WixQA examples,
172+ run SDK-side and custom evaluators, and ingest their scores.
148173
149174``` bash
150175cd /Users/mafaldasavelho/Documents/work-repos/kibana-fork/evals-python-sdk/elastic-evals-sdk-python
151176uv run --extra poc python examples/opik_vs_elastic/run.py
152177```
178+
179+ ### ` run2.py ` : granular workflow
180+
181+ Demonstrates the lower-level workflow without ` run_experiment() ` . It directly
182+ coordinates the Dataset, Evaluators, and Score Ingestion APIs, runs the custom
183+ Document Recall evaluator, and attaches external Orca scores.
184+
185+ ``` bash
186+ uv run --extra poc python examples/opik_vs_elastic/run2.py
187+ ```
0 commit comments