@memori.ai/memori-react 6.7.0 → 6.7.2

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.
@@ -2332,37 +2332,6 @@ const MemoriWidget = ({
2332
2332
  }
2333
2333
  }, [integrationConfig, memori.avatarURL, ogImage]);
2334
2334
 
2335
- // check if owner has enough credits
2336
- const needsCredits = tenant?.billingDelegation;
2337
- const [hasEnoughCredits, setHasEnoughCredits] = useState<boolean>(true);
2338
- const checkCredits = async () => {
2339
- if (!tenant?.billingDelegation) return;
2340
-
2341
- try {
2342
- const resp = await getCredits({
2343
- baseUrl: baseUrl,
2344
- userID: ownerUserID,
2345
- userName: ownerUserName,
2346
- tenant: tenantID,
2347
- });
2348
-
2349
- if (resp.enough) {
2350
- setHasEnoughCredits(true);
2351
- } else {
2352
- setHasEnoughCredits(false);
2353
- console.warn('Not enough credits. Required:', resp.required);
2354
- }
2355
- } catch (e) {
2356
- let err = e as Error;
2357
- console.error(err);
2358
- }
2359
- };
2360
- useEffect(() => {
2361
- if (tenant?.billingDelegation) {
2362
- checkCredits();
2363
- }
2364
- }, [tenant?.billingDelegation]);
2365
-
2366
2335
  // X3 state - tag change
