conare 0.8.0 → 0.10.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 +9 -6
- package/dist/index.d.ts +15 -11
- package/dist/index.js +8 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ await docs.add([...]); // or many; sent 100 at a time. R
|
|
|
45
45
|
await docs.get("refunds"); // { id, text, metadata, updatedAt } or null
|
|
46
46
|
for await (const doc of docs.list()) {} // every document, page by page ({ limit } per page: 1-100, default 50)
|
|
47
47
|
await docs.delete("refunds"); // 404 document_not_found if it does not exist
|
|
48
|
-
await docs.drop(); // delete the namespace and its documents (
|
|
48
|
+
await docs.drop(); // delete the namespace and its documents (also succeeds if it is empty)
|
|
49
49
|
|
|
50
50
|
await conare.namespaces(); // [{ name, documents }]
|
|
51
51
|
```
|
|
@@ -65,14 +65,17 @@ await docs.query("how do refunds work?", {
|
|
|
65
65
|
|
|
66
66
|
Hybrid search (vector and keyword), reranked. One result per document: its best passage.
|
|
67
67
|
|
|
68
|
-
Filters: `{ key: value }` means equals
|
|
69
|
-
Combine with `$and` and `$or`:
|
|
68
|
+
Filters match metadata values exactly: `{ key: value }` means equals (or, for an array value,
|
|
69
|
+
contains). Operators: `$eq` and `$in`. Combine with `$and` and `$or`:
|
|
70
70
|
|
|
71
71
|
```ts
|
|
72
|
-
{ $or: [{ team: "support" }, { year: { $
|
|
73
|
-
{ $and: [{ lang: { $in: ["en", "de"] } }, { draft:
|
|
72
|
+
{ $or: [{ team: "support" }, { year: { $in: [2024, 2025] } }] }
|
|
73
|
+
{ $and: [{ lang: { $in: ["en", "de"] } }, { draft: false }] }
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
There is no `$ne`, `$nin` or range operator (`$gt $gte $lt $lte`): the API answers 400
|
|
77
|
+
`invalid_filter`. Store a value you want to filter on as its own metadata key instead.
|
|
78
|
+
|
|
76
79
|
### Embed and rerank
|
|
77
80
|
|
|
78
81
|
```ts
|
|
@@ -179,4 +182,4 @@ Releases: push a tag `sdk-v<version>` matching `package.json`; CI tests and publ
|
|
|
179
182
|
|
|
180
183
|
## Versions
|
|
181
184
|
|
|
182
|
-
0.8.0 is the first release of this client. Versions of `conare` before it (0.7.x and older)
|
|
185
|
+
0.8.0 is the first release of this client. Versions of `conare` before it (0.7.x and older) are the retired memory CLI.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.10.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>;
|
|
5
5
|
type Scalar = string | number | boolean;
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Operators for one metadata key: `$eq` and `$in`. Filters match values exactly; the API
|
|
8
|
+
* answers 400 invalid_filter for the operators typed `never` here, so they do not compile.
|
|
9
|
+
*/
|
|
7
10
|
export interface FilterOperators {
|
|
8
11
|
$eq?: Scalar;
|
|
9
|
-
$ne?: Scalar;
|
|
10
|
-
$gt?: number | string;
|
|
11
|
-
$gte?: number | string;
|
|
12
|
-
$lt?: number | string;
|
|
13
|
-
$lte?: number | string;
|
|
14
12
|
$in?: Scalar[];
|
|
15
|
-
$
|
|
13
|
+
$ne?: never;
|
|
14
|
+
$nin?: never;
|
|
15
|
+
$gt?: never;
|
|
16
|
+
$gte?: never;
|
|
17
|
+
$lt?: never;
|
|
18
|
+
$lte?: never;
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
18
|
-
* A metadata filter. `{ team: "support" }` means equals
|
|
19
|
-
*
|
|
21
|
+
* A metadata filter. `{ team: "support" }` means equals (or, for an array value, contains);
|
|
22
|
+
* use `$eq` / `$in` per key and `$and` / `$or` to combine:
|
|
23
|
+
* `{ $or: [{ team: "support" }, { year: { $in: [2024, 2025] } }] }`.
|
|
20
24
|
*/
|
|
21
25
|
export interface Filter {
|
|
22
26
|
$and?: Filter[];
|
|
@@ -150,7 +154,7 @@ export declare class Namespace {
|
|
|
150
154
|
}): AsyncGenerator<DocumentSummary>;
|
|
151
155
|
/** Delete one document. Throws a ConareError with status 404 (`document_not_found`) if it does not exist. */
|
|
152
156
|
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
153
|
-
/** Delete the namespace and every document in it.
|
|
157
|
+
/** Delete the namespace and every document in it. Succeeds as well when it holds no documents (already deleted or never written). */
|
|
154
158
|
drop(options?: RequestOptions): Promise<void>;
|
|
155
159
|
}
|
|
156
160
|
/** Apps connected through Conare that keep syncing into a namespace. */
|
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.10.0";
|
|
3
3
|
const DEFAULT_BASE_URL = "https://api.conare.ai";
|
|
4
4
|
const BATCH_SIZE = 100;
|
|
5
5
|
// ---- Errors ----------------------------------------------------------------
|
|
@@ -36,7 +36,12 @@ export class Conare {
|
|
|
36
36
|
throw new ConareError(0, "missing_api_key", "Pass { apiKey } or set CONARE_API_KEY.");
|
|
37
37
|
}
|
|
38
38
|
this.apiKey = apiKey;
|
|
39
|
-
|
|
39
|
+
const baseURL = options.baseURL ?? env("CONARE_BASE_URL") ?? DEFAULT_BASE_URL;
|
|
40
|
+
let end = baseURL.length;
|
|
41
|
+
// A loop, not .replace(/\/+$/, ""): that regex is quadratic on a long run of "/" (3.8 s at 100k).
|
|
42
|
+
while (end > 0 && baseURL[end - 1] === "/")
|
|
43
|
+
end--;
|
|
44
|
+
this.baseURL = baseURL.slice(0, end);
|
|
40
45
|
this.timeout = options.timeout ?? 60_000;
|
|
41
46
|
this.maxRetries = options.maxRetries ?? 2;
|
|
42
47
|
this.fetchFn = options.fetch ?? ((url, init) => fetch(url, init));
|
|
@@ -196,7 +201,7 @@ export class Namespace {
|
|
|
196
201
|
async delete(id, options) {
|
|
197
202
|
await this.client.request("DELETE", this.path(`/documents/${encodeURIComponent(id)}`), undefined, options);
|
|
198
203
|
}
|
|
199
|
-
/** Delete the namespace and every document in it.
|
|
204
|
+
/** Delete the namespace and every document in it. Succeeds as well when it holds no documents (already deleted or never written). */
|
|
200
205
|
async drop(options) {
|
|
201
206
|
await this.client.request("DELETE", this.path(), undefined, options);
|
|
202
207
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "conare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "TypeScript client for Conare: add documents, query them, connect apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"engines": { "node": ">=18" },
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/bun": "1.
|
|
28
|
+
"@types/bun": "1.4.2",
|
|
29
29
|
"typescript": "5.9.3"
|
|
30
30
|
}
|
|
31
31
|
}
|