Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ dist
dist-deno
/*.tgz
.idea/
.eslintcache

2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.6"
".": "0.1.0-alpha.7"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 14
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zeroentropy%2Fzeroentropy-bd2f55f423e09b74f83cbad6034fb76f7052363308d02533a908b49543cff459.yml
openapi_spec_hash: 6d7566ebda7fecac4069744949d547e0
config_hash: e07cdee04c971e1db74e91a5a4cd981c
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zeroentropy%2Fzeroentropy-c95681b13dc56e64126746c6e546b564c7f802ae567fc9ccc1aeb8eddd40bb1e.yml
openapi_spec_hash: 2ac723122fe938e384f11b5cf19e85ec
config_hash: 3be2ee54cbc850c508c90b9ffae2efe5
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## 0.1.0-alpha.7 (2025-11-24)

Full Changelog: [v0.1.0-alpha.6...v0.1.0-alpha.7](https://github.com/zeroentropy-ai/zeroentropy-node/compare/v0.1.0-alpha.6...v0.1.0-alpha.7)

### Features

* **api:** manual updates ([de2c445](https://github.com/zeroentropy-ai/zeroentropy-node/commit/de2c4458b3a9fc3a6bc66b3e34d3db411d5ca6cd))


### Chores

* ci build action ([f6e516b](https://github.com/zeroentropy-ai/zeroentropy-node/commit/f6e516bafe89d3d501a111e64a01684588606d41))
* **deps:** update dependency node-fetch to v2.6.13 ([b514540](https://github.com/zeroentropy-ai/zeroentropy-node/commit/b514540dad74b0359060b3427407f53276f94209))
* **internal:** formatting change ([f08028e](https://github.com/zeroentropy-ai/zeroentropy-node/commit/f08028ecf081a78515aa37d5a8f31d89bcc5ec12))
* **internal:** move publish config ([0819835](https://github.com/zeroentropy-ai/zeroentropy-node/commit/0819835ac68f52cc71834e770bab910f9db38eb8))
* **internal:** remove redundant imports config ([8044b42](https://github.com/zeroentropy-ai/zeroentropy-node/commit/8044b42a7e1860b59633b1c1eea41aecd0761f1a))
* **internal:** update comment in script ([90782a4](https://github.com/zeroentropy-ai/zeroentropy-node/commit/90782a460c764624013f0cd0025c15c6ddc7a69f))
* make some internal functions async ([9722ec8](https://github.com/zeroentropy-ai/zeroentropy-node/commit/9722ec887e08667e0c2ffabe3b0e6e5390187da2))
* update @stainless-api/prism-cli to v5.15.0 ([16c797e](https://github.com/zeroentropy-ai/zeroentropy-node/commit/16c797edaf4fc82dad985a6b8363c26d99da934a))
* update CI script ([96de540](https://github.com/zeroentropy-ai/zeroentropy-node/commit/96de540a48b20d9e3b5abfed353056d2aca48de7))

## 0.1.0-alpha.6 (2025-07-08)

Full Changelog: [v0.1.0-alpha.5...v0.1.0-alpha.6](https://github.com/zeroentropy-ai/zeroentropy-node/compare/v0.1.0-alpha.5...v0.1.0-alpha.6)
Expand Down
2 changes: 1 addition & 1 deletion bin/publish-npm
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ else
fi

# Publish with the appropriate tag
yarn publish --access public --tag "$TAG"
yarn publish --tag "$TAG"
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zeroentropy",
"version": "0.1.0-alpha.6",
"version": "0.1.0-alpha.7",
"description": "The official TypeScript library for the ZeroEntropy API",
"author": "ZeroEntropy <founders@zeroentropy.dev>",
"types": "dist/index.d.ts",
Expand All @@ -13,6 +13,9 @@
"**/*"
],
"private": false,
"publishConfig": {
"access": "public"
},
"scripts": {
"test": "./scripts/test",
"build": "./scripts/build",
Expand Down Expand Up @@ -58,10 +61,6 @@
"./shims/web.js",
"./shims/web.mjs"
],
"imports": {
"zeroentropy": ".",
"zeroentropy/*": "./src/*"
},
"exports": {
"./_shims/auto/*": {
"deno": {
Expand Down
14 changes: 11 additions & 3 deletions scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ set -e

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

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then
brew bundle check >/dev/null 2>&1 || {
echo "==> Installing Homebrew dependencies…"
brew bundle
echo -n "==> Install Homebrew dependencies? (y/N): "
read -r response
case "$response" in
[yY][eE][sS]|[yY])
brew bundle
;;
*)
;;
esac
echo
}
fi

Expand Down
40 changes: 40 additions & 0 deletions scripts/fast-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

set -euo pipefail

echo "Script started with $# arguments"
echo "Arguments: $*"
echo "Script location: $(dirname "$0")"

cd "$(dirname "$0")/.."
echo "Changed to directory: $(pwd)"

if [ $# -eq 0 ]; then
echo "Usage: $0 <file-with-paths> [additional-formatter-args...]"
echo "The file should contain one file path per line"
exit 1
fi

FILE_LIST="$1"

echo "Looking for file: $FILE_LIST"

if [ ! -f "$FILE_LIST" ]; then
echo "Error: File '$FILE_LIST' not found"
exit 1
fi

echo "==> Running eslint --fix"
ESLINT_FILES="$(grep '\.ts$' "$FILE_LIST" || true)"
if ! [ -z "$ESLINT_FILES" ]; then
echo "$ESLINT_FILES" | ESLINT_USE_FLAT_CONFIG="false" xargs ./node_modules/.bin/eslint --cache --fix
fi

echo "==> Running prettier --write"
# format things eslint didn't
PRETTIER_FILES="$(grep '\.\(js\|json\)$' "$FILE_LIST" || true)"
if ! [ -z "$PRETTIER_FILES" ]; then
echo "$PRETTIER_FILES" | xargs ./node_modules/.bin/prettier \
--write --cache --cache-strategy metadata --no-error-on-unmatched-pattern \
'!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs'
fi
4 changes: 2 additions & 2 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
if [ "$1" == "--daemon" ]; then
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" &> .prism.log &
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &

# Wait for server to come online
echo -n "Waiting for server"
Expand All @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then

echo
else
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL"
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL"
fi
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ elif ! prism_is_running ; then
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the prism command:"
echo
echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}"
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}"
echo