2367
2336
  const selectReceiverTag = async (tag: string) => {
2368
2337
  if (!sessionId) return;
@@ -2865,6 +2834,46 @@ const MemoriWidget = ({
2865
2834
  fetchExperts();
2866
2835
  }, [sessionId, fetchExperts]);
2867
2836
 
2837
+ const deepThoughtEnabled =
2838
+ memori.enableDeepThought &&
2839
+ !!loginToken &&
2840
+ !!user?.userID &&
2841
+ user?.pAndCUAccepted;
2842
+
2843
+ // check if owner has enough credits
2844
+ const needsCredits = tenant?.billingDelegation;
2845
+ const [hasEnoughCredits, setHasEnoughCredits] = useState<boolean>(true);
2846
+ const checkCredits = useCallback(async () => {
2847
+ if (!tenant?.billingDelegation) return;
2848
+
2849
+ try {
2850
+ const resp = await getCredits({
2851
+ operation: deepThoughtEnabled
2852
+ ? 'dt_session_creation'
2853
+ : 'session_creation',
2854
+ baseUrl: baseUrl,
2855
+ userID: ownerUserID,
2856
+ userName: ownerUserName,
2857
+ tenant: tenantID,
2858
+ });
2859
+
2860
+ if (resp.enough) {
2861
+ setHasEnoughCredits(true);
2862
+ } else {
2863
+ setHasEnoughCredits(false);
2864
+ console.warn('Not enough credits. Required:', resp.required);
2865
+ }
2866
+ } catch (e) {
2867
+ let err = e as Error;
2868
+ console.error(err);
2869
+ }
2870
+ }, [tenant?.billingDelegation, deepThoughtEnabled]);
2871
+ useEffect(() => {
2872
+ if (tenant?.billingDelegation) {
2873
+ checkCredits();
2874
+ }
2875
+ }, [tenant?.billingDelegation, deepThoughtEnabled]);
2876
+
2868
2877
  const showFullHistory =
2869
2878
  showOnlyLastMessages === undefined
2870
2879
  ? layout !== 'TOTEM' && layout !== 'WEBSITE_ASSISTANT'
@@ -37,7 +37,7 @@ const errors = {
37
37
  USER_CANT_ENABLE_DEEP_THOUGHT: -42,
38
38
  USER_CANT_ENABLE_DCM_INTEGRATION: -43,
39
39
  USER_CANT_ENABLE_CHAINING_OR_BOARD_OF_EXPERTS: -44,
40
- MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS: -45,
40
+ USER_CREATION_BILLING_DENIED_PERMISSION: -46,
41
41
 
42
42
  MEMORI_NOT_FOUND: -51,
43
43
  MEMORI_NOT_ACCESSIBLE: -52,
@@ -62,6 +62,7 @@ const errors = {
62
62
  MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION: -213,
63
63
  MEMORI_NO_PASSWORD_WHEN_PUBLIC: -214,
64
64
  MEMORI_DEEP_THOUGHT_REQUIRES_COMPLETIONS: -215,
65
+ MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS: -216,
65
66
 
66
67
  MEMORI_TRANSFER_MISSING_DESTINATION_USER: -231,
67
68
  MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID: -232,
@@ -155,6 +156,7 @@ const errors = {
155
156
  IMPORTTXT_IMPORT_LIMIT_EXCEEDED: -1632,
156
157
  IMPORTTXT_IMPORT_ON_GPT4_REQUIRES_API_KEY: -1633,
157
158
  IMPORTTXT_IMPORT_REQUIRES_PAYING: -1634,
159
+ IMPORTTXT_BILLING_DENIED_PERMISSION: -1635,
158
160
 
159
161
  EXPORTCSV_MISSING_CSV_SPECS: -1801,
160
162
  EXPORTCSV_MISSING_SEPARATOR: -1802,
@@ -269,7 +269,7 @@
269
269
  "USER_CANT_ENABLE_DEEP_THOUGHT": "User: not enabled to manage Deep Thought",
270
270
  "USER_CANT_ENABLE_DCM_INTEGRATION": "User: not enabled to manage DCM integration",
271
271
  "USER_CANT_ENABLE_CHAINING_OR_BOARD_OF_EXPERTS": "User: not allowed to manage chaining or expert group",
272
- "MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS": "The expert group requires completions to be enabled",
272
+ "USER_CREATION_BILLING_DENIED_PERMISSION": "You don't have enough credits to create a Twin",
273
273
 
274
274
  "MEMORI_NOT_FOUND": "Memori not found",
275
275
  "MEMORI_NOT_ACCESSIBLE": "Memori not accessible",
@@ -294,6 +294,7 @@
294
294
  "MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION": "Memories: TAG and PIN change require separate operations",
295
295
  "MEMORI_NO_PASSWORD_WHEN_PUBLIC": "Memories: no password required when public",
296
296
  "MEMORI_DEEP_THOUGHT_REQUIRES_COMPLETIONS": "Deep Thought requires completions to be enabled",
297
+ "MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS": "The expert group requires completions to be enabled",
297
298
 
298
299
  "MEMORI_TRANSFER_MISSING_DESTINATION_USER": "Transfer: missing destination user",
299
300
  "MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID": "Transfer: invalid destination user ID",
@@ -387,6 +388,7 @@
387
388
  "IMPORTTXT_IMPORT_LIMIT_EXCEEDED": "Import TXT: import limit exceeded",
388
389
  "IMPORTTXT_IMPORT_ON_GPT4_REQUIRES_API_KEY": "Import TXT: import on GPT-4 requires API key",
389
390
  "IMPORTTXT_IMPORT_REQUIRES_PAYING": "Import TXT: Import requires a paying plan",
391
+ "IMPORTTXT_BILLING_DENIED_PERMISSION": "Import TXT: you don't have enough credits for the operation",
390
392
 
391
393
  "EXPORTCSV_MISSING_CSV_SPECS": "CSV export: missing CSV specifications",
392
394
  "EXPORTCSV_MISSING_SEPARATOR": "CSV export: missing separator",
@@ -268,7 +268,7 @@
268
268
  "USER_CANT_ENABLE_DEEP_THOUGHT": "Utente: non abilitato a gestire Pensiero Profondo",
269
269
  "USER_CANT_ENABLE_DCM_INTEGRATION": "Utente: non abilitato a gestire l'integrazione con DCM",
270
270
  "USER_CANT_ENABLE_CHAINING_OR_BOARD_OF_EXPERTS": "Utente: non abilitato a gestire la concatenazione o il gruppo di esperti",
271
- "MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS": "Il gruppo di esperti richiede l'abilitazione delle completions",
271
+ "USER_CREATION_BILLING_DENIED_PERMISSION": "Non hai crediti sufficienti per creare un Twin",
272
272
 
273
273
  "MEMORI_NOT_FOUND": "Memori non trovato",
274
274
  "MEMORI_NOT_ACCESSIBLE": "Memori non accessibile",
@@ -293,6 +293,7 @@
293
293
  "MEMORI_GIVER_TAG_PIN_CHANGE_REQUIRES_SEPARATE_OPERATION": "Memori: cambio TAG e PIN richiedono operazioni separate",
294
294
  "MEMORI_NO_PASSWORD_WHEN_PUBLIC": "Memori: password non richiesta su Memori pubblico",
295
295
  "MEMORI_DEEP_THOUGHT_REQUIRES_COMPLETIONS": "Pensiero Profondo richiede l'abilitazione delle completions",
296
+ "MEMORI_BOARD_OF_EXPERTS_REQUIRES_COMPLETIONS": "Il gruppo di esperti richiede l'abilitazione delle completions",
296
297
 
297
298
  "MEMORI_TRANSFER_MISSING_DESTINATION_USER": "Trasferimento: utente di destinazione mancante",
298
299
  "MEMORI_TRANSFER_INVALID_DESTINATION_USER_ID": "Trasferimento: ID utente di destinazione non valido",
@@ -386,6 +387,7 @@
386
387
  "IMPORTTXT_IMPORT_LIMIT_EXCEEDED": "Importazione TXT: limite importazione superato",
387
388
  "IMPORTTXT_IMPORT_ON_GPT4_REQUIRES_API_KEY": "Importazione TXT: importazione su GPT-4 richiede API key",
388
389
  "IMPORTTXT_IMPORT_REQUIRES_PAYING": "Importazione TXT: importazione richiede un piano a pagamento",
390
+ "IMPORTTXT_BILLING_DENIED_PERMISSION": "Importazione TXT: non hai crediti sufficienti per l'operazione",
389
391
 
390
392
  "EXPORTCSV_MISSING_CSV_SPECS": "Esportazione CSV: specifiche CSV mancanti",
391
393
  "EXPORTCSV_MISSING_SEPARATOR": "Esportazione CSV: separatore mancante",