conare 0.10.0 → 0.11.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 +8 -7
- package/dist/index.d.ts +13 -2
- package/dist/index.js +18 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ const docs = conare.namespace("docs");
|
|
|
19
19
|
await docs.add({ id: "refunds", text: "Refunds are available for 30 days.", metadata: { team: "support" } });
|
|
20
20
|
|
|
21
21
|
const results = await docs.query("how do refunds work?", { topK: 5 });
|
|
22
|
-
// [{ id: "refunds", text: "Refunds are available for 30 days.", score: 0.91, metadata: { team: "support" } }]
|
|
22
|
+
// [{ id: "refunds", text: "Refunds are available for 30 days.", score: 0.91, reranked: true, metadata: { team: "support" } }]
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
A namespace is created by its first write. Writing the same id again replaces the document.
|
|
@@ -45,6 +45,8 @@ 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.deleteMany(["a", "b"]); // up to 1000 ids in one call; missing ids are skipped. Returns the count
|
|
49
|
+
await docs.deleteWhere({ team: "support" }); // every document matching the filter, whole documents. Returns the count
|
|
48
50
|
await docs.drop(); // delete the namespace and its documents (also succeeds if it is empty)
|
|
49
51
|
|
|
50
52
|
await conare.namespaces(); // [{ name, documents }]
|
|
@@ -64,6 +66,8 @@ await docs.query("how do refunds work?", {
|
|
|
64
66
|
```
|
|
65
67
|
|
|
66
68
|
Hybrid search (vector and keyword), reranked. One result per document: its best passage.
|
|
69
|
+
`score` is the reranker's when `reranked` is true, else the fused rank score of a result past the
|
|
70
|
+
rerank window (or of a query not reranked); the two scales do not compare.
|
|
67
71
|
|
|
68
72
|
Filters match metadata values exactly: `{ key: value }` means equals (or, for an array value,
|
|
69
73
|
contains). Operators: `$eq` and `$in`. Combine with `$and` and `$or`:
|
|
@@ -80,7 +84,7 @@ There is no `$ne`, `$nin` or range operator (`$gt $gte $lt $lte`): the API answe
|
|
|
80
84
|
|
|
81
85
|
```ts
|
|
82
86
|
await conare.embed(["some text"], { type: "query" }); // number[][]; type defaults to "document"
|
|
83
|
-
await conare.rerank("refund window", ["a", "b"], { topK: 1 }); // [{ index, score, document }]
|
|
87
|
+
await conare.rerank("refund window", ["a", "b"], { topK: 1 }); // [{ index, score, document }], plus .unscored
|
|
84
88
|
```
|
|
85
89
|
|
|
86
90
|
### Sources
|
|
@@ -147,7 +151,8 @@ Keep the API key on your server. It can read and write every namespace in your o
|
|
|
147
151
|
## MCP
|
|
148
152
|
|
|
149
153
|
Conare is also an MCP server at `https://api.conare.ai/mcp`, with tools to search, fetch, save
|
|
150
|
-
and delete documents and list namespaces.
|
|
154
|
+
and delete documents and list namespaces. Clients that sign in over OAuth (claude.ai connectors,
|
|
155
|
+
ChatGPT) need only the URL; the rest take a key:
|
|
151
156
|
|
|
152
157
|
Claude Code:
|
|
153
158
|
|
|
@@ -179,7 +184,3 @@ CONARE_API_KEY=sk-conare-... bun test # also runs test/live.test.ts ag
|
|
|
179
184
|
```
|
|
180
185
|
|
|
181
186
|
Releases: push a tag `sdk-v<version>` matching `package.json`; CI tests and publishes to npm.
|
|
182
|
-
|
|
183
|
-
## Versions
|
|
184
|
-
|
|
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,4 +1,4 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.11.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>;
|
|
@@ -48,7 +48,10 @@ export interface QueryResult {
|
|
|
48
48
|
id: string;
|
|
49
49
|
/** The best matching passage of the document. */
|
|
50
50
|
text: string;
|
|
51
|
+
/** Higher is better: the reranker's score when `reranked`, else the fused rank score. The two do not compare. */
|
|
51
52
|
score: number;
|
|
53
|
+
/** The reranking model scored this result (false past its window, with `rerank: false`, or when it failed). */
|
|
54
|
+
reranked: boolean;
|
|
52
55
|
metadata: Metadata;
|
|
53
56
|
}
|
|
54
57
|
export interface NamespaceInfo {
|
|
@@ -60,6 +63,10 @@ export interface RerankResult {
|
|
|
60
63
|
score: number;
|
|
61
64
|
document: string;
|
|
62
65
|
}
|
|
66
|
+
/** Rerank results, best first, and the indexes of the documents no window read before the budget ended. */
|
|
67
|
+
export type RerankResults = RerankResult[] & {
|
|
68
|
+
unscored: number[];
|
|
69
|
+
};
|
|
63
70
|
export type SourceStatus = "connecting" | "syncing" | "ready" | "error";
|
|
64
71
|
export interface Source {
|
|
65
72
|
id: string;
|
|
@@ -126,7 +133,7 @@ export declare class Conare {
|
|
|
126
133
|
/** Rerank documents against a query, best first. */
|
|
127
134
|
rerank(query: string, documents: string[], options?: RequestOptions & {
|
|
128
135
|
topK?: number;
|
|
129
|
-
}): Promise<
|
|
136
|
+
}): Promise<RerankResults>;
|
|
130
137
|
private send;
|
|
131
138
|
}
|
|
132
139
|
/** One namespace: a named set of documents, e.g. "docs" or "user-42". */
|
|
@@ -154,6 +161,10 @@ export declare class Namespace {
|
|
|
154
161
|
}): AsyncGenerator<DocumentSummary>;
|
|
155
162
|
/** Delete one document. Throws a ConareError with status 404 (`document_not_found`) if it does not exist. */
|
|
156
163
|
delete(id: string, options?: RequestOptions): Promise<void>;
|
|
164
|
+
/** Delete up to 1000 documents by id in one call. Ids that do not exist are skipped. Returns how many were deleted. */
|
|
165
|
+
deleteMany(ids: string[], options?: RequestOptions): Promise<number>;
|
|
166
|
+
/** Delete every document matching filter (at least one condition), calling until none match. Returns how many were deleted. */
|
|
167
|
+
deleteWhere(filter: Filter, options?: RequestOptions): Promise<number>;
|
|
157
168
|
/** Delete the namespace and every document in it. Succeeds as well when it holds no documents (already deleted or never written). */
|
|
158
169
|
drop(options?: RequestOptions): Promise<void>;
|
|
159
170
|
}
|
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.11.0";
|
|
3
3
|
const DEFAULT_BASE_URL = "https://api.conare.ai";
|
|
4
4
|
const BATCH_SIZE = 100;
|
|
5
5
|
// ---- Errors ----------------------------------------------------------------
|
|
@@ -64,7 +64,8 @@ export class Conare {
|
|
|
64
64
|
/** Rerank documents against a query, best first. */
|
|
65
65
|
async rerank(query, documents, options = {}) {
|
|
66
66
|
const body = await this.request("POST", "/rerank", { query, documents, top_k: options.topK }, options, true);
|
|
67
|
-
|
|
67
|
+
const results = body.results.map((r) => ({ index: r.index, score: r.score, document: documents[r.index] ?? "" }));
|
|
68
|
+
return Object.assign(results, { unscored: body.unscored ?? [] });
|
|
68
69
|
}
|
|
69
70
|
/**
|
|
70
71
|
* @internal Sends one API request. An idempotent request (every GET and DELETE, and the POSTs
|
|
@@ -201,6 +202,21 @@ export class Namespace {
|
|
|
201
202
|
async delete(id, options) {
|
|
202
203
|
await this.client.request("DELETE", this.path(`/documents/${encodeURIComponent(id)}`), undefined, options);
|
|
203
204
|
}
|
|
205
|
+
/** Delete up to 1000 documents by id in one call. Ids that do not exist are skipped. Returns how many were deleted. */
|
|
206
|
+
async deleteMany(ids, options) {
|
|
207
|
+
const out = await this.client.request("POST", this.path("/documents/delete"), { ids }, options);
|
|
208
|
+
return out.deleted;
|
|
209
|
+
}
|
|
210
|
+
/** Delete every document matching filter (at least one condition), calling until none match. Returns how many were deleted. */
|
|
211
|
+
async deleteWhere(filter, options) {
|
|
212
|
+
let deleted = 0;
|
|
213
|
+
for (;;) {
|
|
214
|
+
const out = await this.client.request("POST", this.path("/documents/delete"), { filter }, options);
|
|
215
|
+
deleted += out.deleted;
|
|
216
|
+
if (!out.more)
|
|
217
|
+
return deleted;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
204
220
|
/** Delete the namespace and every document in it. Succeeds as well when it holds no documents (already deleted or never written). */
|
|
205
221
|
async drop(options) {
|
|
206
222
|
await this.client.request("DELETE", this.path(), undefined, options);
|