Skip to content

Commit de2c445

Browse files
feat(api): manual updates
1 parent f6e516b commit de2c445

File tree

15 files changed

+122
-33
lines changed

15 files changed

+122
-33
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ dist
77
dist-deno
88
/*.tgz
99
.idea/
10+
.eslintcache
1011

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 14
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zeroentropy%2Fzeroentropy-bd2f55f423e09b74f83cbad6034fb76f7052363308d02533a908b49543cff459.yml
3-
openapi_spec_hash: 6d7566ebda7fecac4069744949d547e0
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zeroentropy%2Fzeroentropy-c95681b13dc56e64126746c6e546b564c7f802ae567fc9ccc1aeb8eddd40bb1e.yml
3+
openapi_spec_hash: 2ac723122fe938e384f11b5cf19e85ec
44
config_hash: e07cdee04c971e1db74e91a5a4cd981c

scripts/bootstrap

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ set -e
44

55
cd "$(dirname "$0")/.."
66

7-
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then
7+
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then
88
brew bundle check >/dev/null 2>&1 || {
9-
echo "==> Installing Homebrew dependencies…"
10-
brew bundle
9+
echo -n "==> Install Homebrew dependencies? (y/N): "
10+
read -r response
11+
case "$response" in
12+
[yY][eE][sS]|[yY])
13+
brew bundle
14+
;;
15+
*)
16+
;;
17+
esac
18+
echo
1119
}
1220
fi
1321

scripts/fast-format

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
echo "Script started with $# arguments"
6+
echo "Arguments: $*"
7+
echo "Script location: $(dirname "$0")"
8+
9+
cd "$(dirname "$0")/.."
10+
echo "Changed to directory: $(pwd)"
11+
12+
if [ $# -eq 0 ]; then
13+
echo "Usage: $0 <file-with-paths> [additional-formatter-args...]"
14+
echo "The file should contain one file path per line"
15+
exit 1
16+
fi
17+
18+
FILE_LIST="$1"
19+
20+
echo "Looking for file: $FILE_LIST"
21+
22+
if [ ! -f "$FILE_LIST" ]; then
23+
echo "Error: File '$FILE_LIST' not found"
24+
exit 1
25+
fi
26+
27+
echo "==> Running eslint --fix"
28+
ESLINT_FILES="$(grep '\.ts$' "$FILE_LIST" || true)"
29+
if ! [ -z "$ESLINT_FILES" ]; then
30+
echo "$ESLINT_FILES" | ESLINT_USE_FLAT_CONFIG="false" xargs ./node_modules/.bin/eslint --cache --fix
31+
fi
32+
33+
echo "==> Running prettier --write"
34+
# format things eslint didn't
35+
PRETTIER_FILES="$(grep '\.\(js\|json\)$' "$FILE_LIST" || true)"
36+
if ! [ -z "$PRETTIER_FILES" ]; then
37+
echo "$PRETTIER_FILES" | xargs ./node_modules/.bin/prettier \
38+
--write --cache --cache-strategy metadata --no-error-on-unmatched-pattern \
39+
'!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs'
40+
fi

scripts/utils/upload-artifact.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ if [[ "$SIGNED_URL" == "null" ]]; then
1212
exit 1
1313
fi
1414

15-
UPLOAD_RESPONSE=$(tar "${BASE_PATH:+-C$BASE_PATH}" -cz "${ARTIFACT_PATH:-dist}" | curl -v -X PUT \
15+
TARBALL=$(cd dist && npm pack --silent)
16+
17+
UPLOAD_RESPONSE=$(curl -v -X PUT \
1618
-H "Content-Type: application/gzip" \
17-
--data-binary @- "$SIGNED_URL" 2>&1)
19+
--data-binary "@dist/$TARBALL" "$SIGNED_URL" 2>&1)
1820

1921
if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then
2022
echo -e "\033[32mUploaded build to Stainless storage.\033[0m"

src/core.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,21 +1088,21 @@ export const coerceBoolean = (value: unknown): boolean => {
10881088
};
10891089

10901090
export const maybeCoerceInteger = (value: unknown): number | undefined => {
1091-
if (value === undefined) {
1091+
if (value == null) {
10921092
return undefined;
10931093
}
10941094
return coerceInteger(value);
10951095
};
10961096

10971097
export const maybeCoerceFloat = (value: unknown): number | undefined => {
1098-
if (value === undefined) {
1098+
if (value == null) {
10991099
return undefined;
11001100
}
11011101
return coerceFloat(value);
11021102
};
11031103

11041104
export const maybeCoerceBoolean = (value: unknown): boolean | undefined => {
1105-
if (value === undefined) {
1105+
if (value == null) {
11061106
return undefined;
11071107
}
11081108
return coerceBoolean(value);

src/resources/collections.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ export interface CollectionAddParams {
7272
* exceed 1024 bytes.
7373
*/
7474
collection_name: string;
75+
76+
/**
77+
* [ADVANCED] The number of shards to use for this collection. By using K shards,
78+
* your documents can index with K times more throughput. However, queries will be
79+
* automatically sent to all K shards and then aggregated. For large collections,
80+
* this can make queries faster. But for small collections, this will make queries
81+
* slower. `num_shards` must be one of [1, 8, 16, 32, 64]. The default is 1.
82+
*/
83+
num_shards?: number;
7584
}
7685

