@or-sdk/qna
Advanced tools
Comparing version 2.0.0 to 2.0.1-beta.1518.0
@@ -394,2 +394,20 @@ "use strict"; | ||
}; | ||
QnA.prototype.listPassagesInDocument = function (collectionId, documentId, find) { | ||
if (find === void 0) { find = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, this.callApiV2({ | ||
method: 'GET', | ||
route: "collections/".concat(collectionId, "/documents/").concat(documentId, "/passages"), | ||
params: find, | ||
})]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2, (0, base_1.makeList)(response)]; | ||
} | ||
}); | ||
}); | ||
}; | ||
QnA.prototype.deleteDocument = function (collectionId, documentId) { | ||
@@ -396,0 +414,0 @@ return __awaiter(this, void 0, void 0, function () { |
@@ -214,2 +214,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
listPassagesInDocument(collectionId, documentId, find = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield this.callApiV2({ | ||
method: 'GET', | ||
route: `collections/${collectionId}/documents/${documentId}/passages`, | ||
params: find, | ||
}); | ||
return makeList(response); | ||
}); | ||
} | ||
deleteDocument(collectionId, documentId) { | ||
@@ -216,0 +226,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -23,4 +23,5 @@ import { Base, List } from '@or-sdk/base'; | ||
listPassages(collectionId: string, params?: Find): Promise<List<Passage>>; | ||
listPassagesInDocument(collectionId: string, documentId: string, find?: Find): Promise<List<Passage>>; | ||
deleteDocument(collectionId: string, documentId: string): Promise<Document>; | ||
} | ||
//# sourceMappingURL=QnA.d.ts.map |
@@ -1,2 +0,3 @@ | ||
import { PaginationOptions, Token } from '@or-sdk/base'; | ||
import { OrderOptions, PaginationOptions, Token } from '@or-sdk/base'; | ||
export type SearchMode = 'vector' | 'bm25'; | ||
export type QnAConfig = { | ||
@@ -90,5 +91,5 @@ token: Token; | ||
}; | ||
export type Find = Partial<PaginationOptions> & { | ||
export type Find = Partial<PaginationOptions> & Partial<OrderOptions> & { | ||
query?: string; | ||
alpha?: number; | ||
mode?: SearchMode; | ||
}; | ||
@@ -95,0 +96,0 @@ export type CreatePassage = { |
{ | ||
"name": "@or-sdk/qna", | ||
"version": "2.0.0", | ||
"version": "2.0.1-beta.1518.0", | ||
"main": "dist/cjs/index.js", | ||
@@ -30,4 +30,3 @@ "module": "dist/esm/index.js", | ||
"access": "public" | ||
}, | ||
"gitHead": "e0ae7546351c4a0daa0c9f4a7761e9f5e3464284" | ||
} | ||
} |
113
README.md
@@ -533,4 +533,22 @@ # QnA SDK | ||
List documents in a collection with optional pagination and query. | ||
List documents in a collection with optional pagination, query, and ordering. | ||
#### Params | ||
- `collectionId`: `string` - The ID of the collection to retrieve documents from. | ||
- `find`: `Find` (optional) - Optional find parameters. | ||
* `query`: `string` (optional) - The search query to filter documents based on their name and/or description. | ||
* `mode`: `SearchMode` (optional) - The search mode, either 'bm25' for full-text search or 'vector' for vector similarity search. Default is 'bm25' | ||
* `size`: `number` (optional) - The number of documents to return per request. Defaults to 10. | ||
* `from`: `number` (optional) - The starting index for fetching the documents, used for pagination. | ||
* `orderProperty`: `string` (optional) - The property by which to order the documents, e.g., 'name' or 'createdAt'. | ||
* `orderDirection`: `OrderDirection` (optional) - The direction to order the documents, either 'asc' for ascending or 'desc' for descending. | ||
#### Returns | ||
- An array of documents with pagination info. | ||
#### Example | ||
```typescript | ||
@@ -540,8 +558,10 @@ const collectionId = 'a1b2c3d4-uuid'; | ||
query: 'search query', | ||
mode: 'bm25', | ||
size: 10, | ||
skip: 0, | ||
from: 0, | ||
orderProperty: 'name', | ||
orderDirection: 'asc', | ||
}); | ||
// Example response | ||
```json | ||
{ | ||
@@ -551,6 +571,7 @@ "items": [ | ||
"id": "e5f6g7h8-uuid", | ||
"accountId": "i9j0k1l2-uuid", | ||
"collection": "a1b2c3d4-uuid", | ||
"name": "Sample Document", | ||
"description": "A sample document" | ||
"accountId": "i9j0k1l2-uuid", | ||
"collection": "a1b2c3d4-uuid", | ||
"name": "Sample Document", | ||
"description": "A sample document", | ||
"createdAt": "2022-01-02T03:04:05Z" | ||
} | ||
@@ -564,9 +585,29 @@ ], | ||
List collections with optional pagination and query. | ||
List collections with optional pagination, ordering, and query. | ||
#### Params | ||
- `find`: `Find` - Optional find parameters. | ||
* `query`: `string` (optional) - The search query to filter collections based on their name and/or description. | ||
* `mode`: `SearchMode` (optional) - The search mode, either 'bm25' for full-text search or 'vector' for vector similarity search. Default is 'bm25' | ||
* `size`: `number` (optional) - The number of collections to return per request. Defaults to 10. | ||
* `from`: `number` (optional) - The starting index for fetching the collections, used for pagination. | ||
* `orderProperty`: `string` (optional) - The property by which to order the collections, e.g., 'name' or 'createdAt'. | ||
* `orderDirection`: `OrderDirection` (optional) - The direction to order the collections, either 'asc' for ascending or 'desc' for descending. | ||
#### Returns | ||
- An array of collections with pagination info. | ||
#### Example | ||
```typescript | ||
const collections = await qna.listCollections({ | ||
query: 'search query', | ||
mode: 'bm25', | ||
size: 10, | ||
skip: 0, | ||
from: 0, | ||
orderProperty: 'name', | ||
orderDirection: 'asc', | ||
}); | ||
@@ -581,3 +622,4 @@ | ||
"name": "Sample Collection", | ||
"description": "A sample collection" | ||
"description": "A sample collection", | ||
"createdAt": "2022-01-02T03:04:05Z" | ||
} | ||
@@ -712,2 +754,53 @@ ], | ||
### `listPassagesInDocument` | ||
List all passages in a document with optional pagination, query, and ordering. | ||
#### Params | ||
- `collectionId`: `string` - The ID of the collection containing the document. | ||
- `documentId`: `string` - The ID of the document to retrieve passages from. | ||
- `find`: `Find` (optional) - Optional find parameters. | ||
* `query`: `string` (optional) - The search query to filter passages based on their content. | ||
* `mode`: `SearchMode` (optional) - The search mode, either 'bm25' for full-text search or 'vector' for vector similarity search. Default is 'bm25' | ||
* `size`: `number` (optional) - The number of passages to return per request. Defaults to 10. | ||
* `from`: `number` (optional) - The starting index for fetching the passages, used for pagination. | ||
* `orderProperty`: `string` (optional) - The property by which to order the passages, e.g., 'createdAt'. | ||
* `orderDirection`: `OrderDirection` (optional) - The direction to order the passages, either 'asc' for ascending or 'desc' for descending. | ||
#### Returns | ||
- An array of passages with pagination info. | ||
#### Example | ||
```typescript | ||
const collectionId = 'a1b2c3d4-uuid'; | ||
const documentId = 'e5f6g7h8-uuid'; | ||
const passages = await qna.listPassagesInDocument(collectionId, documentId, { | ||
query: 'search query', | ||
mode: 'bm25', | ||
size: 10, | ||
from: 0, | ||
orderProperty: 'createdAt', | ||
orderDirection: 'asc', | ||
}); | ||
// Example response | ||
{ | ||
"items": [ | ||
{ | ||
"id": "m3n4o5p6-uuid", | ||
"accountId": "i9j0k1l2-uuid", | ||
"collection": "a1b2c3d4-uuid", | ||
"documentId": "e5f6g7h8-uuid", | ||
"content": "This is a sample passage in the document.", | ||
"createdAt": "2022-01-02T03:04:05Z" | ||
} | ||
], | ||
"total": 1 | ||
} | ||
``` | ||
### `getPassage` | ||
@@ -714,0 +807,0 @@ |
@@ -326,2 +326,23 @@ import { Base, List, makeList } from '@or-sdk/base'; | ||
/** | ||
* List all passages in a document with optional pagination, query, and ordering. | ||
* @param collectionId - The ID of the collection containing the document. | ||
* @param documentId - The ID of the document to retrieve passages from. | ||
* @param find - Optional find parameters. | ||
* @returns An array of passages with pagination info. | ||
*/ | ||
async listPassagesInDocument( | ||
collectionId: string, | ||
documentId: string, | ||
find: Find = {}, | ||
): Promise<List<Passage>> { | ||
const response = await this.callApiV2<Passage[]>({ | ||
method: 'GET', | ||
route: `collections/${collectionId}/documents/${documentId}/passages`, | ||
params: find, | ||
}); | ||
return makeList(response); | ||
} | ||
/** | ||
* Delete a document from a collection. | ||
@@ -328,0 +349,0 @@ * @param collectionId - The ID of the collection to delete the document from. |
@@ -1,3 +0,5 @@ | ||
import { PaginationOptions, Token } from '@or-sdk/base'; | ||
import { OrderOptions, PaginationOptions, Token } from '@or-sdk/base'; | ||
export type SearchMode = 'vector' | 'bm25'; | ||
export type QnAConfig = { | ||
@@ -370,3 +372,3 @@ /** | ||
*/ | ||
export type Find = Partial<PaginationOptions> & { | ||
export type Find = Partial<PaginationOptions> & Partial<OrderOptions> & { | ||
/** | ||
@@ -378,5 +380,5 @@ * Search query | ||
/** | ||
* Weight between sparse and vector search. 0 - is pure sparse; 1 - is pure vector | ||
* Search mode: bm25 for full-text search and vector for vector similarity search. | ||
*/ | ||
alpha?: number; | ||
mode?: SearchMode; | ||
}; | ||
@@ -383,0 +385,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
106902
1591
892
2