@aiqa/sdk 1.3.0 → 1.4.0

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
@@ -138,6 +138,16 @@ Adds a fact to the active application (Promise-based).
138
138
  ```typescript
139
139
  {
140
140
  id: string;
141
+ /**
142
+ * Optional. Stable identifier for the underlying question, shared across
143
+ * applications and conversations. When provided it is used to look up (or
144
+ * create) the matching question row in the database instead of `id`. When
145
+ * omitted, `id` is used (legacy behavior).
146
+ *
147
+ * Keep this consistent across calls for the "same" question — see
148
+ * "Question identity and questionId" below.
149
+ */
150
+ questionId?: string;
141
151
  question: string;
142
152
  expected_answer: any;
143
153
  answer_format: { type: "STRING" }
@@ -158,6 +168,7 @@ Adds a fact to the active application (Promise-based).
158
168
  ```typescript
159
169
  const isMatched = await sdk.addFact({
160
170
  id: "fact-123",
171
+ questionId: "agreement-q",
161
172
  question: "Do you agree?",
162
173
  expected_answer: "Yes",
163
174
  answer_format: { type: "STRING" },
@@ -165,6 +176,37 @@ const isMatched = await sdk.addFact({
165
176
  });
166
177
  ```
167
178
 
179
+ ##### Question identity and `questionId`
180
+
181
+ `id` identifies an instance of a fact within a single conversation. `questionId`
182
+ is an optional field that identifies the underlying question across every
183
+ application and conversation that asks it. They're separated so you can give
184
+ each fact instance its own `id` (e.g. a per-call uuid) while still pointing at a
185
+ stable question identity.
186
+
187
+ Two server-side features are scoped per question identity:
188
+
189
+ - **Accuracy improvements.** Per-question signals (flags, model tweaks, fuzzy
190
+ matches) accumulate against the question row. Splitting the same logical
191
+ question across multiple identities splits these signals and resets the
192
+ accuracy gains you've already earned.
193
+ - **Remaps from the management dashboard.** When an operator remaps a question
194
+ in the dashboard, the remap is stored on the question row. A subsequent call
195
+ with a different identity won't pick up the remap.
196
+
197
+ The "question identity" the server uses is `questionId` if you sent one,
198
+ otherwise `id`. So:
199
+
200
+ - If your `id` is already stable across calls for the same logical question,
201
+ omitting `questionId` is fine — both features above still work, just keyed off
202
+ `id`.
203
+ - If your `id` varies per call (per-call uuid, ephemeral instance id, etc.),
204
+ send a stable `questionId`. Otherwise each call looks like a new question and
205
+ you lose the features above.
206
+ - Once you've picked an identity for a question, don't change it. If you must
207
+ rename, coordinate with the team owning the dashboard so remaps and
208
+ historical signals can be migrated.
209
+
168
210
  #### `getFacts()`
169
211
 
170
212
  Retrieves all facts for the application (Promise-based). Each fact includes a `metadata` field containing whatever was passed to `addFact()`. Facts added without `metadata` return `{}`.
@@ -289,6 +331,16 @@ type ApplicationFact = ApplicationFactInput & {
289
331
  ```typescript
290
332
  type ApplicationFactInput = {
291
333
  id: string;
334
+ /**
335
+ * Optional. Stable identifier for the underlying question, shared across
336
+ * applications and conversations. Used to look up (or create) the matching
337
+ * question row in the database when provided. When omitted, `id` is used.
338
+ *
339
+ * Keep this consistent across calls — accuracy improvements and remaps
340
+ * configured in the management dashboard are scoped per `questionId`. See
341
+ * "Question identity and questionId" under `addFact()`.
342
+ */
343
+ questionId?: string;
292
344
  question: string;
293
345
  expected_answer: any;
294
346
  answer_format: {
@@ -54,6 +54,14 @@ type ApplicationFactAnswerFormat = {
54
54
  };
55
55
  type ApplicationFactInput = {
56
56
  id: string;
57
+ /**
58
+ * Stable identifier for the underlying question, shared across applications and
59
+ * conversations. When provided it is used to look up (or create) the matching
60
+ * question row in the database instead of `id`. Keep this consistent across
61
+ * calls — accuracy improvements and remaps configured in the management
62
+ * dashboard are scoped per `questionId`.
63
+ */
64
+ questionId?: string;
57
65
  question: string;
58
66
  expected_answer: any;
59
67
  answer_format: ApplicationFactAnswerFormat;
@@ -3396,7 +3396,7 @@ var compareVersions = (left, right) => {
3396
3396
  // package.json
3397
3397
  var package_default = {
3398
3398
  name: "@aiqa/sdk",
3399
- version: "1.2.0",
3399
+ version: "1.4.0-develop.1",
3400
3400
  main: "dist/node/node.js",
3401
3401
  module: "dist/node/node.js",
3402
3402
  types: "dist/node/node.d.ts",