Skip to content

Commit f9d3393

Browse files
author
stlc-bot
committed
feat(people): add ultra mode to people search (#2149)
Stainless-Generated-From: 5fe492dcbb4061b33f808123b87e3a784a0be89e
1 parent 622d0c3 commit f9d3393

9 files changed

Lines changed: 208 additions & 21 deletions

File tree

‎lib/context_dev/models/person_search_params.rb‎

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ class PersonSearchParams < ContextDev::Internal::Type::BaseModel
88
include ContextDev::Internal::Type::RequestParameters
99

1010
# @!attribute query
11-
# Describe the people to find.
11+
# Describe the people to find. Up to 500 characters in `fast` mode and 5000 in
12+
# `ultra` mode.
1213
#
1314
# @return [String]
1415
required :query, String
1516

1617
# @!attribute cursor
17-
# Use next_cursor with the same query and filters to fetch the next page.
18+
# Use next_cursor with the same query, mode and filters to fetch the next page.
1819
#
1920
# @return [String, nil]
2021
optional :cursor, String
@@ -25,19 +26,32 @@ class PersonSearchParams < ContextDev::Internal::Type::BaseModel
2526
# @return [ContextDev::Models::PersonSearchParams::Filters, nil]
2627
optional :filters, -> { ContextDev::PersonSearchParams::Filters }
2728

29+
# @!attribute mode
30+
# `fast` matches people on basic criteria (e.g. their role, location or
31+
# background); `ultra` plans a deeper search, judges each candidate against every
32+
# criterion in the query and explains each match.
33+
#
34+
# @return [Symbol, ContextDev::Models::PersonSearchParams::Mode, nil]
35+
optional :mode, enum: -> { ContextDev::PersonSearchParams::Mode }
36+
2837
# @!attribute tags
2938
# Labels for filtering usage in the dashboard.
3039
#
3140
# @return [Array<String>, nil]
3241
optional :tags, ContextDev::Internal::Type::ArrayOf[String]
3342

34-
# @!method initialize(query:, cursor: nil, filters: nil, tags: nil, request_options: {})
35-
# @param query [String] Describe the people to find.
43+
# @!method initialize(query:, cursor: nil, filters: nil, mode: nil, tags: nil, request_options: {})
44+
# Some parameter documentations has been truncated, see
45+
# {ContextDev::Models::PersonSearchParams} for more details.
3646
#
37-
# @param cursor [String] Use next_cursor with the same query and filters to fetch the next page.
47+
# @param query [String] Describe the people to find. Up to 500 characters in `fast` mode and 5000 in `ul
48+
#
49+
# @param cursor [String] Use next_cursor with the same query, mode and filters to fetch the next page.
3850
#
3951
# @param filters [ContextDev::Models::PersonSearchParams::Filters] Additional constraints every result must match.
4052
#
53+
# @param mode [Symbol, ContextDev::Models::PersonSearchParams::Mode] `fast` matches people on basic criteria (e.g. their role, location or background
54+
#
4155
# @param tags [Array<String>] Labels for filtering usage in the dashboard.
4256
#
4357
# @param request_options [ContextDev::RequestOptions, Hash{Symbol=>Object}]
@@ -70,6 +84,19 @@ class Filters < ContextDev::Internal::Type::BaseModel
7084
#
7185
# @param years_of_experience_min [Integer] Minimum years of professional experience.
7286
end
87+
88+
# `fast` matches people on basic criteria (e.g. their role, location or
89+
# background); `ultra` plans a deeper search, judges each candidate against every
90+
# criterion in the query and explains each match.
91+
module Mode
92+
extend ContextDev::Internal::Type::Enum
93+
94+
FAST = :fast
95+
ULTRA = :ultra
96+
97+
# @!method self.values
98+
# @return [Array<Symbol>]
99+
end
73100
end
74101
end
75102
end

‎lib/context_dev/models/person_search_response.rb‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@ class Result < ContextDev::Internal::Type::BaseModel
9797
# @return [Integer, nil]
9898
required :years_of_experience, Integer, nil?: true
9999

100-
# @!method initialize(description:, is_founder:, location:, name:, profiles:, role:, schools:, skills:, years_of_experience:)
100+
# @!attribute match
101+
# How well the person matches the query. Only returned in `ultra` mode.
102+
#
103+
# @return [ContextDev::Models::PersonSearchResponse::Result::Match, nil]
104+
optional :match, -> { ContextDev::Models::PersonSearchResponse::Result::Match }
105+
106+
# @!method initialize(description:, is_founder:, location:, name:, profiles:, role:, schools:, skills:, years_of_experience:, match: nil)
101107
# A person matching your search; unavailable details are null or empty lists.
102108
#
103109
# @param description [String, nil] What the person does.
@@ -117,6 +123,8 @@ class Result < ContextDev::Internal::Type::BaseModel
117123
# @param skills [Array<String>] Professional skills.
118124
#
119125
# @param years_of_experience [Integer, nil] Years of professional experience.
126+
#
127+
# @param match [ContextDev::Models::PersonSearchResponse::Result::Match] How well the person matches the query. Only returned in `ultra` mode.
120128

121129
# @see ContextDev::Models::PersonSearchResponse::Result#location
122130
class Location < ContextDev::Internal::Type::BaseModel
@@ -215,6 +223,20 @@ class Company < ContextDev::Internal::Type::BaseModel
215223
# @param name [String, nil] Company name.
216224
end
217225
end
226+
227+
# @see ContextDev::Models::PersonSearchResponse::Result#match
228+
class Match < ContextDev::Internal::Type::BaseModel
229+
# @!attribute confidence
230+
# How well the person matches the query, from 0 to 1.
231+
#
232+
# @return [Float]
233+
required :confidence, Float
234+
235+
# @!method initialize(confidence:)
236+
# How well the person matches the query. Only returned in `ultra` mode.
237+
#
238+
# @param confidence [Float] How well the person matches the query, from 0 to 1.
239+
end
218240
end
219241

220242
# @see ContextDev::Models::PersonSearchResponse#key_metadata

‎lib/context_dev/resources/people.rb‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,21 @@ def enrich(params = {})
4545
)
4646
end
4747

