node-behind-api-client 2.0.48

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.
Files changed (157) hide show
  1. package/.gitlab-ci.yml +20 -0
  2. package/README.md +65 -0
  3. package/docs/behind-api-client/easyjob/JobDescriptions/README.md +654 -0
  4. package/docs/behind-api-client/easyjob/README.md +647 -0
  5. package/docs/behind-api-client/easyjob/applicants/README.md +494 -0
  6. package/docs/behind-api-client/easyjob/applications/README.md +754 -0
  7. package/docs/behind-api-client/easyjob/candidateProfiles/README.md +940 -0
  8. package/docs/behind-api-client/easyjob/jd-candidate-questions/README.md +372 -0
  9. package/docs/behind-api-client/payments/payture/README.21.md +901 -0
  10. package/docs/behind-api-client/payments/payture/README.cards.md +1497 -0
  11. package/docs/behind-api-client/payments/payture/README.md +1497 -0
  12. package/docs/behind-api-client/payments/payture/README.rukitchen.md +396 -0
  13. package/docs/behind-api-client/payments/payture/README.subscriptions.md +1266 -0
  14. package/docs/behind-api-client/payments/stripe/README.flow.md +254 -0
  15. package/docs/behind-api-client/rag/storage/README.md +519 -0
  16. package/example.js +35 -0
  17. package/index.cjs +14 -0
  18. package/index.js +15 -0
  19. package/lib/behind-api-auth-client/BehindApiAuthClient.js +91 -0
  20. package/lib/behind-api-auth-client/authorisation/AuthorisationApp.js +9 -0
  21. package/lib/behind-api-auth-client/authorisation/AuthorisationV10.js +9 -0
  22. package/lib/behind-api-auth-client/authorisation/AuthorisationV10Code.js +30 -0
  23. package/lib/behind-api-auth-client/example.js +47 -0
  24. package/lib/behind-api-auth-client/package.json +9 -0
  25. package/lib/behind-api-client/BehindApiClient.js +137 -0
  26. package/lib/behind-api-client/chat/ChatApp.js +11 -0
  27. package/lib/behind-api-client/chat/ChatV10.js +13 -0
  28. package/lib/behind-api-client/chat/ChatV10Chat.js +87 -0
  29. package/lib/behind-api-client/chat/ChatV10Chats.js +14 -0
  30. package/lib/behind-api-client/chat/ChatV10Message.js +57 -0
  31. package/lib/behind-api-client/chat/ChatV20.js +11 -0
  32. package/lib/behind-api-client/chat/ChatV20Chat.js +14 -0
  33. package/lib/behind-api-client/chat/ChatV20Message.js +27 -0
  34. package/lib/behind-api-client/easyjob/EasyjobApp.js +9 -0
  35. package/lib/behind-api-client/easyjob/EasyjobV10.js +31 -0
  36. package/lib/behind-api-client/easyjob/EasyjobV10Answers.js +16 -0
  37. package/lib/behind-api-client/easyjob/EasyjobV10Applicants.js +29 -0
  38. package/lib/behind-api-client/easyjob/EasyjobV10Applications.js +39 -0
  39. package/lib/behind-api-client/easyjob/EasyjobV10CandidateProfileArtifacts.js +31 -0
  40. package/lib/behind-api-client/easyjob/EasyjobV10CandidateProfiles.js +99 -0
  41. package/lib/behind-api-client/easyjob/EasyjobV10Companies.js +36 -0
  42. package/lib/behind-api-client/easyjob/EasyjobV10Cv.js +15 -0
  43. package/lib/behind-api-client/easyjob/EasyjobV10Departments.js +37 -0
  44. package/lib/behind-api-client/easyjob/EasyjobV10JobDescriptionArtifacts.js +29 -0
  45. package/lib/behind-api-client/easyjob/EasyjobV10JobDescriptionCandidateQuestions.js +63 -0
  46. package/lib/behind-api-client/easyjob/EasyjobV10JobDescriptions.js +93 -0
  47. package/lib/behind-api-client/easyjob/EasyjobV10Reports.js +35 -0
  48. package/lib/behind-api-client/example.js +47 -0
  49. package/lib/behind-api-client/global/GlobalApp.js +9 -0
  50. package/lib/behind-api-client/global/GlobalV10.js +11 -0
  51. package/lib/behind-api-client/global/GlobalV10Sockets.js +16 -0
  52. package/lib/behind-api-client/global/GlobalV10Storage.js +29 -0
  53. package/lib/behind-api-client/gpt/GptApp.js +15 -0
  54. package/lib/behind-api-client/gpt/GptV10.js +15 -0
  55. package/lib/behind-api-client/gpt/GptV10Prompt.js +17 -0
  56. package/lib/behind-api-client/gpt/GptV10Request.js +16 -0
  57. package/lib/behind-api-client/gpt/GptV10Storedprompts.js +14 -0
  58. package/lib/behind-api-client/gpt/GptV10Whisper.js +23 -0
  59. package/lib/behind-api-client/gpt/GptV20.js +9 -0
  60. package/lib/behind-api-client/gpt/GptV20Prompt.js +15 -0
  61. package/lib/behind-api-client/gpt/GptV30.js +13 -0
  62. package/lib/behind-api-client/gpt/GptV30Chat.js +19 -0
  63. package/lib/behind-api-client/gpt/GptV30Prompt.js +41 -0
  64. package/lib/behind-api-client/gpt/GptV30Prompts.js +32 -0
  65. package/lib/behind-api-client/gpt/GptV40.js +11 -0
  66. package/lib/behind-api-client/gpt/GptV40Prompt.js +24 -0
  67. package/lib/behind-api-client/gpt/GptV40Prompts.js +30 -0
  68. package/lib/behind-api-client/mailer/MailerApp.js +11 -0
  69. package/lib/behind-api-client/mailer/MailerV10.js +15 -0
  70. package/lib/behind-api-client/mailer/MailerV10Bulk.js +21 -0
  71. package/lib/behind-api-client/mailer/MailerV10Message.js +83 -0
  72. package/lib/behind-api-client/mailer/MailerV10Settings.js +44 -0
  73. package/lib/behind-api-client/mailer/MailerV10Template.js +23 -0
  74. package/lib/behind-api-client/mailer/MailerV20.js +9 -0
  75. package/lib/behind-api-client/mailer/MailerV20Message.js +21 -0
  76. package/lib/behind-api-client/mastogram/MastogramApp.js +9 -0
  77. package/lib/behind-api-client/mastogram/MastogramV10.js +13 -0
  78. package/lib/behind-api-client/mastogram/MastogramV10Bluesky.js +42 -0
  79. package/lib/behind-api-client/mastogram/MastogramV10Mastodon.js +45 -0
  80. package/lib/behind-api-client/mastogram/MastogramV10Telegram.js +39 -0
  81. package/lib/behind-api-client/monitor/MonitorApp.js +9 -0
  82. package/lib/behind-api-client/monitor/MonitorV10.js +13 -0
  83. package/lib/behind-api-client/monitor/MonitorV10Finances.js +39 -0
  84. package/lib/behind-api-client/monitor/MonitorV10Record.js +15 -0
  85. package/lib/behind-api-client/monitor/MonitorV10Records.js +22 -0
  86. package/lib/behind-api-client/oauth/OauthApp.js +9 -0
  87. package/lib/behind-api-client/oauth/OauthV10.js +9 -0
  88. package/lib/behind-api-client/oauth/OauthV10Authorisation.js +15 -0
  89. package/lib/behind-api-client/package.json +9 -0
  90. package/lib/behind-api-client/payments/PaymentsApp.js +13 -0
  91. package/lib/behind-api-client/payments/PaymentsV10.js +15 -0
  92. package/lib/behind-api-client/payments/PaymentsV10Gift.js +32 -0
  93. package/lib/behind-api-client/payments/PaymentsV10Payture.js +30 -0
  94. package/lib/behind-api-client/payments/PaymentsV10Product.js +15 -0
  95. package/lib/behind-api-client/payments/PaymentsV10Telegram.js +44 -0
  96. package/lib/behind-api-client/payments/PaymentsV20.js +9 -0
  97. package/lib/behind-api-client/payments/PaymentsV20Payture.js +32 -0
  98. package/lib/behind-api-client/payments/PaymentsV21.js +15 -0
  99. package/lib/behind-api-client/payments/PaymentsV21Cards.js +14 -0
  100. package/lib/behind-api-client/payments/PaymentsV21Payture.js +29 -0
  101. package/lib/behind-api-client/payments/PaymentsV21Stripe.js +28 -0
  102. package/lib/behind-api-client/payments/PaymentsV21Subscriptions.js +21 -0
  103. package/lib/behind-api-client/questionnaire/QuestionnaireApp.js +9 -0
  104. package/lib/behind-api-client/questionnaire/QuestionnaireV10.js +9 -0
  105. package/lib/behind-api-client/questionnaire/QuestionnaireV10Form.js +22 -0
  106. package/lib/behind-api-client/raet/RaetApp.js +11 -0
  107. package/lib/behind-api-client/raet/RaetV10.js +21 -0
  108. package/lib/behind-api-client/raet/RaetV10Cv.js +87 -0
  109. package/lib/behind-api-client/raet/RaetV10Individual.js +43 -0
  110. package/lib/behind-api-client/raet/RaetV10Individuals.js +38 -0
  111. package/lib/behind-api-client/raet/RaetV10Jd.js +47 -0
  112. package/lib/behind-api-client/raet/RaetV10Project.js +61 -0
  113. package/lib/behind-api-client/raet/RaetV10Projects.js +14 -0
  114. package/lib/behind-api-client/raet/RaetV10Report.js +39 -0
  115. package/lib/behind-api-client/raet/RaetV20.js +11 -0
  116. package/lib/behind-api-client/raet/RaetV20Cv.js +31 -0
  117. package/lib/behind-api-client/raet/RaetV20Individuals.js +25 -0
  118. package/lib/behind-api-client/rag/RagApp.js +9 -0
  119. package/lib/behind-api-client/rag/RagV10.js +9 -0
  120. package/lib/behind-api-client/rag/RagV10Storage.js +27 -0
  121. package/lib/behind-api-client/ruKitchen/RuKitchenApp.js +9 -0
  122. package/lib/behind-api-client/ruKitchen/RuKitchenV10.js +11 -0
  123. package/lib/behind-api-client/ruKitchen/RuKitchenV10Importer.js +29 -0
  124. package/lib/behind-api-client/ruKitchen/RuKitchenV10SeoArticle.js +14 -0
  125. package/lib/behind-api-client/sales/SalesApp.js +11 -0
  126. package/lib/behind-api-client/sales/SalesV10.js +23 -0
  127. package/lib/behind-api-client/sales/SalesV10Catalogue.js +58 -0
  128. package/lib/behind-api-client/sales/SalesV10Categories.js +15 -0
  129. package/lib/behind-api-client/sales/SalesV10Companies.js +55 -0
  130. package/lib/behind-api-client/sales/SalesV10Company.js +120 -0
  131. package/lib/behind-api-client/sales/SalesV10Group.js +70 -0
  132. package/lib/behind-api-client/sales/SalesV10Groups.js +21 -0
  133. package/lib/behind-api-client/sales/SalesV10Logs.js +14 -0
  134. package/lib/behind-api-client/sales/SalesV10Notes.js +38 -0
  135. package/lib/behind-api-client/sales/SalesV20.js +11 -0
  136. package/lib/behind-api-client/sales/SalesV20Companies.js +26 -0
  137. package/lib/behind-api-client/sales/SalesV20Notes.js +17 -0
  138. package/lib/behind-api-client/sip/SipApp.js +9 -0
  139. package/lib/behind-api-client/sip/SipV10.js +15 -0
  140. package/lib/behind-api-client/sip/SipV10Call.js +83 -0
  141. package/lib/behind-api-client/sip/SipV10Phone.js +44 -0
  142. package/lib/behind-api-client/sip/SipV10Transcript.js +21 -0
  143. package/lib/behind-api-client/sip/SipV10Transcripts.js +21 -0
  144. package/lib/behind-api-client/storage/StorageApp.js +9 -0
  145. package/lib/behind-api-client/storage/StorageV10.js +11 -0
  146. package/lib/behind-api-client/storage/StorageV10File.js +35 -0
  147. package/lib/behind-api-client/storage/StorageV10Upload.js +21 -0
  148. package/lib/behind-api-client/tests/TestsApp.js +9 -0
  149. package/lib/behind-api-client/tests/TestsV10.js +15 -0
  150. package/lib/behind-api-client/tests/TestsV10Cases.js +29 -0
  151. package/lib/behind-api-client/tests/TestsV10CasesExtended.js +14 -0
  152. package/lib/behind-api-client/tests/TestsV10Core.js +14 -0
  153. package/lib/behind-api-client/tests/TestsV10Mail.js +14 -0
  154. package/lib/behind-api-client/tools/ToolsApp.js +9 -0
  155. package/lib/behind-api-client/tools/ToolsV10.js +9 -0
  156. package/lib/behind-api-client/tools/ToolsV10Pdf.js +30 -0
  157. package/package.json +25 -0
