conare 0.27.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -110,6 +110,10 @@ fuses: `"vector"` (the embedding model) and `"keyword"` (BM25; alone, BM25 alone
|
|
|
110
110
|
`score` is the reranker's when `reranked` is true, else the fused rank score of a result past the
|
|
111
111
|
rerank window (or of a query not reranked); the two scales do not compare.
|
|
112
112
|
|
|
113
|
+
A search that lost a part still answers: the results carry `.degraded`, the parts it lost (`["rerank"]`
|
|
114
|
+
when the reranker did not answer, `["embed"]` when only keywords searched), empty when it lost nothing.
|
|
115
|
+
Each page of `queryPages` has the same field.
|
|
116
|
+
|
|
113
117
|
Filters match metadata values: `{ key: value }` means equals (or, for an array value,
|
|
114
118
|
contains). Operators: `$eq`, `$in`, `$ne`, `$nin` (queries only) and the ranges below. Combine with `$and` and `$or`:
|
|
115
119
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.28.0";
|
|
2
2
|
/** A metadata value: string, number, boolean or an array of strings. */
|
|
3
3
|
export type MetadataValue = string | number | boolean | string[];
|
|
4
4
|
export type Metadata = Record<string, MetadataValue>;
|
|
@@ -338,9 +338,19 @@ export interface GrepPage {
|
|
|
338
338
|
/** Where the next page starts; null on the last page. A page can stop short of `limit`. */
|
|
339
339
|
nextCursor: string | null;
|
|
340
340
|
}
|
|
341
|
+
/**
|
|
342
|
+
* A search's results, best first, and what the search lost on the way (the values of the `Conare-Degraded`
|
|
343
|
+
* header, such as `rerank` when no result was reranked or `embed` when only keywords searched); empty when it
|
|
344
|
+
* lost nothing. A search that lost a part still answers 200: read `.degraded` before trusting the order.
|
|
345
|
+
*/
|
|
346
|
+
export type QueryResults = QueryResult[] & {
|
|
347
|
+
degraded: string[];
|
|
348
|
+
};
|
|
341
349
|
/** One page of `Namespace.queryPages`. */
|
|
342
350
|
export interface QueryPage {
|
|
343
351
|
results: QueryResult[];
|
|
352
|
+
/** What this page's search lost (see `QueryResults`); empty when it lost nothing. */
|
|
353
|
+
degraded: string[];
|
|
344
354
|
/** Where the next page starts (`queryPages`'s `cursor`); null on the last page. */
|
|
345
355
|
nextCursor: string | null;
|
|
346
356
|
}
|
|
@@ -845,7 +855,7 @@ export declare class Namespace {
|
|
|
845
855
|
* `userPrefix` (ending in `:`) to a group's; both combine with `filter`. An empty `user` or
|
|
846
856
|
* `userPrefix` is a 400, never "every user". `excludeIds` keeps those documents out.
|
|
847
857
|
*/
|
|
848
|
-
query(query: string, options?: QueryOptions): Promise<
|
|
858
|
+
query(query: string, options?: QueryOptions): Promise<QueryResults>;
|
|
849
859
|
/**
|
|
850
860
|
* The documents whose text matches a regular expression, or a near spelling (`{ query, max_distance }`),
|
|
851
861
|
* with the lines that match, in id order. A match lies inside one passage. Pass `nextCursor` as `cursor`
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// conare: TypeScript client for the Conare API. Zero dependencies; uses global fetch.
|
|
2
|
-
export const VERSION = "0.
|
|
2
|
+
export const VERSION = "0.28.0";
|
|
3
3
|
const DEFAULT_BASE_URL = "https://api.conare.ai";
|
|
4
4
|
const BATCH_SIZE = 100;
|
|
5
5
|
/** Above the API's 110 s deadline for a write: a call given up sooner is retried while the first still runs. */
|
|
@@ -560,7 +560,7 @@ export class Namespace {
|
|
|
560
560
|
*/
|
|
561
561
|
async query(query, options = {}) {
|
|
562
562
|
const body = await this.client.request("POST", this.path("/query"), queryBody(query, options), options);
|
|
563
|
-
return body.results;
|
|
563
|
+
return Object.assign(body.results, { degraded: body.degraded ?? [] });
|
|
564
564
|
}
|
|
565
565
|
/**
|
|
566
566
|
* The documents whose text matches a regular expression, or a near spelling (`{ query, max_distance }`),
|
|
@@ -592,12 +592,12 @@ export class Namespace {
|
|
|
592
592
|
: await this.client.request("POST", this.path("/query"), { ...queryBody(query, options), max_results: options.maxResults }, options);
|
|
593
593
|
if (!cursor) {
|
|
594
594
|
cursor = page.next_cursor ?? null;
|
|
595
|
-
yield { results: page.results, nextCursor: cursor };
|
|
595
|
+
yield { results: page.results, nextCursor: cursor, degraded: page.degraded ?? [] };
|
|
596
596
|
}
|
|
597
597
|
while (cursor) {
|
|
598
598
|
page = await this.client.request("POST", this.path("/query"), { cursor, top_k: options.topK }, options);
|
|
599
599
|
cursor = page.next_cursor ?? null;
|
|
600
|
-
yield { results: page.results, nextCursor: cursor };
|
|
600
|
+
yield { results: page.results, nextCursor: cursor, degraded: page.degraded ?? [] };
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
603
|
/** One document by id, or null if it does not exist. */
|