Skip to content

Commit b7e350b

Browse files
author
stlc-bot
committed
feat(people): add ultra mode to people search (#2149)
Stainless-Generated-From: 6741289d8fddd4ebeb2ccab1f17c4f37f6a4d04a
1 parent dcd299f commit b7e350b

4 files changed

Lines changed: 52 additions & 8 deletions

File tree

‎src/context/dev/resources/people.py‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def search(
127127
query: str,
128128
cursor: str | Omit = omit,
129129
filters: person_search_params.Filters | Omit = omit,
130+
mode: Literal["fast", "ultra"] | Omit = omit,
130131
tags: SequenceNotStr[str] | Omit = omit,
131132
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
132133
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -139,12 +140,17 @@ def search(
139140
Find people with a natural-language query.
140141
141142
Args:
142-
query: Describe the people to find.
143+
query: Describe the people to find. Up to 500 characters in `fast` mode and 5000 in
144+
`ultra` mode.
143145
144-
cursor: Use next_cursor with the same query and filters to fetch the next page.
146+
cursor: Use next_cursor with the same query, mode and filters to fetch the next page.
145147
146148
filters: Additional constraints every result must match.
147149
150+
mode: `fast` matches people on basic criteria (e.g. their role, location or
151+
background); `ultra` plans a deeper search, judges each candidate against every
152+
criterion in the query and explains each match.
153+
148154
tags: Labels for filtering usage in the dashboard.
149155
150156
extra_headers: Send extra headers
@@ -162,6 +168,7 @@ def search(
162168
"query": query,
163169
"cursor": cursor,
164170
"filters": filters,
171+
"mode": mode,
165172
"tags": tags,
166173
},
167174
person_search_params.PersonSearchParams,
@@ -275,6 +282,7 @@ async def search(
275282
query: str,
276283
cursor: str | Omit = omit,
277284
filters: person_search_params.Filters | Omit = omit,
285+
mode: Literal["fast", "ultra"] | Omit = omit,
278286
tags: SequenceNotStr[str] | Omit = omit,
279287
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
280288
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -287,12 +295,17 @@ async def search(
287295
Find people with a natural-language query.
288296
289297
Args:
290-
query: Describe the people to find.
298+
query: Describe the people to find. Up to 500 characters in `fast` mode and 5000 in
299+
`ultra` mode.
291300
292-
cursor: Use next_cursor with the same query and filters to fetch the next page.
301+
cursor: Use next_cursor with the same query, mode and filters to fetch the next page.
293302
294303
filters: Additional constraints every result must match.
295304
305+
mode: `fast` matches people on basic criteria (e.g. their role, location or
306+
background); `ultra` plans a deeper search, judges each candidate against every
307+
criterion in the query and explains each match.
308+
296309
tags: Labels for filtering usage in the dashboard.
297310
298311
extra_headers: Send extra headers
@@ -310,6 +323,7 @@ async def search(
310323
"query": query,
311324
"cursor": cursor,
312325
"filters": filters,
326+
"mode": mode,
313327
"tags": tags,
314328
},
315329
person_search_params.PersonSearchParams,

‎src/context/dev/types/person_search_params.py‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Required, TypedDict
5+
from typing_extensions import Literal, Required, TypedDict
66

77
from .._types import SequenceNotStr
88

@@ -11,14 +11,24 @@
1111

1212
class PersonSearchParams(TypedDict, total=False):
1313
query: Required[str]
14-
"""Describe the people to find."""
14+
"""Describe the people to find.
15+
16+
Up to 500 characters in `fast` mode and 5000 in `ultra` mode.
17+
"""
1518

1619
cursor: str
17-
"""Use next_cursor with the same query and filters to fetch the next page."""
20+
"""Use next_cursor with the same query, mode and filters to fetch the next page."""
1821

1922
filters: Filters
2023
"""Additional constraints every result must match."""
2124

25+
mode: Literal["fast", "ultra"]
26+
"""`fast` matches people on basic criteria (e.g.
27+
28+
their role, location or background); `ultra` plans a deeper search, judges each
29+
candidate against every criterion in the query and explains each match.
30+
"""
31+
2232
tags: SequenceNotStr[str]
2333
"""Labels for filtering usage in the dashboard."""
2434

‎src/context/dev/types/person_search_response.py‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@
44

55
from .._models import BaseModel
66

7-
__all__ = ["PersonSearchResponse", "Result", "ResultLocation", "ResultRole", "ResultRoleCompany", "KeyMetadata"]
7+
__all__ = [
8+
"PersonSearchResponse",
9+
"Result",
10+
"ResultLocation",
11+
"ResultRole",
12+
"ResultRoleCompany",
13+
"ResultMatch",
14+
"KeyMetadata",
15+
]
816

917

1018
class ResultLocation(BaseModel):
@@ -49,6 +57,13 @@ class ResultRole(BaseModel):
4957
"""Job title."""
5058

5159

60+
class ResultMatch(BaseModel):
61+
"""How well the person matches the query. Only returned in `ultra` mode."""
62+
63+
confidence: float
64+
"""How well the person matches the query, from 0 to 1."""
65+
66+
5267
class Result(BaseModel):
5368
"""A person matching your search; unavailable details are null or empty lists."""
5469

@@ -79,6 +94,9 @@ class Result(BaseModel):
7994
years_of_experience: Optional[int] = None
8095
"""Years of professional experience."""
8196

97+
match: Optional[ResultMatch] = None
98+
"""How well the person matches the query. Only returned in `ultra` mode."""
99+
82100

83101
class KeyMetadata(BaseModel):
84102
"""Credits this request used and your remaining balance."""

‎tests/api_resources/test_people.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def test_method_search_with_all_params(self, client: ContextDev) -> None:
103103
"years_of_experience_max": 0,
104104
"years_of_experience_min": 0,
105105
},
106+
mode="fast",
106107
tags=["production", "team-alpha"],
107108
)
108109
assert_matches_type(PersonSearchResponse, person, path=["response"])
@@ -225,6 +226,7 @@ async def test_method_search_with_all_params(self, async_client: AsyncContextDev
225226
"years_of_experience_max": 0,
226227
"years_of_experience_min": 0,
227228
},
229+
mode="fast",
228230
tags=["production", "team-alpha"],
229231
)
230232
assert_matches_type(PersonSearchResponse, person, path=["response"])

0 commit comments

Comments
 (0)