Skip to content

Commit 7b8f948

Browse files
feat(api): update via SDK Studio (#68)
1 parent 1f6c6c3 commit 7b8f948

File tree

7 files changed

+61
-70
lines changed

7 files changed

+61
-70
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 46
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-194878b194cd507d7c5418ff38cc0fc53441ef618f991990d334b4b75775cd8f.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-e20c18e11af76caf98794e68406fc556cf91d13e8e27a3b1d1909a4f8c2d3eb5.yml

src/contextual/resources/generate.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ def create(
8282
messages: List of messages in the conversation so far. The last message must be from the
8383
user.
8484
85-
model: The version of the Contextual's GLM to use. Currently, we just have "v1".
85+
model: The version of the Contextual's GLM to use. Currently, we just have
86+
"ctxl-rerank-en-v1-instruct".
8687
8788
avoid_commentary: Flag to indicate whether the model should avoid providing additional commentary
8889
in responses. Commentary is conversational in nature and does not contain
@@ -188,7 +189,8 @@ async def create(
188189
messages: List of messages in the conversation so far. The last message must be from the
189190
user.
190191
191-
model: The version of the Contextual's GLM to use. Currently, we just have "v1".
192+
model: The version of the Contextual's GLM to use. Currently, we just have
193+
"ctxl-rerank-en-v1-instruct".
192194
193195
avoid_commentary: Flag to indicate whether the model should avoid providing additional commentary
194196
in responses. Commentary is conversational in nature and does not contain

src/contextual/resources/rerank.py

Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -63,38 +63,30 @@ def create(
6363
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
6464
) -> RerankCreateResponse:
6565
"""
66-
Rank a list of documents according to their relevance to a query and your custom
67-
instructions about how to prioritize retrievals. We evaluated the model on
68-
instructions for recency, document type, source, and metadata, and it can
69-
generalize to other instructions as well.
70-
71-
The total request cannot exceed 400,000 tokens. The combined length of the
72-
query, instruction and any document with its metadata must not exceed 8,000
73-
tokens. Email
66+
Rank a list of documents according to their relevance to a query.
67+
68+
The total request cannot exceed 400,000 tokens. The combined length of any
69+
document, instruction and the query must not exceed 4,000 tokens. Email
7470
[rerank-feedback@contextual.ai](mailto:rerank-feedback@contextual.ai) with any
7571
feedback or questions.
7672
7773
Args:
78-
documents: The texts to be reranked according to their relevance to the query and the
79-
optional instruction
74+
documents: The texts to be reranked according to their relevance to the query
8075
81-
model: The version of the reranker to use. Currently, we just have
82-
"ctxl-rerank-en-v1-instruct".
76+
model: The version of the reranker to use. Currently, we just have "v1".
8377
8478
query: The string against which documents will be ranked for relevance
8579
86-
instruction: Instructions that the reranker references when ranking retrievals. We evaluated
87-
the model on instructions for recency, document type, source, and metadata, and
88-
it can generalize to other instructions as well. Note that we do not guarantee
89-
that the reranker will follow these instructions exactly. Examples: "Prioritize
90-
internal sales documents over market analysis reports. More recent documents
91-
should be weighted higher. Enterprise portal content supersedes distributor
92-
communications." and "Emphasize forecasts from top-tier investment banks. Recent
93-
analysis should take precedence. Disregard aggregator sites and favor detailed
94-
research notes over news summaries."
80+
instruction: Instructions that the reranker references when ranking retrievals. Note that we
81+
do not guarantee that the reranker will follow these instructions exactly.
82+
Examples: "Prioritize internal sales documents over market analysis reports.
83+
More recent documents should be weighted higher. Enterprise portal content
84+
supersedes distributor communications." and "Emphasize forecasts from top-tier
85+
investment banks. Recent analysis should take precedence. Disregard aggregator
86+
sites and favor detailed research notes over news summaries."
9587
9688
metadata: Metadata for documents being passed to the reranker. Must be the same length as
97-
the documents list. If a document does not have metadata, add an empty string.
89+
the documents list.
9890
9991
top_n: The number of top-ranked results to return
10092
@@ -163,38 +155,30 @@ async def create(
163155
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
164156
) -> RerankCreateResponse:
165157
"""
166-
Rank a list of documents according to their relevance to a query and your custom
167-
instructions about how to prioritize retrievals. We evaluated the model on
168-
instructions for recency, document type, source, and metadata, and it can
169-
generalize to other instructions as well.
170-
171-
The total request cannot exceed 400,000 tokens. The combined length of the
172-
query, instruction and any document with its metadata must not exceed 8,000
173-
tokens. Email
158+
Rank a list of documents according to their relevance to a query.
159+
160+
The total request cannot exceed 400,000 tokens. The combined length of any
161+
document, instruction and the query must not exceed 4,000 tokens. Email
174162
[rerank-feedback@contextual.ai](mailto:rerank-feedback@contextual.ai) with any
175163
feedback or questions.
176164
177165
Args:
178-
documents: The texts to be reranked according to their relevance to the query and the
179-
optional instruction
166+
documents: The texts to be reranked according to their relevance to the query
180167
181-
model: The version of the reranker to use. Currently, we just have
182-
"ctxl-rerank-en-v1-instruct".
168+
model: The version of the reranker to use. Currently, we just have "v1".
183169
184170
query: The string against which documents will be ranked for relevance
185171
186-
instruction: Instructions that the reranker references when ranking retrievals. We evaluated
187-
the model on instructions for recency, document type, source, and metadata, and
188-
it can generalize to other instructions as well. Note that we do not guarantee
189-
that the reranker will follow these instructions exactly. Examples: "Prioritize
190-
internal sales documents over market analysis reports. More recent documents
191-
should be weighted higher. Enterprise portal content supersedes distributor
192-
communications." and "Emphasize forecasts from top-tier investment banks. Recent
193-
analysis should take precedence. Disregard aggregator sites and favor detailed
194-
research notes over news summaries."
172+
instruction: Instructions that the reranker references when ranking retrievals. Note that we
173+
do not guarantee that the reranker will follow these instructions exactly.
174+
Examples: "Prioritize internal sales documents over market analysis reports.
175+
More recent documents should be weighted higher. Enterprise portal content
176+
supersedes distributor communications." and "Emphasize forecasts from top-tier
177+
investment banks. Recent analysis should take precedence. Disregard aggregator
178+
sites and favor detailed research notes over news summaries."
195179
196180
metadata: Metadata for documents being passed to the reranker. Must be the same length as
197-
the documents list. If a document does not have metadata, add an empty string.
181+
the documents list.
198182
199183
top_n: The number of top-ranked results to return
200184

src/contextual/types/agents/query_create_params.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
from __future__ import annotations
44

55
from typing import List, Union, Iterable
6-
from typing_extensions import Literal, Required, TypeAlias, TypedDict
6+
from datetime import datetime
7+
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
8+
9+
from ..._utils import PropertyInfo
710

811
__all__ = ["QueryCreateParams", "Message", "DocumentsFilters", "DocumentsFiltersBaseMetadataFilter"]
912

@@ -104,7 +107,10 @@ class DocumentsFiltersBaseMetadataFilter(TypedDict, total=False):
104107
]
105108
"""Operator to be used for the filter."""
106109

107-
value: Union[str, float, bool, List[Union[str, float, bool]], None]
110+
value: Annotated[
111+
Union[str, Union[str, datetime], float, bool, Iterable[object], List[Union[str, float, bool]]],
112+
PropertyInfo(format="iso8601"),
113+
]
108114
"""The value to be searched for in the field.
109115
110116
In case of exists operator, it is not needed.

src/contextual/types/datastores/composite_metadata_filter_param.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
from __future__ import annotations
44

55
from typing import TYPE_CHECKING, List, Union, Iterable, Optional
6-
from typing_extensions import Literal, Required, TypeAlias, TypedDict, TypeAliasType
6+
from datetime import datetime
7+
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict, TypeAliasType
78

9+
from ..._utils import PropertyInfo
810
from ..._compat import PYDANTIC_V2
911

1012
__all__ = ["CompositeMetadataFilterParam", "Filter", "FilterBaseMetadataFilter"]
@@ -19,7 +21,10 @@ class FilterBaseMetadataFilter(TypedDict, total=False):
1921
]
2022
"""Operator to be used for the filter."""
2123

22-
value: Union[str, float, bool, List[Union[str, float, bool]], None]
24+
value: Annotated[
25+
Union[str, Union[str, datetime], float, bool, Iterable[object], List[Union[str, float, bool]]],
26+
PropertyInfo(format="iso8601"),
27+
]
2328
"""The value to be searched for in the field.
2429
2530
In case of exists operator, it is not needed.

src/contextual/types/generate_create_params.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ class GenerateCreateParams(TypedDict, total=False):
1919
"""
2020

2121
model: Required[str]
22-
"""The version of the Contextual's GLM to use. Currently, we just have "v1"."""
22+
"""The version of the Contextual's GLM to use.
23+
24+
Currently, we just have "ctxl-rerank-en-v1-instruct".
25+
"""
2326

2427
avoid_commentary: bool
2528
"""

src/contextual/types/rerank_create_params.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,29 @@
1010

1111
class RerankCreateParams(TypedDict, total=False):
1212
documents: Required[List[str]]
13-
"""
14-
The texts to be reranked according to their relevance to the query and the
15-
optional instruction
16-
"""
13+
"""The texts to be reranked according to their relevance to the query"""
1714

1815
model: Required[str]
19-
"""The version of the reranker to use.
20-
21-
Currently, we just have "ctxl-rerank-en-v1-instruct".
22-
"""
16+
"""The version of the reranker to use. Currently, we just have "v1"."""
2317

2418
query: Required[str]
2519
"""The string against which documents will be ranked for relevance"""
2620

2721
instruction: str
2822
"""Instructions that the reranker references when ranking retrievals.
2923
30-
We evaluated the model on instructions for recency, document type, source, and
31-
metadata, and it can generalize to other instructions as well. Note that we do
32-
not guarantee that the reranker will follow these instructions exactly.
33-
Examples: "Prioritize internal sales documents over market analysis reports.
34-
More recent documents should be weighted higher. Enterprise portal content
35-
supersedes distributor communications." and "Emphasize forecasts from top-tier
36-
investment banks. Recent analysis should take precedence. Disregard aggregator
37-
sites and favor detailed research notes over news summaries."
24+
Note that we do not guarantee that the reranker will follow these instructions
25+
exactly. Examples: "Prioritize internal sales documents over market analysis
26+
reports. More recent documents should be weighted higher. Enterprise portal
27+
content supersedes distributor communications." and "Emphasize forecasts from
28+
top-tier investment banks. Recent analysis should take precedence. Disregard
29+
aggregator sites and favor detailed research notes over news summaries."
3830
"""
3931

4032
metadata: List[str]
4133
"""Metadata for documents being passed to the reranker.
4234
43-
Must be the same length as the documents list. If a document does not have
44-
metadata, add an empty string.
35+
Must be the same length as the documents list.
4536
"""
4637

4738
top_n: int

0 commit comments

Comments
 (0)