7786
export interface CollectionGetListParams {}

src/resources/documents.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export class Documents extends APIResource {
1414
* `index_status` of `indexed`. After this call, the document will have an
1515
* `index_status` of `not_indexed`, since the document will need to reindex with
1616
* the new metadata.
17-
* - When updating with a non-null `index_status`, setting it to
18-
* `not_parsed or `not_indexed`requires that the document must have`index_status`of`parsing_failed`or`indexing_failed`,
19-
* respectively.
17+
* - When updating with a non-null `index_status`, setting it to `not_parsed` or
18+
* `not_indexed` requires that the document must have `index_status` of
19+
* `parsing_failed` or `indexing_failed`, respectively.
2020
*
2121
* A `404 Not Found` status code will be returned, if the provided collection name
2222
* or document path does not exist.
@@ -373,9 +373,11 @@ export namespace DocumentAddParams {
373373
pages: Array<string>;
374374

375375
/**
376-
* This field must be `text-pages`
376+
* This field must be `text-pages` or `text-pages-unordered`. When `unordered` is
377+
* provided, it is assumed that consecutive pages aren't meant to be read one after
378+
* another. For example, PDFs are ordered, and CSVs are unordered.
377379
*/
378-
type: 'text-pages';
380+
type: 'text-pages' | 'text-pages-unordered';
379381
}
380382

381383
export interface APIBinaryDocument {

src/resources/models.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@ export class Models extends APIResource {
1010
* The results will be sorted by descending order of relevance. For each document,
1111
* the index and the score will be returned. The index is relative to the documents
1212
* array that was passed in. The score is the query-document relevancy determined
13-
* by the reranker model. The value will be returned in descending order to
13+
* by the reranker model. The results will be returned in descending order of
1414
* relevance.
15+
*
16+
* Organizations will, by default, have a ratelimit of `2,500,000`
17+
* bytes-per-minute. If this is exceeded, requests will be throttled into
18+
* `latency: "slow"` mode, up to `10,000,000` bytes-per-minute. If even this is
19+
* exceeded, you will get a `429` error. To request higher ratelimits, please
20+
* contact [founders@zeroentropy.dev](mailto:founders@zeroentropy.dev) or message
21+
* us on [Discord](https://go.zeroentropy.dev/discord) or
22+
* [Slack](https://go.zeroentropy.dev/slack)!
1523
*/
1624
rerank(body: ModelRerankParams, options?: Core.RequestOptions): Core.APIPromise<ModelRerankResponse> {
1725
return this._client.post('/models/rerank', { body, ...options });
@@ -36,8 +44,8 @@ export namespace ModelRerankResponse {
3644
/**
3745
* The relevance score between this document and the query. This number will range
3846
* between 0.0 and 1.0. This score is dependent on only the query and the scored
39-
* document; other documents do not affect this score. This value is deterministic,
40-
* but may vary slightly due to floating point error.
47+
* document; other documents do not affect this score. This value is intended to be
48+
* deterministic, but it may vary slightly due to floating point error.
4149
*/
4250
relevance_score: number;
4351
}
@@ -50,19 +58,29 @@ export interface ModelRerankParams {
5058
documents: Array<string>;
5159

5260
/**
53-
* The query to rerank the documents by. Results will be in descending order of
54-
* relevance.
61+
* The model ID to use for reranking. Options are: ["zerank-2", "zerank-1",
62+
* "zerank-1-small"]
63+
*/
64+
model: string;
65+
66+
/**
67+
* The query to rerank the documents by.
5568
*/
5669
query: string;
5770

5871
/**
59-
* The model ID to use for reranking. Options are: ["zerank-1-large"]
72+
* Whether the call will be inferenced "fast" or "slow". RateLimits for slow API
73+
* calls are orders of magnitude higher, but you can expect >10 second latency.
74+
* Fast inferences are guaranteed subsecond, but rate limits are lower. If not
75+
* specified, first a "fast" call will be attempted, but if you have exceeded your
76+
* fast rate limit, then a slow call will be executed. If explicitly set to "fast",
77+
* then 429 will be returned if it cannot be executed fast.
6078
*/
61-
model?: string;
79+
latency?: 'fast' | 'slow' | null;
6280

6381
/**
6482
* If provided, then only the top `n` documents will be returned in the results
65-
* array.
83+
* array. Otherwise, `n` will be the length of the provided documents array.
6684
*/
6785
top_n?: number | null;
6886
}

src/resources/queries.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,11 @@ export interface QueryTopDocumentsParams {
215215

216216
/**
217217
* The natural language query to search with. This cannot exceed 4096 UTF-8 bytes.
218+
* If `null`, then the sort will be undefined. The purpose of `null` is to do
219+
* faster metadata filter searches without care for relevancy. Cost per query is
220+
* unchanged.
218221
*/
219-
query: string;
222+
query: string | null;
220223

221224
/**
222225
* The query filter to apply. Please read [Metadata Filtering](/metadata-filtering)

0 commit comments

Comments
 (0)