qanswer-sdk 3.1209.0-main → 3.1211.0-main
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 +195 -15
- package/api.ts +21 -21
- package/dist/api.d.ts +384 -384
- package/package.json +1 -1
- package/qanswer-sdk-3.1211.0-main.tgz +0 -0
- package/qanswer-sdk-3.1209.0-main.tgz +0 -0
package/README.md
CHANGED
|
@@ -9,6 +9,16 @@
|
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
+
## ✨ Features
|
|
13
|
+
|
|
14
|
+
- **OpenAPI-Generated**: Built using OpenAPI Generator for robust and reliable API handling.
|
|
15
|
+
- **TypeScript Support**: Includes full typing for a better developer experience.
|
|
16
|
+
- **Axios Integration**: Uses Axios under the hood for HTTP requests.
|
|
17
|
+
- **Flexible Authentication**: Easily configure API key or OAuth2 token-based authentication.
|
|
18
|
+
- **Modular and Compatible**: Works in both Node.js and modern front-end bundlers like Webpack and Browserify.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
12
22
|
## 📦 Installation
|
|
13
23
|
|
|
14
24
|
```bash
|
|
@@ -23,28 +33,198 @@ yarn add qanswer-sdk
|
|
|
23
33
|
|
|
24
34
|
---
|
|
25
35
|
|
|
26
|
-
##
|
|
36
|
+
## 🚀 Usage
|
|
37
|
+
|
|
38
|
+
### Importing the SDK
|
|
39
|
+
|
|
40
|
+
The SDK can be used with both TypeScript and JavaScript.
|
|
41
|
+
|
|
42
|
+
🖥️ In TypeScript:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { Configuration, DatasetApi } from "qanswer-sdk";
|
|
46
|
+
|
|
47
|
+
// Setup configuration
|
|
48
|
+
const configuration = new Configuration({
|
|
49
|
+
apiKey: "YOUR_API_KEY",
|
|
50
|
+
basePath: "https://api.qanswer.com",
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Create an instance of the API you want to use
|
|
54
|
+
const datasetApiInstance = new DatasetApi(configuration);
|
|
55
|
+
|
|
56
|
+
// Example: Creating a new dataset
|
|
57
|
+
datasetApiInstance
|
|
58
|
+
.createDataset({
|
|
59
|
+
name: "sample_dataset",
|
|
60
|
+
language: "en",
|
|
61
|
+
datasetType: "qa",
|
|
62
|
+
description: "A sample dataset",
|
|
63
|
+
})
|
|
64
|
+
.then((response) => {
|
|
65
|
+
console.log("Dataset created successfully!", response);
|
|
66
|
+
})
|
|
67
|
+
.catch((error) => {
|
|
68
|
+
console.error("Error creating dataset:", error);
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
🛠️ In JavaScript:
|
|
27
73
|
|
|
28
74
|
```javascript
|
|
29
|
-
|
|
75
|
+
const { Configuration, DatasetApi } = require("qanswer-sdk");
|
|
76
|
+
|
|
77
|
+
// Setup configuration
|
|
78
|
+
const configuration = new Configuration({
|
|
79
|
+
apiKey: "YOUR_API_KEY",
|
|
80
|
+
basePath: "https://api.qanswer.com",
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Create an API instance
|
|
84
|
+
const datasetApiInstance = new DatasetApi(configuration);
|
|
85
|
+
|
|
86
|
+
// Example: Creating a new dataset
|
|
87
|
+
datasetApiInstance
|
|
88
|
+
.createDataset({
|
|
89
|
+
name: "sample_dataset",
|
|
90
|
+
language: "en",
|
|
91
|
+
datasetType: "qa",
|
|
92
|
+
description: "A sample dataset",
|
|
93
|
+
})
|
|
94
|
+
.then((response) => {
|
|
95
|
+
console.log("Dataset created successfully!", response);
|
|
96
|
+
})
|
|
97
|
+
.catch((error) => {
|
|
98
|
+
console.error("Error creating dataset:", error);
|
|
99
|
+
});
|
|
100
|
+
```
|
|
30
101
|
|
|
31
|
-
|
|
32
|
-
const api = new DefaultApi();
|
|
102
|
+
### 🔐 Authentication
|
|
33
103
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
104
|
+
Authenticate QAnswer API requests using:
|
|
105
|
+
|
|
106
|
+
#### API Key Authentication:
|
|
107
|
+
|
|
108
|
+
Provide the API key when initializing Configuration:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
const configuration = new Configuration({
|
|
112
|
+
apiKey: "YOUR_API_KEY",
|
|
113
|
+
});
|
|
38
114
|
```
|
|
39
115
|
|
|
40
|
-
|
|
116
|
+
#### Bearer Token (OAuth2) Authentication:
|
|
41
117
|
|
|
42
|
-
|
|
118
|
+
Supply a bearer token during configuration:
|
|
43
119
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
120
|
+
```typescript
|
|
121
|
+
const configuration = new Configuration({
|
|
122
|
+
accessToken: "YOUR_BEARER_TOKEN",
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 📚 Available APIs
|
|
127
|
+
|
|
128
|
+
The SDK is organized into separate API modules for better usability. Below are some of the key APIs with example usage.
|
|
129
|
+
|
|
130
|
+
#### 📁 Dataset API
|
|
131
|
+
|
|
132
|
+
Create a Dataset
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
const datasetPayload = {
|
|
136
|
+
name: "my_dataset",
|
|
137
|
+
language: "en",
|
|
138
|
+
datasetType: "qa",
|
|
139
|
+
description: "A dataset for Q&A tasks",
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
datasetApiInstance
|
|
143
|
+
.createDataset(datasetPayload)
|
|
144
|
+
.then((response) => {
|
|
145
|
+
console.log("Dataset created successfully!", response);
|
|
146
|
+
})
|
|
147
|
+
.catch((error) => {
|
|
148
|
+
console.error("Error creating dataset:", error);
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
List All Datasets
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
datasetApiInstance
|
|
156
|
+
.listDatasets()
|
|
157
|
+
.then((datasets) => {
|
|
158
|
+
console.log("Available datasets:", datasets);
|
|
159
|
+
})
|
|
160
|
+
.catch((error) => {
|
|
161
|
+
console.error("Error retrieving datasets:", error);
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### 📑 Document API
|
|
166
|
+
|
|
167
|
+
Add Q&A Pairs
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
const qnaPayload = {
|
|
171
|
+
username: "user123",
|
|
172
|
+
dataset: "my_dataset",
|
|
173
|
+
connector_id: 42,
|
|
174
|
+
quota: 100,
|
|
175
|
+
qna_pairs: [
|
|
176
|
+
{
|
|
177
|
+
question: "What is QAnswer?",
|
|
178
|
+
answer: "QAnswer is an intelligent assistant platform.",
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
qaApiInstance
|
|
184
|
+
.addQnA(qnaPayload)
|
|
185
|
+
.then((response) => {
|
|
186
|
+
console.log("Q&A added successfully!", response);
|
|
187
|
+
})
|
|
188
|
+
.catch((error) => {
|
|
189
|
+
console.error("Error adding Q&A pairs:", error);
|
|
190
|
+
});
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### 🕵️ PDF Search API
|
|
194
|
+
|
|
195
|
+
Search in a PDF
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
const pdfSearchPayload = {
|
|
199
|
+
username: "user123",
|
|
200
|
+
dataset: "my_dataset",
|
|
201
|
+
filename: "document.pdf",
|
|
202
|
+
task_name: "search",
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
pdfApiInstance
|
|
206
|
+
.searchInPDF(pdfSearchPayload)
|
|
207
|
+
.then((results) => {
|
|
208
|
+
console.log("Search results:", results);
|
|
209
|
+
})
|
|
210
|
+
.catch((error) => {
|
|
211
|
+
console.error("Error during PDF search:", error);
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### ⚙️ Custom Configuration
|
|
216
|
+
|
|
217
|
+
Customize SDK behavior by passing additional settings to the Configuration object:
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
const configuration = new Configuration({
|
|
221
|
+
apiKey: "YOUR_API_KEY",
|
|
222
|
+
basePath: "https://api.qanswer.com",
|
|
223
|
+
baseOptions: {
|
|
224
|
+
timeout: 10000, // Set request timeout to 10 seconds
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
```
|
|
48
228
|
|
|
49
229
|
---
|
|
50
230
|
|
|
@@ -61,4 +241,4 @@ This project is licensed under the MIT License
|
|
|
61
241
|
|
|
62
242
|
---
|
|
63
243
|
|
|
64
|
-
|
|
244
|
+
## Made with ❤️ by The QA Company
|
package/api.ts
CHANGED
|
@@ -7047,25 +7047,25 @@ export interface PageOrganization {
|
|
|
7047
7047
|
* @type {number}
|
|
7048
7048
|
* @memberof PageOrganization
|
|
7049
7049
|
*/
|
|
7050
|
-
'
|
|
7050
|
+
'numberOfElements'?: number;
|
|
7051
7051
|
/**
|
|
7052
7052
|
*
|
|
7053
|
-
* @type {
|
|
7053
|
+
* @type {number}
|
|
7054
7054
|
* @memberof PageOrganization
|
|
7055
7055
|
*/
|
|
7056
|
-
'
|
|
7056
|
+
'size'?: number;
|
|
7057
7057
|
/**
|
|
7058
7058
|
*
|
|
7059
|
-
* @type {
|
|
7059
|
+
* @type {Array<Organization>}
|
|
7060
7060
|
* @memberof PageOrganization
|
|
7061
7061
|
*/
|
|
7062
|
-
'
|
|
7062
|
+
'content'?: Array<Organization>;
|
|
7063
7063
|
/**
|
|
7064
7064
|
*
|
|
7065
7065
|
* @type {number}
|
|
7066
7066
|
* @memberof PageOrganization
|
|
7067
7067
|
*/
|
|
7068
|
-
'
|
|
7068
|
+
'number'?: number;
|
|
7069
7069
|
/**
|
|
7070
7070
|
*
|
|
7071
7071
|
* @type {boolean}
|
|
@@ -7120,25 +7120,25 @@ export interface PageTeamWithCount {
|
|
|
7120
7120
|
* @type {number}
|
|
7121
7121
|
* @memberof PageTeamWithCount
|
|
7122
7122
|
*/
|
|
7123
|
-
'
|
|
7123
|
+
'numberOfElements'?: number;
|
|
7124
7124
|
/**
|
|
7125
7125
|
*
|
|
7126
|
-
* @type {
|
|
7126
|
+
* @type {number}
|
|
7127
7127
|
* @memberof PageTeamWithCount
|
|
7128
7128
|
*/
|
|
7129
|
-
'
|
|
7129
|
+
'size'?: number;
|
|
7130
7130
|
/**
|
|
7131
7131
|
*
|
|
7132
|
-
* @type {
|
|
7132
|
+
* @type {Array<TeamWithCount>}
|
|
7133
7133
|
* @memberof PageTeamWithCount
|
|
7134
7134
|
*/
|
|
7135
|
-
'
|
|
7135
|
+
'content'?: Array<TeamWithCount>;
|
|
7136
7136
|
/**
|
|
7137
7137
|
*
|
|
7138
7138
|
* @type {number}
|
|
7139
7139
|
* @memberof PageTeamWithCount
|
|
7140
7140
|
*/
|
|
7141
|
-
'
|
|
7141
|
+
'number'?: number;
|
|
7142
7142
|
/**
|
|
7143
7143
|
*
|
|
7144
7144
|
* @type {boolean}
|
|
@@ -7179,10 +7179,10 @@ export interface Pageable {
|
|
|
7179
7179
|
export interface PageableObject {
|
|
7180
7180
|
/**
|
|
7181
7181
|
*
|
|
7182
|
-
* @type {
|
|
7182
|
+
* @type {boolean}
|
|
7183
7183
|
* @memberof PageableObject
|
|
7184
7184
|
*/
|
|
7185
|
-
'
|
|
7185
|
+
'unpaged'?: boolean;
|
|
7186
7186
|
/**
|
|
7187
7187
|
*
|
|
7188
7188
|
* @type {boolean}
|
|
@@ -7194,19 +7194,19 @@ export interface PageableObject {
|
|
|
7194
7194
|
* @type {number}
|
|
7195
7195
|
* @memberof PageableObject
|
|
7196
7196
|
*/
|
|
7197
|
-
'
|
|
7197
|
+
'pageSize'?: number;
|
|
7198
7198
|
/**
|
|
7199
7199
|
*
|
|
7200
|
-
* @type {
|
|
7200
|
+
* @type {SortObject}
|
|
7201
7201
|
* @memberof PageableObject
|
|
7202
7202
|
*/
|
|
7203
|
-
'
|
|
7203
|
+
'sort'?: SortObject;
|
|
7204
7204
|
/**
|
|
7205
7205
|
*
|
|
7206
|
-
* @type {
|
|
7206
|
+
* @type {number}
|
|
7207
7207
|
* @memberof PageableObject
|
|
7208
7208
|
*/
|
|
7209
|
-
'
|
|
7209
|
+
'pageNumber'?: number;
|
|
7210
7210
|
/**
|
|
7211
7211
|
*
|
|
7212
7212
|
* @type {number}
|
|
@@ -11380,13 +11380,13 @@ export interface SortObject {
|
|
|
11380
11380
|
* @type {boolean}
|
|
11381
11381
|
* @memberof SortObject
|
|
11382
11382
|
*/
|
|
11383
|
-
'
|
|
11383
|
+
'unsorted'?: boolean;
|
|
11384
11384
|
/**
|
|
11385
11385
|
*
|
|
11386
11386
|
* @type {boolean}
|
|
11387
11387
|
* @memberof SortObject
|
|
11388
11388
|
*/
|
|
11389
|
-
'
|
|
11389
|
+
'sorted'?: boolean;
|
|
11390
11390
|
/**
|
|
11391
11391
|
*
|
|
11392
11392
|
* @type {boolean}
|