@or-sdk/qna
Advanced tools
Comparing version 1.5.1-beta.1426.0 to 1.6.0-beta.1427.0
@@ -150,2 +150,18 @@ "use strict"; | ||
}; | ||
QnA.prototype.createManyPassages = function (collectionId, passages) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, this.callApiV2({ | ||
method: 'POST', | ||
route: "collections/".concat(collectionId, "/passages"), | ||
data: passages, | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
return [2]; | ||
} | ||
}); | ||
}); | ||
}; | ||
QnA.prototype.deleteCollection = function (collectionId) { | ||
@@ -152,0 +168,0 @@ return __awaiter(this, void 0, void 0, function () { |
@@ -71,2 +71,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
createManyPassages(collectionId, passages) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.callApiV2({ | ||
method: 'POST', | ||
route: `collections/${collectionId}/passages`, | ||
data: passages, | ||
}); | ||
}); | ||
} | ||
deleteCollection(collectionId) { | ||
@@ -73,0 +82,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -8,2 +8,3 @@ import { Base, List } from '@or-sdk/base'; | ||
createPassage(collectionId: string, params: CreatePassage): Promise<Passage>; | ||
createManyPassages(collectionId: string, passages: CreatePassage[]): Promise<void>; | ||
deleteCollection(collectionId: string): Promise<Collection>; | ||
@@ -18,3 +19,3 @@ deletePassage(collectionId: string, passageId: string): Promise<DeletedPassage>; | ||
getCollection(collectionId: string): Promise<Collection>; | ||
getPassage(collectionId: string, passageId: string): Promise<Passage>; | ||
getPassage<T extends Record<string, unknown>>(collectionId: string, passageId: string): Promise<Passage & T>; | ||
addProperty(collectionId: string, property: Property): Promise<void>; | ||
@@ -21,0 +22,0 @@ listDocuments(collectionId: string, { query, from: offset, size: limit, alpha }?: Find): Promise<List<Document>>; |
@@ -12,3 +12,3 @@ import { PaginationOptions, Token } from '@or-sdk/base'; | ||
name: string; | ||
defaultParams: Record<string, unknown>; | ||
defaultProperties: Record<string, unknown>; | ||
}; | ||
@@ -49,2 +49,4 @@ export type Property = { | ||
description: string; | ||
createdAt: string; | ||
updateAt: string; | ||
}; | ||
@@ -57,2 +59,4 @@ export type Collection = { | ||
properties?: Property[]; | ||
createdAt: string; | ||
updateAt: string; | ||
}; | ||
@@ -86,2 +90,5 @@ export type SearchResult = { | ||
id: string; | ||
content: string; | ||
createdAt: string; | ||
updateAt: string; | ||
}; | ||
@@ -88,0 +95,0 @@ export type ListPassages = Partial<PaginationOptions> & { |
{ | ||
"name": "@or-sdk/qna", | ||
"version": "1.5.1-beta.1426.0", | ||
"version": "1.6.0-beta.1427.0", | ||
"main": "dist/cjs/index.js", | ||
@@ -20,3 +20,3 @@ "module": "dist/esm/index.js", | ||
"dependencies": { | ||
"@or-sdk/base": "^0.28.2-beta.1426.0", | ||
"@or-sdk/base": "^0.28.1", | ||
"lodash": "^4.17.21" | ||
@@ -23,0 +23,0 @@ }, |
@@ -65,7 +65,7 @@ # QnA SDK | ||
- `name`: `string` - Document name | ||
- `defaultParams`: `Record<string, unknown>` (optional) - Default custom properties for the document passages. Note that these properties should be listed in the collection properties. | ||
- `defaultProperties`: `Record<string, unknown>` (optional) - Default custom properties for the document passages. Note that these properties should be listed in the collection properties. | ||
#### Example | ||
In this example, the `loadDocument` method downloads a document from the provided URL, splits the content into passages, and adds them to the specified collection. Additionally, the `defaultParams` attribute is used to set custom properties for the passages. | ||
In this example, the `loadDocument` method downloads a document from the provided URL, splits the content into passages, and adds them to the specified collection. Additionally, the `defaultProperties` attribute is used to set custom properties for the passages. | ||
@@ -75,6 +75,6 @@ ```typescript | ||
const document = await qna.loadDocument(collectionId, { | ||
name: 'Sample Document', | ||
description: 'A sample document', | ||
url: 'http://example.com/sample-document.pdf', | ||
name: 'Sample Document', | ||
defaultParams: { | ||
defaultProperties: { | ||
author: 'John Doe', | ||
@@ -558,2 +558,34 @@ publishDate: '2020-12-31', | ||
### `createManyPassages` | ||
Create a batch of passages and add it to a specific document within a collection. A passage is an atomic piece of data that represents a portion of a document. It is the smallest searchable unit within a collection. | ||
#### Params | ||
- collectionId: `string` - The ID of the collection the document belongs to | ||
- passages: `CreatePassage[]` - An array of objects containing parameters required to create each passage | ||
- `content` (string): The content of the passage to be created | ||
- `documentId` (string): The ID of the document the passage will be associated with | ||
- `property: value` (optional): Custom properties of the passage. Note that these properties should be listed in the collection properties | ||
#### Example | ||
```typescript | ||
const collectionId = 'a1b2c3d4-uuid'; | ||
const passages: CreatePassage[] = [ | ||
{ | ||
content: 'This is the content of the first passage.', | ||
documentId: 'e5f6g7h8-uuid', | ||
}, | ||
{ | ||
content: 'This is the content of the second passage.', | ||
documentId: 'e5f6g7h8-uuid', | ||
}, | ||
]; | ||
const passage = await qna.createPassage(collectionId, params); | ||
// No direct response, the batch of passages are added to the collection | ||
``` | ||
**Note:** The number of the passages are not limited but the total amount of the data to create in a single batch is limited to 1MB. | ||
### `listPassages` | ||
@@ -560,0 +592,0 @@ |
@@ -59,2 +59,8 @@ import { Base, List, makeList } from '@or-sdk/base'; | ||
/** | ||
* Create a new passage within the collection. | ||
* @param collectionId - The ID of the collection the passage belongs to. | ||
* @param params - The passage creation parameters. | ||
* @returns The created passage. | ||
*/ | ||
async createPassage(collectionId: string, params: CreatePassage): Promise<Passage> { | ||
@@ -77,2 +83,15 @@ const { content, documentId, ...properties } = params; | ||
/** | ||
* Create batch of passages within the collection. | ||
* @param collectionId - The ID of the collection the passage belongs to. | ||
* @param passages - The passages to create. | ||
*/ | ||
async createManyPassages(collectionId: string, passages: CreatePassage[]): Promise<void> { | ||
await this.callApiV2({ | ||
method: 'POST', | ||
route: `collections/${collectionId}/passages`, | ||
data: passages, | ||
}); | ||
} | ||
/** | ||
* Delete a collection by ID. | ||
@@ -239,4 +258,4 @@ * @param collectionId - The ID of the collection to delete. | ||
*/ | ||
async getPassage(collectionId: string, passageId: string): Promise<Passage> { | ||
const response = await this.callApiV2<Passage>({ | ||
async getPassage<T extends Record<string, unknown>>(collectionId: string, passageId: string): Promise<Passage & T> { | ||
const response = await this.callApiV2<Passage & T>({ | ||
method: 'GET', | ||
@@ -243,0 +262,0 @@ route: `collections/${collectionId}/passages/${passageId}`, |
@@ -48,3 +48,3 @@ import { PaginationOptions, Token } from '@or-sdk/base'; | ||
*/ | ||
defaultParams: Record<string, unknown>; | ||
defaultProperties: Record<string, unknown>; | ||
}; | ||
@@ -189,2 +189,12 @@ | ||
description: string; | ||
/** | ||
* Creation Date | ||
*/ | ||
createdAt: string; | ||
/** | ||
* Updating Date | ||
*/ | ||
updateAt: string; | ||
}; | ||
@@ -220,2 +230,12 @@ | ||
properties?: Property[]; | ||
/** | ||
* Creation Date | ||
*/ | ||
createdAt: string; | ||
/** | ||
* Updating Date | ||
*/ | ||
updateAt: string; | ||
}; | ||
@@ -326,2 +346,17 @@ | ||
id: string; | ||
/** | ||
* Passage Content | ||
*/ | ||
content: string; | ||
/** | ||
* Creation Date | ||
*/ | ||
createdAt: string; | ||
/** | ||
* Updating Date | ||
*/ | ||
updateAt: string; | ||
}; | ||
@@ -328,0 +363,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
98405
1575
720
Updated@or-sdk/base@^0.28.1