@@ -0,0 +1,519 @@
1
+ # RAG Storage API Extension
2
+
3
+ This document extends the main EasyJob JavaScript API Client Documentation with detailed information about the RAG (Retrieval-Augmented Generation) Storage API methods.
4
+
5
+ ## Overview
6
+
7
+ The RAG Storage API provides vector-based semantic search and document storage capabilities. It allows you to store text documents with metadata and perform intelligent semantic searches across stored content. This is particularly useful for building knowledge bases, document retrieval systems, and AI-powered search functionality.
8
+
9
+ ---
10
+
11
+ ## RAG Storage API
12
+
13
+ ### behindAPI.rag.V10.storage.search(query, limit)
14
+ Performs a semantic search across stored documents using vector embeddings to find the most relevant content.
15
+
16
+ **Parameters:**
17
+ - `query` (string, required) - The search query text to find semantically similar documents
18
+ - `limit` (integer, required) - Maximum number of results to return
19
+
20
+ **Usage:**
21
+ ```javascript
22
+ const result = await behindAPI.rag.V10.storage.search(
23
+ "software development best practices",
24
+ 5
25
+ );
26
+
27
+ // Response:
28
+ {
29
+ success: true,
30
+ data: [
31
+ {
32
+ text: "Software development best practices include code reviews...",
33
+ doc_type: "article",
34
+ source: "internal_wiki",
35
+ book_id: "dev-handbook",
36
+ chapter_id: "chapter-3",
37
+ page_id: "page-12",
38
+ similarity_score: 0.92
39
+ },
40
+ {
41
+ text: "Effective software development requires proper testing...",
42
+ doc_type: "guide",
43
+ source: "training_materials",
44
+ book_id: "quality-assurance",
45
+ chapter_id: "chapter-1",
46
+ page_id: "page-5",
47
+ similarity_score: 0.87
48
+ }
49
+ // ... additional results
50
+ ]
51
+ }
52
+ ```
53
+
54
+ ### behindAPI.rag.V10.storage.put(text, docType, source, bookId, chapterId, pageId)
55
+ Stores a text document with metadata in the RAG storage system, automatically generating vector embeddings for semantic search.
56
+
57
+ **Parameters:**
58
+ - `text` (string, required) - The text content to store
59
+ - `docType` (string, required) - The type/category of the document (e.g., "article", "guide", "manual", "faq")
60
+ - `source` (string, required) - The source or origin of the document (e.g., "internal_wiki", "external_api", "user_upload")
61
+ - `bookId` (string, required) - Identifier for the book/collection this document belongs to
62
+ - `chapterId` (string, required) - Identifier for the chapter/section within the book
63
+ - `pageId` (string, required) - Identifier for the specific page/document
64
+
65
+ **Usage:**
66
+ ```javascript
67
+ const result = await behindAPI.rag.V10.storage.put(
68
+ "JavaScript is a versatile programming language used for web development. It supports both functional and object-oriented programming paradigms.",
69
+ "article",
70
+ "internal_wiki",
71
+ "programming-guide",
72
+ "chapter-javascript",
73
+ "page-intro"
74
+ );
75
+
76
+ // Response:
77
+ {
78
+ success: true,
79
+ data: {
80
+ document_id: "550e8400-e29b-41d4-a716-446655440000",
81
+ message: "Document stored successfully"
82
+ }
83
+ }
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Data Structure Reference
89
+
90
+ ### Search Result Object
91
+ Each search result contains:
92
+
93
+ - `text` (string) - The stored text content
94
+ - `doc_type` (string) - Type of document
95
+ - `source` (string) - Source of the document
96
+ - `book_id` (string) - Book/collection identifier
97
+ - `chapter_id` (string) - Chapter/section identifier
98
+ - `page_id` (string) - Page/document identifier
99
+ - `similarity_score` (float) - Semantic similarity score (0-1, where 1 is most similar)
100
+
101
+ ### Storage Response Object
102
+ When storing a document:
103
+
104
+ - `document_id` (UUID) - Unique identifier for the stored document
105
+ - `message` (string) - Status message confirming storage
106
+
107
+ ---
108
+
109
+ ## Complete Usage Examples
110
+
111
+ ### Example 1: Building a Knowledge Base
112
+
113
+ ```javascript
114
+ // Store company documentation in the RAG system
115
+ async function buildKnowledgeBase() {
116
+ const documents = [
117
+ {
118
+ text: "Our company vacation policy allows 20 days of paid time off per year. Employees must request vacation at least 2 weeks in advance.",
119
+ docType: "policy",
120
+ source: "hr_handbook",
121
+ bookId: "employee-handbook",
122
+ chapterId: "benefits",
123
+ pageId: "vacation-policy"
124
+ },
125
+ {
126
+ text: "The onboarding process for new employees takes approximately 2 weeks. It includes orientation, system setup, and initial training sessions.",
127
+ docType: "procedure",
128
+ source: "hr_handbook",
129
+ bookId: "employee-handbook",
130
+ chapterId: "onboarding",
131
+ pageId: "overview"
132
+ },
133
+ {
134
+ text: "All code changes must go through a peer review process before merging to the main branch. At least one approval is required.",
135
+ docType: "policy",
136
+ source: "engineering_wiki",
137
+ bookId: "dev-standards",
138
+ chapterId: "code-review",
139
+ pageId: "process"
140
+ }
141
+ ];
142
+
143
+ try {
144
+ console.log("Building knowledge base...");
145
+
146
+ for (const doc of documents) {
147
+ const result = await behindAPI.rag.V10.storage.put(
148
+ doc.text,
149
+ doc.docType,
150
+ doc.source,
151
+ doc.bookId,
152
+ doc.chapterId,
153
+ doc.pageId
154
+ );
155
+
156
+ if (result.success) {
157
+ console.log(`✓ Stored: ${doc.pageId}`);
158
+ } else {
159
+ console.error(`✗ Failed to store: ${doc.pageId}`);
160
+ }
161
+ }
162
+
163
+ console.log("\nKnowledge base built successfully!");
164
+ return true;
165
+
166
+ } catch (error) {
167
+ console.error("Error building knowledge base:", error);
168
+ return false;
169
+ }
170
+ }
171
+ ```
172
+
173
+ ### Example 2: Semantic Search with Context
174
+
175
+ ```javascript
176
+ // Search for relevant information and provide context
177
+ async function findRelevantInformation(userQuery) {
178
+ try {
179
+ console.log(`Searching for: "${userQuery}"\n`);
180
+
181
+ // Perform semantic search
182
+ const searchResult = await behindAPI.rag.V10.storage.search(userQuery, 3);
183
+
184
+ if (!searchResult.success) {
185
+ console.error("Search failed");
186
+ return null;
187
+ }
188
+
189
+ // Process and display results
190
+ console.log(`Found ${searchResult.data.length} relevant results:\n`);
191
+
192
+ searchResult.data.forEach((result, index) => {
193
+ console.log(`Result ${index + 1}:`);
194
+ console.log(` Similarity: ${(result.similarity_score * 100).toFixed(1)}%`);
195
+ console.log(` Type: ${result.doc_type}`);
196
+ console.log(` Source: ${result.source}`);
197
+ console.log(` Location: ${result.book_id} > ${result.chapter_id} > ${result.page_id}`);
198
+ console.log(` Content: ${result.text.substring(0, 100)}...`);
199
+ console.log();
200
+ });
201
+
202
+ return searchResult.data;
203
+
204
+ } catch (error) {
205
+ console.error("Error during search:", error);
206
+ return null;
207
+ }
208
+ }
209
+
210
+ // Example usage
211
+ findRelevantInformation("How do I request time off?");
212
+ findRelevantInformation("What is the code review process?");
213
+ ```
214
+
215
+ ### Example 3: Document Categorization and Storage
216
+
217
+ ```javascript
218
+ // Organize and store documents by category
219
+ async function organizeDocuments(category, documents) {
220
+ const results = {
221
+ success: 0,
222
+ failed: 0,
223
+ details: []
224
+ };
225
+
226
+ try {
227
+ for (const doc of documents) {
228
+ const result = await behindAPI.rag.V10.storage.put(
229
+ doc.content,
230
+ category,
231
+ doc.source || "default",
232
+ doc.bookId || `${category}-collection`,
233
+ doc.chapterId || "general",
234
+ doc.pageId || `page-${Date.now()}`
235
+ );
236
+
237
+ if (result.success) {
238
+ results.success++;
239
+ results.details.push({
240
+ pageId: doc.pageId,
241
+ status: "stored",
242
+ documentId: result.data.document_id
243
+ });
244
+ } else {
245
+ results.failed++;
246
+ results.details.push({
247
+ pageId: doc.pageId,
248
+ status: "failed",
249
+ error: result.message
250
+ });
251
+ }
252
+ }
253
+
254
+ console.log(`\nCategorization Results for "${category}":`);
255
+ console.log(` Successfully stored: ${results.success}`);
256
+ console.log(` Failed: ${results.failed}`);
257
+
258
+ return results;
259
+
260
+ } catch (error) {
261
+ console.error("Error organizing documents:", error);
262
+ return results;
263
+ }
264
+ }
265
+
266
+ // Example: Store FAQ documents
267
+ const faqDocuments = [
268
+ {
269
+ content: "To reset your password, click on 'Forgot Password' on the login page and follow the instructions sent to your email.",
270
+ source: "support_center",
271
+ bookId: "faqs",
272
+ chapterId: "account",
273
+ pageId: "password-reset"
274
+ },
275
+ {
276
+ content: "You can update your profile information by navigating to Settings > Profile and clicking the Edit button.",
277
+ source: "support_center",
278
+ bookId: "faqs",
279
+ chapterId: "account",
280
+ pageId: "profile-update"
281
+ }
282
+ ];
283
+
284
+ organizeDocuments("faq", faqDocuments);
285
+ ```
286
+
287
+ ### Example 4: Advanced Search and Filtering
288
+
289
+ ```javascript
290
+ // Perform search with result filtering and ranking
291
+ async function advancedSearch(query, options = {}) {
292
+ const {
293
+ minSimilarity = 0.7,
294
+ maxResults = 10,
295
+ filterByType = null,
296
+ filterBySource = null
297
+ } = options;
298
+
299
+ try {
300
+ // Perform initial search with higher limit
301
+ const searchResult = await behindAPI.rag.V10.storage.search(query, maxResults * 2);
302
+
303
+ if (!searchResult.success) {
304
+ return { success: false, message: "Search failed" };
305
+ }
306
+
307
+ // Filter and process results
308
+ let filteredResults = searchResult.data.filter(result => {
309
+ // Filter by minimum similarity
310
+ if (result.similarity_score < minSimilarity) return false;
311
+
312
+ // Filter by document type if specified
313
+ if (filterByType && result.doc_type !== filterByType) return false;
314
+
315
+ // Filter by source if specified
316
+ if (filterBySource && result.source !== filterBySource) return false;
317
+
318
+ return true;
319
+ });
320
+
321
+ // Limit to maxResults
322
+ filteredResults = filteredResults.slice(0, maxResults);
323
+
324
+ // Group by source
325
+ const groupedBySource = filteredResults.reduce((acc, result) => {
326
+ if (!acc[result.source]) {
327
+ acc[result.source] = [];
328
+ }
329
+ acc[result.source].push(result);
330
+ return acc;
331
+ }, {});
332
+
333
+ console.log(`\nAdvanced Search Results for: "${query}"`);
334
+ console.log(`Total matches: ${filteredResults.length}\n`);
335
+
336
+ Object.entries(groupedBySource).forEach(([source, results]) => {
337
+ console.log(`Source: ${source} (${results.length} results)`);
338
+ results.forEach((result, idx) => {
339
+ console.log(` ${idx + 1}. [${result.doc_type}] ${result.book_id}/${result.page_id}`);
340
+ console.log(` Similarity: ${(result.similarity_score * 100).toFixed(1)}%`);
341
+ });
342
+ console.log();
343
+ });
344
+
345
+ return {
346
+ success: true,
347
+ data: filteredResults,
348
+ grouped: groupedBySource
349
+ };
350
+
351
+ } catch (error) {
352
+ console.error("Error in advanced search:", error);
353
+ return { success: false, message: error.message };
354
+ }
355
+ }
356
+
357
+ // Example usage
358
+ advancedSearch("employee benefits", {
359
+ minSimilarity: 0.75,
360
+ maxResults: 5,
361
+ filterByType: "policy",
362
+ filterBySource: "hr_handbook"
363
+ });
364
+ ```
365
+
366
+ ### Example 5: Building a Q&A System
367
+
368
+ ```javascript
369
+ // Create an intelligent Q&A system using RAG storage
370
+ async function answerQuestion(question) {
371
+ try {
372
+ console.log(`Question: ${question}\n`);
373
+
374
+ // Search for relevant context
375
+ const searchResult = await behindAPI.rag.V10.storage.search(question, 3);
376
+
377
+ if (!searchResult.success || searchResult.data.length === 0) {
378
+ return {
379
+ answer: "I couldn't find relevant information to answer this question.",
380
+ confidence: 0,
381
+ sources: []
382
+ };
383
+ }
384
+
385
+ // Get the most relevant result
386
+ const topResult = searchResult.data[0];
387
+ const confidence = topResult.similarity_score;
388
+
389
+ // Build response with sources
390
+ const sources = searchResult.data.map(result => ({
391
+ location: `${result.book_id}/${result.chapter_id}/${result.page_id}`,
392
+ type: result.doc_type,
393
+ relevance: (result.similarity_score * 100).toFixed(1) + "%"
394
+ }));
395
+
396
+ console.log(`Answer (${(confidence * 100).toFixed(1)}% confidence):`);
397
+ console.log(topResult.text);
398
+ console.log("\nSources:");
399
+ sources.forEach((source, idx) => {
400
+ console.log(` ${idx + 1}. ${source.location} (${source.type}) - ${source.relevance} relevant`);
401
+ });
402
+
403
+ return {
404
+ answer: topResult.text,
405
+ confidence: confidence,
406
+ sources: sources,
407
+ allResults: searchResult.data
408
+ };
409
+
410
+ } catch (error) {
411
+ console.error("Error answering question:", error);
412
+ return {
413
+ answer: "An error occurred while processing your question.",
414
+ confidence: 0,
415
+ sources: []
416
+ };
417
+ }
418
+ }
419
+
420
+ // Example usage
421
+ answerQuestion("What is the vacation policy?");
422
+ answerQuestion("How does the code review process work?");
423
+ answerQuestion("What happens during employee onboarding?");
424
+ ```
425
+
426
+ ---
427
+
428
+ ## Best Practices
429
+
430
+ 1. **Document Organization**: Use consistent and hierarchical naming for `bookId`, `chapterId`, and `pageId` to create a logical document structure. This makes it easier to filter and manage stored content.
431
+
432
+ 2. **Text Chunking**: Break large documents into smaller, focused chunks before storing. Optimal chunk size is typically 200-500 words for best semantic search results.
433
+
434
+ 3. **Metadata Consistency**: Maintain consistent `docType` and `source` values across your application to enable effective filtering and categorization.
435
+
436
+ 4. **Search Relevance**: Start with higher limit values and filter results by similarity score on the client side to ensure you capture all relevant content while maintaining quality.
437
+
438
+ 5. **Content Quality**: Store well-formatted, clear text for better embedding quality and search results. Remove unnecessary formatting characters and normalize whitespace.
439
+
440
+ 6. **Incremental Updates**: When updating documents, consider versioning by including version information in the `pageId` or storing timestamps in the text content.
441
+
442
+ 7. **Performance Optimization**: Cache frequently searched queries and their results to reduce API calls and improve response times.
443
+
444
+ 8. **Error Handling**: Always implement proper error handling, as network issues or storage failures can occur during document storage operations.
445
+
446
+ ---
447
+
448
+ ## Error Handling
449
+
450
+ All methods return a response object with a `success` boolean property. When `success` is `false`, a `message` property will contain the error description.
451
+
452
+ ```javascript
453
+ // Example error handling for search
454
+ const searchResult = await behindAPI.rag.V10.storage.search("query", 5);
455
+
456
+ if (!searchResult.success) {
457
+ console.error("Search failed:", searchResult.message);
458
+ // Handle the error appropriately
459
+ return;
460
+ }
461
+
462
+ // Process successful result
463
+ const results = searchResult.data;
464
+
465
+ // Example error handling for put
466
+ const storeResult = await behindAPI.rag.V10.storage.put(
467
+ text,
468
+ docType,
469
+ source,
470
+ bookId,
471
+ chapterId,
472
+ pageId
473
+ );
474
+
475
+ if (!storeResult.success) {
476
+ console.error("Storage failed:", storeResult.message);
477
+ // Implement retry logic or alternative handling
478
+ return;
479
+ }
480
+
481
+ console.log("Document stored:", storeResult.data.document_id);
482
+ ```
483
+
484
+ ---
485
+
486
+ ## Integration Notes
487
+
488
+ The RAG Storage API can be integrated with other EasyJob APIs to enhance functionality:
489
+
490
+ - **Job Descriptions**: Store and search job descriptions for semantic matching with candidate profiles
491
+ - **Applicant Profiles**: Index candidate resumes and profiles for intelligent talent search
492
+ - **Company Documentation**: Build a searchable knowledge base of company policies, procedures, and guidelines
493
+ - **Training Materials**: Create a semantic search system for training content and educational resources
494
+ - **Support Systems**: Power Q&A and support systems with relevant document retrieval
495
+
496
+ ---
497
+
498
+ ## Technical Details
499
+
500
+ ### Vector Embeddings
501
+ The RAG Storage API automatically generates vector embeddings for stored text using advanced language models. These embeddings capture semantic meaning, enabling intelligent search that understands context and intent rather than just keyword matching.
502
+
503
+ ### Semantic Search
504
+ Search queries are converted to vector embeddings and compared against stored documents using cosine similarity. Results are ranked by semantic relevance, with scores ranging from 0 (unrelated) to 1 (highly relevant).
505
+
506
+ ### Language Support
507
+ The system automatically detects and handles multiple languages, ensuring accurate semantic search across multilingual content.
508
+
509
+ ---
510
+
511
+ ## Use Cases
512
+
513
+ 1. **Knowledge Management**: Build internal knowledge bases with intelligent search capabilities
514
+ 2. **Content Recommendation**: Find and recommend related content based on user interests or current context
515
+ 3. **Document Classification**: Automatically categorize and organize documents based on content
516
+ 4. **Talent Matching**: Match job seekers with relevant positions based on semantic similarity of skills and requirements
517
+ 5. **Customer Support**: Power chatbots and support systems with relevant document retrieval
518
+ 6. **Research Assistance**: Help users find relevant research papers, articles, and documentation
519
+ 7. **Training Systems**: Create intelligent training platforms that surface relevant learning materials
package/example.js ADDED
@@ -0,0 +1,35 @@
1
+
2
+ import BehindApiClient from "./lib/behind-api-client/BehindApiClient.js";
3
+ import BehindApiAuthClient from "./lib/behind-api-auth-client/BehindApiAuthClient.js";
4
+ import dotenv from 'dotenv';
5
+
6
+ dotenv.config();
7
+
8
+ (async () => {
9
+
10
+ let behindAuthAPI = new BehindApiAuthClient('https://api.auth.behind.ai');
11
+ let behindAPI = new BehindApiClient('https://api.behind.ai:6002', process.env.ACCESS_TOKEN);
12
+
13
+ behindAPI.selfsigned = true;
14
+
15
+ try{
16
+ try{
17
+ // let auth_result = await behindAuthAPI.authorisation.V10.code.createByEmail(
18
+ // "test@behind.ai",
19
+ // "app-easyjob",
20
+ // process.env.APP_SECRET)
21
+ //
22
+ // console.log(auth_result);
23
+ } catch (e) {
24
+ console.log("Auth method exception:", e)
25
+ }
26
+
27
+ // let result = await behindAPI.easyjob.V10.companies.create("Company name");
28
+ //let result = await behindAPI.request('easyjob/10/companies/create', {name: "Company 3"});
29
+ let result_2 = await behindAPI.request('easyjob/10/companies/get_list', {});
30
+ console.log(result_2);
31
+ } catch (e) {
32
+ console.log("EXCEPTION",e)
33
+ }
34
+
35
+ })()
package/index.cjs ADDED
@@ -0,0 +1,14 @@
1
+
2
+ const BehindApiClient = require("./lib/behind-api-client/BehindApiClient.js");
3
+ const BehindApiAuthClient = require("./lib/behind-api-auth-client/BehindApiAuthClient.js");
4
+
5
+ (async () => {
6
+ // let behindAPI = new BehindApiClient('https://api.behind.ai:6002', 'token')
7
+ // behindAPI.selfsigned = true;
8
+ //
9
+ // let result = await behindAPI.easyjob.V10.companies.create("Company name-1");
10
+ // console.log(result);
11
+ })()
12
+
13
+ module.exports = BehindApiClient;
14
+ module.exports = BehindApiAuthClient;
package/index.js ADDED
@@ -0,0 +1,15 @@
1
+
2
+ import BehindApiClient from "./lib/behind-api-client/BehindApiClient.js";
3
+
4
+ (async () => {
5
+ // let behindAPI = new BehindApiClient('https://api.behind.ai:6002', 'token')
6
+ // behindAPI.selfsigned = true;
7
+ //
8
+ // try{
9
+ // let result = await behindAPI.easyjob.V10.companies.create("Company name");
10
+ // console.log(result);
11
+ // } catch (e) {
12
+ // console.log("EXCEPTION",e)
13
+ // }
14
+
15
+ })()
@@ -0,0 +1,91 @@
1
+ const axios = require('axios');
2
+ const AuthorisationApp = require('./authorisation/AuthorisationApp');
3
+
4
+ class BehindApiAuthClient {
5
+ constructor(endpoint, accessToken) {
6
+ this.endpoint = endpoint;
7
+ this.accessToken = accessToken;
8
+ this.selfsigned = false;
9
+
10
+ // Event handlers
11
+ this.onExpiredHandler = () => {};
12
+ this.onRejectHandler = () => {};
13
+ this.onTooManyRequestsHandler = () => {};
14
+
15
+ // Initialize app modules
16
+ this.authorisation = new AuthorisationApp(this);
17
+ }
18
+
19
+ onExpired(callback) {
20
+ if (typeof callback === 'function') {
21
+ this.onExpiredHandler = callback;
22
+ }
23
+ }
24
+
25
+ onReject(callback) {
26
+ if (typeof callback === 'function') {
27
+ this.onRejectHandler = callback;
28
+ }
29
+ }
30
+
31
+ onTooManyRequests(callback) {
32
+ if (typeof callback === 'function') {
33
+ this.onTooManyRequestsHandler = callback;
34
+ }
35
+ }
36
+
37
+ async apiRequest(app, version, module, action, data) {
38
+ let postData = {};
39
+ postData = Object.assign(postData, data);
40
+
41
+ const headers = {
42
+ Accept: 'application/json',
43
+ 'Content-Type': 'application/json',
44
+ };
45
+
46
+ if (this.accessToken) {
47
+ postData.access_token = this.accessToken;
48
+ headers.AccessToken = this.accessToken;
49
+ headers.Authorization = `Bearer ${this.accessToken}`;
50
+ }
51
+
52
+ try {
53
+ let httpsAgent = null;
54
+ let options = { headers: headers };
55
+
56
+ if (httpsAgent != null) {
57
+ options.httpsAgent = httpsAgent;
58
+ }
59
+
60
+ const response = await axios.post(
61
+ `${this.endpoint}/api/${app}/${version}/${module}/${action}`,
62
+ postData,
63
+ options
64
+ );
65
+
66
+ if (response.status === 200) {
67
+ if (response.data.success) {
68
+ return response.data;
69
+ } else {
70
+ throw response.status;
71
+ }
72
+ } else {
73
+ try {
74
+ if (response.data.code === 1001 || response.data.code === 1009) {
75
+ this.onRejectHandler(response.data);
76
+ }
77
+ if (response.data.code === 1039) {
78
+ this.onTooManyRequestsHandler(response.data);
79
+ }
80
+ } catch (e) {
81
+ // Error handling callback failed
82
+ }
83
+ throw response.data.message;
84
+ }
85
+ } catch (e) {
86
+ throw e;
87
+ }
88
+ }
89
+ }
90
+
91
+ module.exports = BehindApiAuthClient;
@@ -0,0 +1,9 @@
1
+ const AuthorisationV10 = require('./AuthorisationV10');
2
+
3
+ class AuthorisationApp {
4
+ constructor(apiClient) {
5
+ this.V10 = new AuthorisationV10(apiClient);
6
+ }
7
+ }
8
+
9
+ module.exports = AuthorisationApp;
@@ -0,0 +1,9 @@
1
+ const AuthorisationV10Code = require('./AuthorisationV10Code');
2
+
3
+ class AuthorisationV10 {
4
+ constructor(apiClient) {
5
+ this.code = new AuthorisationV10Code(apiClient);
6
+ }
7
+ }
8
+
9
+ module.exports = AuthorisationV10;