48+
# Some parameter documentations has been truncated, see
49+
# {ContextDev::Models::PersonSearchParams} for more details.
50+
#
4851
# Find people with a natural-language query.
4952
#
50-
# @overload search(query:, cursor: nil, filters: nil, tags: nil, request_options: {})
53+
# @overload search(query:, cursor: nil, filters: nil, mode: nil, tags: nil, request_options: {})
5154
#
52-
# @param query [String] Describe the people to find.
55+
# @param query [String] Describe the people to find. Up to 500 characters in `fast` mode and 5000 in `ul
5356
#
54-
# @param cursor [String] Use next_cursor with the same query and filters to fetch the next page.
57+
# @param cursor [String] Use next_cursor with the same query, mode and filters to fetch the next page.
5558
#
5659
# @param filters [ContextDev::Models::PersonSearchParams::Filters] Additional constraints every result must match.
5760
#
61+
# @param mode [Symbol, ContextDev::Models::PersonSearchParams::Mode] `fast` matches people on basic criteria (e.g. their role, location or background
62+
#
5863
# @param tags [Array<String>] Labels for filtering usage in the dashboard.
5964
#
6065
# @param request_options [ContextDev::RequestOptions, Hash{Symbol=>Object}, nil]

‎rbi/context_dev/models/person_search_params.rbi‎

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ module ContextDev
1111
T.any(ContextDev::PersonSearchParams, ContextDev::Internal::AnyHash)
1212
end
1313

14-
# Describe the people to find.
14+
# Describe the people to find. Up to 500 characters in `fast` mode and 5000 in
15+
# `ultra` mode.
1516
sig { returns(String) }
1617
attr_accessor :query
1718

