Skip to content

Commit 90701fc

Browse files
author
stlc-bot
committed
feat(search): add languages filter to web search (#1833)
Stainless-Generated-From: 13105888483fa150eaf7eb68006c78a7bc4776cb
1 parent 27e1555 commit 90701fc

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎pkg/cmd/news_test.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestNewsSearch(t *testing.T) {
1818
"news", "search",
1919
"--search-by", "{entity: {domain: stripe.com, type: domain}, type: entity}",
2020
"--cursor", "cursor",
21-
"--filter-by", "{articleLanguage: [ar], articleType: [editorial], date: {from: 0, to: 0}, sourceCountry: [ae], sourceDomain: [x]}",
21+
"--filter-by", "{articleLanguage: [am], articleType: [editorial], date: {from: 0, to: 0}, sourceCountry: [ae], sourceDomain: [x]}",
2222
"--limit", "1",
2323
"--sort-by", "{type: relevance}",
2424
"--tag", "production",
@@ -38,7 +38,7 @@ func TestNewsSearch(t *testing.T) {
3838
"--search-by.entity", "{domain: stripe.com, type: domain}",
3939
"--search-by.type", "entity",
4040
"--cursor", "cursor",
41-
"--filter-by.article-language", "[ar]",
41+
"--filter-by.article-language", "[am]",
4242
"--filter-by.article-type", "[editorial]",
4343
"--filter-by.date", "{from: 0, to: 0}",
4444
"--filter-by.source-country", "[ae]",
@@ -61,7 +61,7 @@ func TestNewsSearch(t *testing.T) {
6161
"cursor: cursor\n" +
6262
"filterBy:\n" +
6363
" articleLanguage:\n" +
64-
" - ar\n" +
64+
" - am\n" +
6565
" articleType:\n" +
6666
" - editorial\n" +
6767
" date:\n" +

‎pkg/cmd/web.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,12 @@ var webSearch = requestflag.WithInnerFlags(cli.Command{
342342
Usage: `Allowlist — only return results from these domains. Up to 100 domains. Example: ["arxiv.org", "github.com"].`,
343343
BodyPath: "includeDomains",
344344
},
345+
&requestflag.Flag[any]{
346+
Name: "languages",
347+
Usage: "Languages to return results in, as BCP 47 language codes such as `en` or `de`, or \"all\" for any language. Defaults to \"all\". Example: [\"en\", \"de\"].",
348+
Default: "all",
349+
BodyPath: "languages",
350+
},
345351
&requestflag.Flag[map[string]any]{
346352
Name: "markdown-options",
347353
Usage: "Inline Markdown scraping for each result. Set `enabled: true` to activate.",

‎pkg/cmd/web_test.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ func TestWebSearch(t *testing.T) {
218218
"--freshness", "last_24_hours",
219219
"--highlights-options", "{enabled: true, maxCharacters: 100}",
220220
"--include-domain", "xxx",
221+
"--languages", "all",
221222
"--markdown-options", "{enabled: true, includeFrames: true, includeImages: true, includeLinks: true, maxAgeMs: 0, pdf: {end: 1, shouldParse: true, start: 1}, shortenBase64Images: true, timeoutOpts: {milliseconds: 1, behavior: fail}, useMainContentOnly: true, waitForMs: 0}",
222223
"--num-results", "10",
223224
"--query-fanout=true",
@@ -245,6 +246,7 @@ func TestWebSearch(t *testing.T) {
245246
"--highlights-options.enabled=true",
246247
"--highlights-options.max-characters", "100",
247248
"--include-domain", "xxx",
249+
"--languages", "all",
248250
"--markdown-options.enabled=true",
249251
"--markdown-options.include-frames=true",
250252
"--markdown-options.include-images=true",
@@ -279,6 +281,7 @@ func TestWebSearch(t *testing.T) {
279281
" maxCharacters: 100\n" +
280282
"includeDomains:\n" +
281283
" - xxx\n" +
284+
"languages: all\n" +
282285
"markdownOptions:\n" +
283286
" enabled: true\n" +
284287
" includeFrames: true\n" +

0 commit comments

Comments
 (0)