exit 1
Expand Down
6 changes: 4 additions & 2 deletions scripts/utils/upload-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ if [[ "$SIGNED_URL" == "null" ]]; then
exit 1
fi

UPLOAD_RESPONSE=$(tar -cz dist | curl -v -X PUT \
TARBALL=$(cd dist && npm pack --silent)

UPLOAD_RESPONSE=$(curl -v -X PUT \
-H "Content-Type: application/gzip" \
--data-binary @- "$SIGNED_URL" 2>&1)
--data-binary "@dist/$TARBALL" "$SIGNED_URL" 2>&1)

if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then
echo -e "\033[32mUploaded build to Stainless storage.\033[0m"
Expand Down
14 changes: 8 additions & 6 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,10 @@ export abstract class APIClient {
return null;
}

buildRequest<Req>(
async buildRequest<Req>(
inputOptions: FinalRequestOptions<Req>,
{ retryCount = 0 }: { retryCount?: number } = {},
): { req: RequestInit; url: string; timeout: number } {
): Promise<{ req: RequestInit; url: string; timeout: number }> {
const options = { ...inputOptions };
const { method, path, query, defaultBaseURL, headers: headers = {} } = options;

Expand Down Expand Up @@ -450,7 +450,9 @@ export abstract class APIClient {

await this.prepareOptions(options);

const { req, url, timeout } = this.buildRequest(options, { retryCount: maxRetries - retriesRemaining });
const { req, url, timeout } = await this.buildRequest(options, {
retryCount: maxRetries - retriesRemaining,
});

await this.prepareRequest(req, { url, options });

Expand Down Expand Up @@ -1086,21 +1088,21 @@ export const coerceBoolean = (value: unknown): boolean => {
};

export const maybeCoerceInteger = (value: unknown): number | undefined => {
if (value === undefined) {
if (value == null) {
return undefined;
}
return coerceInteger(value);
};

export const maybeCoerceFloat = (value: unknown): number | undefined => {
if (value === undefined) {
if (value == null) {
return undefined;
}
return coerceFloat(value);
};

export const maybeCoerceBoolean = (value: unknown): boolean | undefined => {
if (value === undefined) {
if (value == null) {
return undefined;
}
return coerceBoolean(value);
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ ZeroEntropy.DocumentGetInfoListResponsesGetDocumentInfoListCursor =
DocumentGetInfoListResponsesGetDocumentInfoListCursor;
ZeroEntropy.Queries = Queries;
ZeroEntropy.Models = Models;

export declare namespace ZeroEntropy {
export type RequestOptions = Core.RequestOptions;

Expand Down
9 changes: 9 additions & 0 deletions src/resources/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ export interface CollectionAddParams {
* exceed 1024 bytes.
*/
collection_name: string;

/**
* [ADVANCED] The number of shards to use for this collection. By using K shards,
* your documents can index with K times more throughput. However, queries will be
* automatically sent to all K shards and then aggregated. For large collections,
* this can make queries faster. But for small collections, this will make queries
* slower. `num_shards` must be one of [1, 8, 16, 32, 64]. The default is 1.
*/
num_shards?: number;
}

export interface CollectionGetListParams {}
Expand Down
12 changes: 7 additions & 5 deletions src/resources/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export class Documents extends APIResource {
* `index_status` of `indexed`. After this call, the document will have an
* `index_status` of `not_indexed`, since the document will need to reindex with
* the new metadata.
* - When updating with a non-null `index_status`, setting it to
* `not_parsed or `not_indexed`requires that the document must have`index_status`of`parsing_failed`or`indexing_failed`,
* respectively.
* - When updating with a non-null `index_status`, setting it to `not_parsed` or
* `not_indexed` requires that the document must have `index_status` of
* `parsing_failed` or `indexing_failed`, respectively.
*
* A `404 Not Found` status code will be returned, if the provided collection name
* or document path does not exist.
Expand Down Expand Up @@ -373,9 +373,11 @@ export namespace DocumentAddParams {
pages: Array<string>;

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

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

/**
* The query to rerank the documents by. Results will be in descending order of
* relevance.
* The model ID to use for reranking. Options are: ["zerank-2", "zerank-1",
* "zerank-1-small"]
*/
model: string;

/**
* The query to rerank the documents by.
*/
query: string;

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

/**
* If provided, then only the top `n` documents will be returned in the results
* array.
* array. Otherwise, `n` will be the length of the provided documents array.
*/
top_n?: number | null;
}
Expand Down
5 changes: 4 additions & 1 deletion src/resources/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@ export interface QueryTopDocumentsParams {

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

/**
* The query filter to apply. Please read [Metadata Filtering](/metadata-filtering)
Expand Down
6 changes: 6 additions & 0 deletions src/resources/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export interface StatusGetStatusResponse {
*/
num_failed_documents: number;

/**
* The total number of bytes used by documents that are currently indexed. Measured
* as UTF-8 bytes. For PDF/DOCX/PPT/etc, this is of the OCR'ed text.
*/
num_indexed_bytes: number;

/**
* The number of documents that are currently indexed.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.1.0-alpha.6'; // x-release-please-version
export const VERSION = '0.1.0-alpha.7'; // x-release-please-version
2 changes: 1 addition & 1 deletion tests/api-resources/collections.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('resource collections', () => {
});

test('add: required and optional params', async () => {
const response = await client.collections.add({ collection_name: 'collection_name' });
const response = await client.collections.add({ collection_name: 'collection_name', num_shards: 0 });
});

test('getList', async () => {
Expand Down
Loading