qanswer-sdk 3.1209.0-main → 3.1210.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 +20 -20
- package/dist/api.d.ts +383 -383
- package/package.json +1 -1
- package/qanswer-sdk-3.1210.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
|
@@ -7011,13 +7011,13 @@ export interface PageOrganization {
|
|
|
7011
7011
|
* @type {number}
|
|
7012
7012
|
* @memberof PageOrganization
|
|
7013
7013
|
*/
|
|
7014
|
-
'
|
|
7014
|
+
'totalElements'?: number;
|
|
7015
7015
|
/**
|
|
7016
7016
|
*
|
|
7017
7017
|
* @type {number}
|
|
7018
7018
|
* @memberof PageOrganization
|
|
7019
7019
|
*/
|
|
7020
|
-
'
|
|
7020
|
+
'totalPages'?: number;
|
|
7021
7021
|
/**
|
|
7022
7022
|
*
|
|
7023
7023
|
* @type {PageableObject}
|
|
@@ -7026,22 +7026,22 @@ export interface PageOrganization {
|
|
|
7026
7026
|
'pageable'?: PageableObject;
|
|
7027
7027
|
/**
|
|
7028
7028
|
*
|
|
7029
|
-
* @type {
|
|
7029
|
+
* @type {boolean}
|
|
7030
7030
|
* @memberof PageOrganization
|
|
7031
7031
|
*/
|
|
7032
|
-
'
|
|
7032
|
+
'first'?: boolean;
|
|
7033
7033
|
/**
|
|
7034
7034
|
*
|
|
7035
7035
|
* @type {boolean}
|
|
7036
7036
|
* @memberof PageOrganization
|
|
7037
7037
|
*/
|
|
7038
|
-
'
|
|
7038
|
+
'last'?: boolean;
|
|
7039
7039
|
/**
|
|
7040
7040
|
*
|
|
7041
|
-
* @type {
|
|
7041
|
+
* @type {SortObject}
|
|
7042
7042
|
* @memberof PageOrganization
|
|
7043
7043
|
*/
|
|
7044
|
-
'
|
|
7044
|
+
'sort'?: SortObject;
|
|
7045
7045
|
/**
|
|
7046
7046
|
*
|
|
7047
7047
|
* @type {number}
|
|
@@ -7084,13 +7084,13 @@ export interface PageTeamWithCount {
|
|
|
7084
7084
|
* @type {number}
|
|
7085
7085
|
* @memberof PageTeamWithCount
|
|
7086
7086
|
*/
|
|
7087
|
-
'
|
|
7087
|
+
'totalElements'?: number;
|
|
7088
7088
|
/**
|
|
7089
7089
|
*
|
|
7090
7090
|
* @type {number}
|
|
7091
7091
|
* @memberof PageTeamWithCount
|
|
7092
7092
|
*/
|
|
7093
|
-
'
|
|
7093
|
+
'totalPages'?: number;
|
|
7094
7094
|
/**
|
|
7095
7095
|
*
|
|
7096
7096
|
* @type {PageableObject}
|
|
@@ -7099,22 +7099,22 @@ export interface PageTeamWithCount {
|
|
|
7099
7099
|
'pageable'?: PageableObject;
|
|
7100
7100
|
/**
|
|
7101
7101
|
*
|
|
7102
|
-
* @type {
|
|
7102
|
+
* @type {boolean}
|
|
7103
7103
|
* @memberof PageTeamWithCount
|
|
7104
7104
|
*/
|
|
7105
|
-
'
|
|
7105
|
+
'first'?: boolean;
|
|
7106
7106
|
/**
|
|
7107
7107
|
*
|
|
7108
7108
|
* @type {boolean}
|
|
7109
7109
|
* @memberof PageTeamWithCount
|
|
7110
7110
|
*/
|
|
7111
|
-
'
|
|
7111
|
+
'last'?: boolean;
|
|
7112
7112
|
/**
|
|
7113
7113
|
*
|
|
7114
|
-
* @type {
|
|
7114
|
+
* @type {SortObject}
|
|
7115
7115
|
* @memberof PageTeamWithCount
|
|
7116
7116
|
*/
|
|
7117
|
-
'
|
|
7117
|
+
'sort'?: SortObject;
|
|
7118
7118
|
/**
|
|
7119
7119
|
*
|
|
7120
7120
|
* @type {number}
|
|
@@ -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}
|
|
@@ -7197,10 +7197,10 @@ export interface PageableObject {
|
|
|
7197
7197
|
'pageNumber'?: number;
|
|
7198
7198
|
/**
|
|
7199
7199
|
*
|
|
7200
|
-
* @type {
|
|
7200
|
+
* @type {number}
|
|
7201
7201
|
* @memberof PageableObject
|
|
7202
7202
|
*/
|
|
7203
|
-
'
|
|
7203
|
+
'pageSize'?: number;
|
|
7204
7204
|
/**
|
|
7205
7205
|
*
|
|
7206
7206
|
* @type {SortObject}
|
|
@@ -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}
|