18-
# Use next_cursor with the same query and filters to fetch the next page.
19+
# Use next_cursor with the same query, mode and filters to fetch the next page.
1920
sig { returns(T.nilable(String)) }
2021
attr_reader :cursor
2122

@@ -31,6 +32,15 @@ module ContextDev
3132
end
3233
attr_writer :filters
3334

35+
# `fast` matches people on basic criteria (e.g. their role, location or
36+
# background); `ultra` plans a deeper search, judges each candidate against every
37+
# criterion in the query and explains each match.
38+
sig { returns(T.nilable(ContextDev::PersonSearchParams::Mode::OrSymbol)) }
39+
attr_reader :mode
40+
41+
sig { params(mode: ContextDev::PersonSearchParams::Mode::OrSymbol).void }
42+
attr_writer :mode
43+
3444
# Labels for filtering usage in the dashboard.
3545
sig { returns(T.nilable(T::Array[String])) }
3646
attr_reader :tags
@@ -43,17 +53,23 @@ module ContextDev
4353
query: String,
4454
cursor: String,
4555
filters: ContextDev::PersonSearchParams::Filters::OrHash,
56+
mode: ContextDev::PersonSearchParams::Mode::OrSymbol,
4657
tags: T::Array[String],
4758
request_options: ContextDev::RequestOptions::OrHash
4859
).returns(T.attached_class)
4960
end
5061
def self.new(
51-
# Describe the people to find.
62+
# Describe the people to find. Up to 500 characters in `fast` mode and 5000 in
63+
# `ultra` mode.
5264
query:,
53-
# Use next_cursor with the same query and filters to fetch the next page.
65+
# Use next_cursor with the same query, mode and filters to fetch the next page.
5466
cursor: nil,
5567
# Additional constraints every result must match.
5668
filters: nil,
69+
# `fast` matches people on basic criteria (e.g. their role, location or
70+
# background); `ultra` plans a deeper search, judges each candidate against every
71+
# criterion in the query and explains each match.
72+
mode: nil,
5773
# Labels for filtering usage in the dashboard.
5874
tags: nil,
5975
request_options: {}
@@ -66,6 +82,7 @@ module ContextDev
6682
query: String,
6783
cursor: String,
6884
filters: ContextDev::PersonSearchParams::Filters,
85+
mode: ContextDev::PersonSearchParams::Mode::OrSymbol,
6986
tags: T::Array[String],
7087
request_options: ContextDev::RequestOptions
7188
}
@@ -134,6 +151,29 @@ module ContextDev
134151
def to_hash
135152
end
136153
end
154+
155+
# `fast` matches people on basic criteria (e.g. their role, location or
156+
# background); `ultra` plans a deeper search, judges each candidate against every
157+
# criterion in the query and explains each match.
158+
module Mode
159+
extend ContextDev::Internal::Type::Enum
160+
161+
TaggedSymbol =
162+
T.type_alias { T.all(Symbol, ContextDev::PersonSearchParams::Mode) }
163+
OrSymbol = T.type_alias { T.any(Symbol, String) }
164+
165+
FAST = T.let(:fast, ContextDev::PersonSearchParams::Mode::TaggedSymbol)
166+
ULTRA =
167+
T.let(:ultra, ContextDev::PersonSearchParams::Mode::TaggedSymbol)
168+
169+
sig do
170+
override.returns(
171+
T::Array[ContextDev::PersonSearchParams::Mode::TaggedSymbol]
172+
)
173+
end
174+
def self.values
175+
end
176+
end
137177
end
138178
end
139179
end

‎rbi/context_dev/models/person_search_response.rbi‎

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,22 @@ module ContextDev
140140
sig { returns(T.nilable(Integer)) }
141141
attr_accessor :years_of_experience
142142

