qanswer-sdk 3.1208.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 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
- ## Quick Start
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
- import { DefaultApi } from "qanswer-sdk";
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
- // Create an instance of the API client
32
- const api = new DefaultApi();
102
+ ### 🔐 Authentication
33
103
 
34
- // Example: ask QAnswer a question
35
- api.getAnswer({ question: "What is QAnswer?" })
36
- .then(response => console.log("🤖 Answer:", response.data))
37
- .catch(err => console.error("❌ Error:", err));
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
- ## 📖 Features
118
+ Supply a bearer token during configuration:
43
119
 
44
- ✨ Auto-generated from OpenAPI
45
- 🔧 Written in TypeScript with full type safety
46
- Powered by Axios under the hood
47
- 📦 Easy to install and use in Node.js or browser apps
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
- # Made with ❤️ by The QA Company
244
+ ## Made with ❤️ by The QA Company
package/api.ts CHANGED
@@ -3832,6 +3832,12 @@ export interface DocumentMetadata {
3832
3832
  * @memberof DocumentMetadata
3833
3833
  */
3834
3834
  'doOCR'?: boolean;
3835
+ /**
3836
+ *
3837
+ * @type {boolean}
3838
+ * @memberof DocumentMetadata
3839
+ */
3840
+ 'doLLM'?: boolean;
3835
3841
  }
3836
3842
  /**
3837
3843
  * Metadata of the document to be uploaded
@@ -7020,22 +7026,22 @@ export interface PageOrganization {
7020
7026
  'pageable'?: PageableObject;
7021
7027
  /**
7022
7028
  *
7023
- * @type {SortObject}
7029
+ * @type {boolean}
7024
7030
  * @memberof PageOrganization
7025
7031
  */
7026
- 'sort'?: SortObject;
7032
+ 'first'?: boolean;
7027
7033
  /**
7028
7034
  *
7029
7035
  * @type {boolean}
7030
7036
  * @memberof PageOrganization
7031
7037
  */
7032
- 'first'?: boolean;
7038
+ 'last'?: boolean;
7033
7039
  /**
7034
7040
  *
7035
- * @type {boolean}
7041
+ * @type {SortObject}
7036
7042
  * @memberof PageOrganization
7037
7043
  */
7038
- 'last'?: boolean;
7044
+ 'sort'?: SortObject;
7039
7045
  /**
7040
7046
  *
7041
7047
  * @type {number}
@@ -7093,22 +7099,22 @@ export interface PageTeamWithCount {
7093
7099
  'pageable'?: PageableObject;
7094
7100
  /**
7095
7101
  *
7096
- * @type {SortObject}
7102
+ * @type {boolean}
7097
7103
  * @memberof PageTeamWithCount
7098
7104
  */
7099
- 'sort'?: SortObject;
7105
+ 'first'?: boolean;
7100
7106
  /**
7101
7107
  *
7102
7108
  * @type {boolean}
7103
7109
  * @memberof PageTeamWithCount
7104
7110
  */
7105
- 'first'?: boolean;
7111
+ 'last'?: boolean;
7106
7112
  /**
7107
7113
  *
7108
- * @type {boolean}
7114
+ * @type {SortObject}
7109
7115
  * @memberof PageTeamWithCount
7110
7116
  */
7111
- 'last'?: boolean;
7117
+ 'sort'?: SortObject;
7112
7118
  /**
7113
7119
  *
7114
7120
  * @type {number}
@@ -10958,6 +10964,12 @@ export interface SocketFileMetadata {
10958
10964
  * @memberof SocketFileMetadata
10959
10965
  */
10960
10966
  'do_ocr'?: boolean;
10967
+ /**
10968
+ *
10969
+ * @type {boolean}
10970
+ * @memberof SocketFileMetadata
10971
+ */
10972
+ 'do_llm'?: boolean;
10961
10973
  /**
10962
10974
  *
10963
10975
  * @type {string}