Skip to content

Commit 2830b82

Browse files
authored
docs(api): describe supported search rankers (#6395)
# What does this PR do? Adds a schema description to `SearchRankingOptions.ranker` that lists the currently supported ranking algorithms: `weighted`, `rrf`, `neural`, and `classifier`. The field remains `str | None`, so this is documentation-only and preserves acceptance of other strings for OpenAI API compatibility. A regression test verifies the generated Pydantic schema, and the checked-in OpenAPI specifications are regenerated. Closes #6176 ## Test Plan ```bash uv run ruff format --check src/ogx_api/vector_io/models.py tests/unit/providers/responses/builtin/test_openai_responses_file_search_ranking_options.py uv run ruff check src/ogx_api/vector_io/models.py tests/unit/providers/responses/builtin/test_openai_responses_file_search_ranking_options.py uv run pytest -q tests/unit/providers/responses/builtin/test_openai_responses_file_search_ranking_options.py PYTHONUTF8=1 uv run ./scripts/run_openapi_generator.sh ``` Output: ```text 2 files already formatted All checks passed! 2 passed in 0.05s Stable schema is valid Experimental schema is valid Deprecated schema is valid Combined (stainless) schema is valid OpenAPI specification generated successfully! Schemas: 430 Paths: 50 Operations: 70 { "anyOf": [{"type": "string"}, {"type": "null"}], "default": null, "description": "Name of the ranking algorithm. Supported values are weighted, rrf, neural, and classifier. Other string values are accepted for OpenAI API compatibility but are not supported.", "title": "Ranker" } ``` I also attempted the full pre-commit run twice; initialization could not fetch `pre-commit-hooks` because the GitHub connection timed out/reset. The relevant Ruff, pytest, schema validation, and generated-file checks above completed locally. --------- Signed-off-by: KXH <shepherdlaurie238@gmail.com>
1 parent 1b7234d commit 2830b82

7 files changed

Lines changed: 22 additions & 1 deletion

File tree

client-sdks/stainless/openapi.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13928,6 +13928,7 @@ components:
1392813928
anyOf:
1392913929
- type: string
1393013930
- type: 'null'
13931+
description: Name of the ranking algorithm. Supported values are "weighted", "rrf", "neural", and "classifier". Other string values are accepted for OpenAI API compatibility but are not supported.
1393113932
score_threshold:
1393213933
anyOf:
1393313934
- type: number

docs/static/deprecated-ogx-spec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7572,6 +7572,7 @@ components:
75727572
anyOf:
75737573
- type: string
75747574
- type: 'null'
7575+
description: Name of the ranking algorithm. Supported values are "weighted", "rrf", "neural", and "classifier". Other string values are accepted for OpenAI API compatibility but are not supported.
75757576
score_threshold:
75767577
anyOf:
75777578
- type: number

docs/static/experimental-ogx-spec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8942,6 +8942,7 @@ components:
89428942
anyOf:
89438943
- type: string
89448944
- type: 'null'
8945+
description: Name of the ranking algorithm. Supported values are "weighted", "rrf", "neural", and "classifier". Other string values are accepted for OpenAI API compatibility but are not supported.
89458946
score_threshold:
89468947
anyOf:
89478948
- type: number

docs/static/ogx-spec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12444,6 +12444,7 @@ components:
1244412444
anyOf:
1244512445
- type: string
1244612446
- type: 'null'
12447+
description: Name of the ranking algorithm. Supported values are "weighted", "rrf", "neural", and "classifier". Other string values are accepted for OpenAI API compatibility but are not supported.
1244712448
score_threshold:
1244812449
anyOf:
1244912450
- type: number

docs/static/stainless-ogx-spec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13928,6 +13928,7 @@ components:
1392813928
anyOf:
1392913929
- type: string
1393013930
- type: 'null'
13931+
description: Name of the ranking algorithm. Supported values are "weighted", "rrf", "neural", and "classifier". Other string values are accepted for OpenAI API compatibility but are not supported.
1393113932
score_threshold:
1393213933
anyOf:
1393313934
- type: number

src/ogx_api/vector_io/models.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,13 @@ class SearchRankingOptions(BaseModel):
506506
weights contains "neural".
507507
"""
508508

509-
ranker: str | None = None
509+
ranker: str | None = Field(
510+
default=None,
511+
description=(
512+
'Name of the ranking algorithm. Supported values are "weighted", "rrf", "neural", and '
513+
'"classifier". Other string values are accepted for OpenAI API compatibility but are not supported.'
514+
),
515+
)
510516
# NOTE: OpenAI File Search Tool requires threshold to be between 0 and 1, however
511517
# we don't guarantee that the score is between 0 and 1, so will leave this unconstrained
512518
# and let the provider handle it

tests/unit/providers/responses/builtin/test_openai_responses_file_search_ranking_options.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
from ogx_api.vector_io import SearchRankingOptions, VectorStoreSearchResponsePage
1111

1212

13+
def test_ranking_options_schema_documents_supported_rankers():
14+
"""The API schema should explain which ranker values OGX supports."""
15+
ranker_schema = SearchRankingOptions.model_json_schema()["properties"]["ranker"]
16+
17+
description = ranker_schema.get("description")
18+
assert description
19+
for ranker in ("weighted", "rrf", "neural", "classifier"):
20+
assert ranker in description
21+
22+
1323
async def test_file_search_forwards_ranking_options_weights(mock_vector_io_api):
1424
"""Test that file_search forwards ranking_options.weights to vector store search."""
1525
query = "What is machine learning?"

0 commit comments

Comments
 (0)