143+
# How well the person matches the query. Only returned in `ultra` mode.
144+
sig do
145+
returns(
146+
T.nilable(ContextDev::Models::PersonSearchResponse::Result::Match)
147+
)
148+
end
149+
attr_reader :match
150+
151+
sig do
152+
params(
153+
match:
154+
ContextDev::Models::PersonSearchResponse::Result::Match::OrHash
155+
).void
156+
end
157+
attr_writer :match
158+
143159
# A person matching your search; unavailable details are null or empty lists.
144160
sig do
145161
params(
@@ -153,7 +169,9 @@ module ContextDev
153169
ContextDev::Models::PersonSearchResponse::Result::Role::OrHash,
154170
schools: T::Array[String],
155171
skills: T::Array[String],
156-
years_of_experience: T.nilable(Integer)
172+
years_of_experience: T.nilable(Integer),
173+
match:
174+
ContextDev::Models::PersonSearchResponse::Result::Match::OrHash
157175
).returns(T.attached_class)
158176
end
159177
def self.new(
@@ -174,7 +192,9 @@ module ContextDev
174192
# Professional skills.
175193
skills:,
176194
# Years of professional experience.
177-
years_of_experience:
195+
years_of_experience:,
196+
# How well the person matches the query. Only returned in `ultra` mode.
197+
match: nil
178198
)
179199
end
180200

@@ -190,7 +210,8 @@ module ContextDev
190210
role: ContextDev::Models::PersonSearchResponse::Result::Role,
191211
schools: T::Array[String],
192212
skills: T::Array[String],
193-
years_of_experience: T.nilable(Integer)
213+
years_of_experience: T.nilable(Integer),
214+
match: ContextDev::Models::PersonSearchResponse::Result::Match
194215
}
195216
)
196217
end
@@ -379,6 +400,32 @@ module ContextDev
379400
end
380401
end
381402
end
403+
404+
class Match < ContextDev::Internal::Type::BaseModel
405+
OrHash =
406+
T.type_alias do
407+
T.any(
408+
ContextDev::Models::PersonSearchResponse::Result::Match,
409+
ContextDev::Internal::AnyHash
410+
)
411+
end
412+
413+
# How well the person matches the query, from 0 to 1.
414+
sig { returns(Float) }
415+
attr_accessor :confidence
416+
417+
# How well the person matches the query. Only returned in `ultra` mode.
418+
sig { params(confidence: Float).returns(T.attached_class) }
419+
def self.new(
420+
# How well the person matches the query, from 0 to 1.
421+
confidence:
422+
)
423+
end
424+
425+
sig { override.returns({ confidence: Float }) }
426+
def to_hash
427+
end
428+
end
382429
end
383430

384431
class KeyMetadata < ContextDev::Internal::Type::BaseModel

‎rbi/context_dev/resources/people.rbi‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,23 @@ module ContextDev
5353
query: String,
5454
cursor: String,
5555
filters: ContextDev::PersonSearchParams::Filters::OrHash,
56+
mode: ContextDev::PersonSearchParams::Mode::OrSymbol,
5657
tags: T::Array[String],
5758
request_options: ContextDev::RequestOptions::OrHash
5859
).returns(ContextDev::Models::PersonSearchResponse)
5960
end
6061
def search(
61-
# Describe the people to find.
62+
# Describe the people to find. Up to 500 characters in `fast` mode and 5000 in
63+
# `ultra` mode.
6264
query:,
63-
# Use next_cursor with the same query and filters to fetch the next page.
65+
# Use next_cursor with the same query, mode and filters to fetch the next page.
6466
cursor: nil,
6567
# Additional constraints every result must match.
6668
filters: nil,
69+
# `fast` matches people on basic criteria (e.g. their role, location or
70+
# background); `ultra` plans a deeper search, judges each candidate against every
71+
# criterion in the query and explains each match.
72+
mode: nil,
6773
# Labels for filtering usage in the dashboard.
6874
tags: nil,
6975
request_options: {}

0 commit comments

Comments
 (0)