conare 0.14.0 → 0.15.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 +2 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.js +11 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ No dependencies. Works on Node 18+, Bun, Deno and edge runtimes.
|
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
9
|
npm install conare
|
|
10
|
-
export CONARE_API_KEY=sk-conare-... # conare.ai/
|
|
10
|
+
export CONARE_API_KEY=sk-conare-... # conare.ai/dashboard/keys
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
```ts
|
|
@@ -54,6 +54,7 @@ await docs.drop(); // delete the namespace and its d
|
|
|
54
54
|
await docs.create({ sparse: true }); // create it with a sparse (SPLADE) index, before its first write
|
|
55
55
|
|
|
56
56
|
await conare.namespaces(); // [{ name, documents }]
|
|
57
|
+
await conare.namespaces({ prefix: "u7f3a9c-" }); // one user's namespaces
|
|
57
58
|
```
|
|
58
59
|
|
|
59
60
|
Namespace names: 1-64 characters of `a-z 0-9 _ -`. Ids: up to 256 characters of
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.15.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>;
|
|
@@ -136,8 +136,13 @@ export declare class Conare {
|
|
|
136
136
|
constructor(options?: ConareOptions);
|
|
137
137
|
/** A handle to one namespace. Nothing is sent until you call a method; the first write creates it. */
|
|
138
138
|
namespace(name: string): Namespace;
|
|
139
|
-
/**
|
|
140
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Every namespace in the organization (a scoped key: every one it reaches) with its document
|
|
141
|
+
* count; with `prefix`, only those whose name starts with it, e.g. one user's `"u7f3a9c-"`.
|
|
142
|
+
*/
|
|
143
|
+
namespaces(options?: RequestOptions & {
|
|
144
|
+
prefix?: string;
|
|
145
|
+
}): Promise<NamespaceInfo[]>;
|
|
141
146
|
/** Embed texts. Use type "query" for search queries and "document" (default) for stored text. */
|
|
142
147
|
embed(input: string | string[], options?: RequestOptions & {
|
|
143
148
|
type?: "document" | "query";
|
|
@@ -182,12 +187,14 @@ export declare class Namespace {
|
|
|
182
187
|
/**
|
|
183
188
|
* Hybrid search, reranked. One result per document: its best passage. `retrievers` picks what
|
|
184
189
|
* the search fuses (default `["vector", "keyword"]`); `"sparse"` needs a namespace created with
|
|
185
|
-
* a sparse index.
|
|
190
|
+
* a sparse index. `rerankDepth` (1-100) has the reranker score every passage among the first
|
|
191
|
+
* that many, 20 at a time (about 100 ms each); unset, it reads one window of 20.
|
|
186
192
|
*/
|
|
187
193
|
query(query: string, options?: RequestOptions & {
|
|
188
194
|
topK?: number;
|
|
189
195
|
filter?: Filter;
|
|
190
196
|
rerank?: boolean;
|
|
197
|
+
rerankDepth?: number;
|
|
191
198
|
retrievers?: Retriever[];
|
|
192
199
|
}): Promise<QueryResult[]>;
|
|
193
200
|
/** One document by id, or null if it does not exist. */
|
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.15.0";
|
|
3
3
|
const DEFAULT_BASE_URL = "https://api.conare.ai";
|
|
4
4
|
const BATCH_SIZE = 100;
|
|
5
5
|
// ---- Errors ----------------------------------------------------------------
|
|
@@ -63,9 +63,13 @@ export class Conare {
|
|
|
63
63
|
namespace(name) {
|
|
64
64
|
return new Namespace(this, name);
|
|
65
65
|
}
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Every namespace in the organization (a scoped key: every one it reaches) with its document
|
|
68
|
+
* count; with `prefix`, only those whose name starts with it, e.g. one user's `"u7f3a9c-"`.
|
|
69
|
+
*/
|
|
70
|
+
async namespaces(options = {}) {
|
|
71
|
+
const path = options.prefix ? `/namespaces?prefix=${encodeURIComponent(options.prefix)}` : "/namespaces";
|
|
72
|
+
const body = await this.request("GET", path, undefined, options);
|
|
69
73
|
return body.namespaces;
|
|
70
74
|
}
|
|
71
75
|
/** Embed texts. Use type "query" for search queries and "document" (default) for stored text. */
|
|
@@ -204,10 +208,11 @@ export class Namespace {
|
|
|
204
208
|
/**
|
|
205
209
|
* Hybrid search, reranked. One result per document: its best passage. `retrievers` picks what
|
|
206
210
|
* the search fuses (default `["vector", "keyword"]`); `"sparse"` needs a namespace created with
|
|
207
|
-
* a sparse index.
|
|
211
|
+
* a sparse index. `rerankDepth` (1-100) has the reranker score every passage among the first
|
|
212
|
+
* that many, 20 at a time (about 100 ms each); unset, it reads one window of 20.
|
|
208
213
|
*/
|
|
209
214
|
async query(query, options = {}) {
|
|
210
|
-
const body = await this.client.request("POST", this.path("/query"), { query, top_k: options.topK, filter: options.filter, rerank: options.rerank, retrievers: options.retrievers }, options, true);
|
|
215
|
+
const body = await this.client.request("POST", this.path("/query"), { query, top_k: options.topK, filter: options.filter, rerank: options.rerank, rerank_depth: options.rerankDepth, retrievers: options.retrievers }, options, true);
|
|
211
216
|
return body.results;
|
|
212
217
|
}
|
|
213
218
|
/** One document by id, or null if it does not exist. */
|