llama-stack-mirror/llama_stack/apis
Mark Campbell 618ccea090
feat: add input validation for search mode of rag query config (#2275)
# What does this PR do?
Adds input validation for mode in RagQueryConfig
This will prevent users from inputting search modes other than `vector`
and `keyword` for the time being with `hybrid` to follow when that
functionality is implemented.

## Test Plan
[Describe the tests you ran to verify your changes with result
summaries. *Provide clear instructions so the plan can be easily
re-executed.*]
```
# Check out this PR and enter the LS directory
uv sync --extra dev
```
Run the quickstart
[example](https://llama-stack.readthedocs.io/en/latest/getting_started/#step-3-run-the-demo)
Alter the Agent to include a query_config
```
agent = Agent(
    client,
    model=model_id,
    instructions="You are a helpful assistant",
    tools=[
        {
            "name": "builtin::rag/knowledge_search",
            "args": {
                "vector_db_ids": [vector_db_id],
                "query_config": {
                    "mode": "i-am-not-vector", # Test for non valid search mode
                    "max_chunks": 6
                }
            },
        }
    ],
)
```
Ensure you get the following error:
```
400: {'errors': [{'loc': ['mode'], 'msg': "Value error, mode must be either 'vector' or 'keyword' if supported by the vector_io provider", 'type': 'value_error'}]}
```

## Running unit tests
```
uv sync --extra dev
uv run pytest tests/unit/rag/test_rag_query.py -v
```

[//]: # (## Documentation)
2025-07-14 09:11:34 -04:00
..
agents feat: Add webmethod for deleting openai responses (#2160) 2025-06-30 11:28:02 +02:00
batch_inference chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
benchmarks chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
common chore(api): add mypy coverage to apis (#2648) 2025-07-09 12:55:16 +02:00
datasetio chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
datasets fix: finish conversion to StrEnum (#2514) 2025-06-26 08:01:26 +05:30
eval chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
files fix: finish conversion to StrEnum (#2514) 2025-06-26 08:01:26 +05:30
inference chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
inspect chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
models fix: finish conversion to StrEnum (#2514) 2025-06-26 08:01:26 +05:30
post_training chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
providers chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
safety chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
scoring chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
scoring_functions chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
shields chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
synthetic_data_generation chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
telemetry docs: Minor spelling fix (#2592) 2025-07-02 20:26:51 -04:00
tools feat: add input validation for search mode of rag query config (#2275) 2025-07-14 09:11:34 -04:00
vector_dbs chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
vector_io chore: remove nested imports (#2515) 2025-06-26 08:01:05 +05:30
__init__.py API Updates (#73) 2024-09-17 19:51:35 -07:00
datatypes.py chore: enable pyupgrade fixes (#1806) 2025-05-01 14:23:50 -07:00
resource.py feat: drop python 3.10 support (#2469) 2025-06-19 12:07:14 +05:30
version.py llama-stack version alpha -> v1 2025-01-15 05:58:09 -08:00