@magmamath/students-features 0.3.1-rc.2 → 0.3.1-rc.4

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 (79) hide show
  1. package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js +1 -2
  2. package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js.map +1 -1
  3. package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js +2 -9
  4. package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
  5. package/dist/commonjs/features/chatbot/components/Chatbot.js +1 -7
  6. package/dist/commonjs/features/chatbot/components/Chatbot.js.map +1 -1
  7. package/dist/commonjs/features/chatbot/index.js.map +1 -1
  8. package/dist/commonjs/features/chatbot/model/ChatBotMessageHandler.js +4 -2
  9. package/dist/commonjs/features/chatbot/model/ChatBotMessageHandler.js.map +1 -1
  10. package/dist/commonjs/features/chatbot/model/ChatBotModel.js +36 -15
  11. package/dist/commonjs/features/chatbot/model/ChatBotModel.js.map +1 -1
  12. package/dist/commonjs/features/chatbot/model/translation.js +9 -7
  13. package/dist/commonjs/features/chatbot/model/translation.js.map +1 -1
  14. package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
  15. package/dist/module/features/chatbot/components/Alternatives/Alternatives.js +1 -2
  16. package/dist/module/features/chatbot/components/Alternatives/Alternatives.js.map +1 -1
  17. package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js +2 -9
  18. package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
  19. package/dist/module/features/chatbot/components/Chatbot.js +1 -7
  20. package/dist/module/features/chatbot/components/Chatbot.js.map +1 -1
  21. package/dist/module/features/chatbot/index.js.map +1 -1
  22. package/dist/module/features/chatbot/model/ChatBotMessageHandler.js +4 -2
  23. package/dist/module/features/chatbot/model/ChatBotMessageHandler.js.map +1 -1
  24. package/dist/module/features/chatbot/model/ChatBotModel.js +36 -15
  25. package/dist/module/features/chatbot/model/ChatBotModel.js.map +1 -1
  26. package/dist/module/features/chatbot/model/translation.js +9 -7
  27. package/dist/module/features/chatbot/model/translation.js.map +1 -1
  28. package/dist/module/features/chatbot/types/model.types.js.map +1 -1
  29. package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts +1 -1
  30. package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts.map +1 -1
  31. package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts +1 -4
  32. package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -1
  33. package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts +1 -4
  34. package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts.map +1 -1
  35. package/dist/typescript/commonjs/features/chatbot/index.d.ts +1 -1
  36. package/dist/typescript/commonjs/features/chatbot/index.d.ts.map +1 -1
  37. package/dist/typescript/commonjs/features/chatbot/model/ChatBotMessageHandler.d.ts +1 -1
  38. package/dist/typescript/commonjs/features/chatbot/model/ChatBotMessageHandler.d.ts.map +1 -1
  39. package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts +4 -2
  40. package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
  41. package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts +5 -5
  42. package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts.map +1 -1
  43. package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +3 -8
  44. package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts.map +1 -1
  45. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +14 -3
  46. package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
  47. package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts +1 -3
  48. package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts.map +1 -1
  49. package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts +1 -1
  50. package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts.map +1 -1
  51. package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts +1 -4
  52. package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -1
  53. package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts +1 -4
  54. package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts.map +1 -1
  55. package/dist/typescript/module/features/chatbot/index.d.ts +1 -1
  56. package/dist/typescript/module/features/chatbot/index.d.ts.map +1 -1
  57. package/dist/typescript/module/features/chatbot/model/ChatBotMessageHandler.d.ts +1 -1
  58. package/dist/typescript/module/features/chatbot/model/ChatBotMessageHandler.d.ts.map +1 -1
  59. package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts +4 -2
  60. package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
  61. package/dist/typescript/module/features/chatbot/model/translation.d.ts +5 -5
  62. package/dist/typescript/module/features/chatbot/model/translation.d.ts.map +1 -1
  63. package/dist/typescript/module/features/chatbot/types/api.types.d.ts +3 -8
  64. package/dist/typescript/module/features/chatbot/types/api.types.d.ts.map +1 -1
  65. package/dist/typescript/module/features/chatbot/types/model.types.d.ts +14 -3
  66. package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
  67. package/dist/typescript/module/features/chatbot/types/translation.types.d.ts +1 -3
  68. package/dist/typescript/module/features/chatbot/types/translation.types.d.ts.map +1 -1
  69. package/package.json +1 -1
  70. package/src/features/chatbot/components/Alternatives/Alternatives.tsx +3 -3
  71. package/src/features/chatbot/components/ChatMessages/ChatbotMessages.tsx +2 -12
  72. package/src/features/chatbot/components/Chatbot.tsx +1 -10
  73. package/src/features/chatbot/index.ts +1 -0
  74. package/src/features/chatbot/model/ChatBotMessageHandler.ts +2 -0
  75. package/src/features/chatbot/model/ChatBotModel.ts +42 -11
  76. package/src/features/chatbot/model/translation.ts +10 -6
  77. package/src/features/chatbot/types/api.types.ts +3 -6
  78. package/src/features/chatbot/types/model.types.ts +16 -3
  79. package/src/features/chatbot/types/translation.types.ts +1 -3
@@ -1,13 +1,10 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { ChatbotModel } from '../../model/ChatBotModel';
3
- import { PostMessagePayload } from '../../types/api.types';
4
3
  import { AUDIO_CONFIG, DEFAULT_VOICE } from '../../constants';
5
4
  import { ChatbotRenderer } from '../../types/model.types';
6
5
  type ChatbotMessagesProps = {
7
6
  model: ChatbotModel;
8
7
  isHintFeedback: boolean;
9
- sendHelpRequestPayload: Omit<PostMessagePayload, 'type'>;
10
- translationTargetLanguage: string;
11
8
  sanitizeSpeechInput: (speech: string) => string;
12
9
  isTextToSpeechEnabled: boolean;
13
10
  textToSpeechConfig?: {
@@ -16,6 +13,6 @@ type ChatbotMessagesProps = {
16
13
  };
17
14
  renderer?: (props: ChatbotRenderer) => ReactNode;
18
15
  };
19
- export declare const ChatbotMessages: ({ model, isHintFeedback, sendHelpRequestPayload, translationTargetLanguage, sanitizeSpeechInput, isTextToSpeechEnabled, textToSpeechConfig, renderer, }: ChatbotMessagesProps) => React.JSX.Element;
16
+ export declare const ChatbotMessages: ({ model, isHintFeedback, sanitizeSpeechInput, isTextToSpeechEnabled, textToSpeechConfig, renderer, }: ChatbotMessagesProps) => React.JSX.Element;
20
17
  export {};
21
18
  //# sourceMappingURL=ChatbotMessages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChatbotMessages.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/chatbot/components/ChatMessages/ChatbotMessages.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAU,MAAM,OAAO,CAAA;AAGhD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAyB,MAAM,iBAAiB,CAAA;AACpF,OAAO,EAAkB,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzE,KAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,YAAY,CAAA;IACnB,cAAc,EAAE,OAAO,CAAA;IACvB,sBAAsB,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAA;IACxD,yBAAyB,EAAE,MAAM,CAAA;IACjC,mBAAmB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAA;IAC/C,qBAAqB,EAAE,OAAO,CAAA;IAC9B,kBAAkB,CAAC,EAAE;QACnB,KAAK,EAAE,OAAO,aAAa,CAAA;QAC3B,WAAW,EAAE,OAAO,YAAY,CAAA;KACjC,CAAA;IACD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,SAAS,CAAA;CACjD,CAAA;AAQD,eAAO,MAAM,eAAe,4JASzB,oBAAoB,sBA+EtB,CAAA"}
1
+ {"version":3,"file":"ChatbotMessages.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/chatbot/components/ChatMessages/ChatbotMessages.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAU,MAAM,OAAO,CAAA;AAGhD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIvD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAyB,MAAM,iBAAiB,CAAA;AACpF,OAAO,EAAkB,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzE,KAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,YAAY,CAAA;IACnB,cAAc,EAAE,OAAO,CAAA;IACvB,mBAAmB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAA;IAC/C,qBAAqB,EAAE,OAAO,CAAA;IAC9B,kBAAkB,CAAC,EAAE;QACnB,KAAK,EAAE,OAAO,aAAa,CAAA;QAC3B,WAAW,EAAE,OAAO,YAAY,CAAA;KACjC,CAAA;IACD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,SAAS,CAAA;CACjD,CAAA;AAQD,eAAO,MAAM,eAAe,yGAOzB,oBAAoB,sBA0EtB,CAAA"}
@@ -1,14 +1,11 @@
1
1
  import { ComponentType, PropsWithChildren, ReactNode } from 'react';
2
2
  import { ChatbotModel } from '../model/ChatBotModel';
3
- import { PostMessagePayload } from '../types/api.types';
4
3
  import { AUDIO_CONFIG, DEFAULT_VOICE } from '../constants';
5
4
  import { ChatbotRenderer } from '../types/model.types';
6
5
  import React from 'react';
7
6
  type ChatbotProps = {
8
7
  model: ChatbotModel;
9
- translationTargetLanguage: string;
10
8
  isHintFeedback: boolean;
11
- sendHelpRequestPayload: Omit<PostMessagePayload, 'type'>;
12
9
  sanitizeSpeechInput: (speech: string) => string;
13
10
  isTextToSpeechEnabled: boolean;
14
11
  isTranslationEnabled: boolean;
@@ -23,6 +20,6 @@ type ChatbotProps = {
23
20
  height: number;
24
21
  };
25
22
  };
26
- export declare const Chatbot: ({ model, translationTargetLanguage, isHintFeedback, sendHelpRequestPayload, sanitizeSpeechInput, isTextToSpeechEnabled, textToSpeechConfig, isTranslationEnabled, renderer, ButtonWrapper, iconSize, }: ChatbotProps) => React.JSX.Element | null;
23
+ export declare const Chatbot: ({ model, isHintFeedback, sanitizeSpeechInput, isTextToSpeechEnabled, textToSpeechConfig, isTranslationEnabled, renderer, ButtonWrapper, iconSize, }: ChatbotProps) => React.JSX.Element | null;
27
24
  export {};
28
25
  //# sourceMappingURL=Chatbot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Chatbot.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/components/Chatbot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAGp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CAAA;AACtD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,YAAY,CAAA;IACnB,cAAc,EAAE,OAAO,CAAA;IACvB,mBAAmB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAA;IAC/C,qBAAqB,EAAE,OAAO,CAAA;IAC9B,oBAAoB,EAAE,OAAO,CAAA;IAC7B,kBAAkB,CAAC,EAAE;QACnB,KAAK,EAAE,OAAO,aAAa,CAAA;QAC3B,WAAW,EAAE,OAAO,YAAY,CAAA;KACjC,CAAA;IACD,aAAa,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAA;IAC/C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,SAAS,CAAA;IAChD,QAAQ,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAC7C,CAAA;AAED,eAAO,MAAM,OAAO,wJAUjB,YAAY,6BAqCd,CAAA"}
@@ -1,7 +1,7 @@
1
1
  export { Chatbot } from './components/Chatbot';
2
2
  export { ChatbotModel } from './model/ChatBotModel';
3
3
  export { AudioStatus, type AudioProvider } from './types/t2s.types';
4
- export { MessageVariant, type ConversationMessage, type ChatbotRenderer, type ChatbotModelProps, } from './types/model.types';
4
+ export { MessageVariant, type ConversationMessage, type ChatbotRenderer, type ChatbotModelProps, type IChatDrawBoardAdapter, } from './types/model.types';
5
5
  export type { PostMessageResponse, ChatAnswer } from './types/api.types';
6
6
  export { ChatMessageHandler } from './model/ChatBotMessageHandler';
7
7
  export { DefaultMessagesCreator } from './model/DefaultMessageCreator';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/chatbot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,EACL,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/chatbot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACnE,OAAO,EACL,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA"}
@@ -23,7 +23,7 @@ export declare class ChatMessageHandler {
23
23
  constructor({ drawBoardAdapter, api, messagesLimit, messages, }: ChatMessageHandlerProps);
24
24
  bindKeyStore($store: Store<string>): this;
25
25
  private getThreadItem;
26
- readonly postMessageFx: ({ problemAnswer, problem, answer, language, }: PostMessagePayload) => Promise<PostMessageResponse>;
26
+ readonly postMessageFx: ({ problemAnswer, problem, answer, language, imageAltText, }: PostMessagePayload) => Promise<PostMessageResponse>;
27
27
  resetThread: import("effector/effector.umd").Effect<ResetCacheProps, void, Error>;
28
28
  resetAll(): void;
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ChatBotMessageHandler.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/model/ChatBotMessageHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAEhC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAG7E,KAAK,uBAAuB,GAAG;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,eAAe,CAAA;IACzB,gBAAgB,EAAE,qBAAqB,CAAA;IACvC,GAAG,EAAE;QACH,OAAO,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAA;KAC/D,CAAA;CACF,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAA;IACpB,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuB;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgC;IAExD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAA;IAC9B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,cAAc,CAA4B;IAElD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAA;gBAEb,EACjB,gBAAgB,EAChB,GAAG,EACH,aAA6D,EAC7D,QAAQ,GACT,EAAE,uBAAuB;IAOnB,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;YAQ3B,aAAa;IAc3B,SAAgB,aAAa,kDAK1B,kBAAkB,KAAG,OAAO,CAAC,mBAAmB,CAAC,CAqBnD;IAEM,WAAW,uEA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
@@ -1,5 +1,5 @@
1
1
  import { type Store } from 'effector';
2
- import { ChatbotModelProps, ConversationMessage, SendHelpParams, SetHintMessageProps } from '../types/model.types';
2
+ import { ChatbotContext, ChatbotModelProps, ConversationMessage, SendHelpParams, SetHintMessageProps, StartConversationProps } from '../types/model.types';
3
3
  import { GetAlternativesResponse } from '../types/api.types';
4
4
  import { ChatbotAPI } from './api';
5
5
  import { ChatbotTranslation } from './translation';
@@ -22,6 +22,8 @@ export declare class ChatbotModel {
22
22
  readonly removeLastMessage: import("effector").EventCallable<void>;
23
23
  private readonly setLastMessageKey;
24
24
  readonly $lastMessageKey: import("effector").StoreWritable<string | null>;
25
+ readonly setContext: import("effector").EventCallable<ChatbotContext | null>;
26
+ readonly $context: import("effector").StoreWritable<ChatbotContext | null>;
25
27
  readonly setScrollActive: import("effector").EventCallable<boolean>;
26
28
  readonly $isScrollActive: import("effector").StoreWritable<boolean>;
27
29
  readonly sendHelpRequestFx: import("effector").Effect<SendHelpParams, void, Error>;
@@ -38,7 +40,7 @@ export declare class ChatbotModel {
38
40
  constructor({ api, messages, $key }: ChatbotModelProps);
39
41
  private createSendHelpRequestFx;
40
42
  private initChatReplyWatcher;
41
- readonly startConversation: import("effector").Effect<void, void | undefined, Error>;
43
+ readonly startConversation: import("effector").Effect<void | StartConversationProps, void | undefined, Error>;
42
44
  setHintMessage({ key, ...message }: SetHintMessageProps): void;
43
45
  readonly reinitConversation: import("effector").Effect<ReinitConversationProps, void, Error>;
44
46
  bindKey($store: Store<string>): this;
@@ -1 +1 @@
1
- {"version":3,"file":"ChatBotModel.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/model/ChatBotModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,KAAK,EAIX,MAAM,UAAU,CAAA;AAEjB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EAEd,mBAAmB,EAEpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,uBAAuB,EAA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yB;IAC3C,QAAQ,CAAC,UAAU,yCAAgB;IACnC,QAAQ,CAAC,OAAO,4CAA0E;IAE1F,SAAgB,iBAAiB,yCAAgB;IACjD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAwB;IAC1D,SAAgB,eAAe,kDAAwC;IAEvE,SAAgB,UAAU,0DAAuC;IACjE,SAAgB,QAAQ,0DAAiC;IAEzD,QAAQ,CAAC,eAAe,4CAAyB;IACjD,QAAQ,CAAC,eAAe,4CAAuC;IAE/D,QAAQ,CAAC,iBAAiB,yDAAA;IAE1B,QAAQ,CAAC,eAAe,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAA;IAEvD,QAAQ,CAAC,QAAQ,iGAAkD;IACnE,QAAQ,CAAC,SAAS,kFAAmC;IACrD,QAAQ,CAAC,cAAc,mFAAoC;IAE3D,SAAgB,gBAAgB;;;;;OAe/B;gBAEW,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,iBAAiB;IA4BtD,OAAO,CAAC,uBAAuB;IA0E/B,OAAO,CAAC,oBAAoB;IAe5B,SAAgB,iBAAiB,oFAc/B;IAEK,cAAc,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,EAAE,mBAAmB;IAW9D,SAAgB,kBAAkB,kEAoBhC;IAEK,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;IAQ7B,mBAAmB,CAAC,aAAa,EAAE,aAAa;CAIxD"}
@@ -1,6 +1,6 @@
1
1
  import { EventCallable, Store } from 'effector';
2
2
  import { TranslateMessageFxProps } from '../types/translation.types';
3
- import { ChatbotMessages, ConversationMessage } from '../types/model.types';
3
+ import { ChatbotContext, ChatbotMessages, ConversationMessage } from '../types/model.types';
4
4
  import { GetAlternativesResponse } from '../types/api.types';
5
5
  import { ChatbotAPI } from './api';
6
6
  import { EntityFieldStore } from '../../../lib/effector/createEntityFieldStore';
@@ -9,6 +9,7 @@ type ChatbotTranslationProps = {
9
9
  $key: Store<string>;
10
10
  defaultMessages: ChatbotMessages;
11
11
  messagesModel: EntityFieldStore<ConversationMessage[]>;
12
+ $context: Store<ChatbotContext | null>;
12
13
  alternativesModel: {
13
14
  set: EventCallable<GetAlternativesResponse | null>;
14
15
  $store: Store<GetAlternativesResponse | null>;
@@ -17,15 +18,14 @@ type ChatbotTranslationProps = {
17
18
  export declare class ChatbotTranslation {
18
19
  private readonly api;
19
20
  private readonly $key;
21
+ private readonly $context;
20
22
  private readonly defaultMessages;
21
23
  private readonly messagesModel;
22
24
  private readonly alternativesModel;
23
25
  readonly setIsTranslated: EventCallable<boolean>;
24
26
  readonly $isTranslated: import("effector").StoreWritable<boolean>;
25
- readonly translateAllMessagesFx: import("effector").Effect<{
26
- targetLanguage: string;
27
- }, ConversationMessage[], Error>;
28
- constructor({ api, $key, defaultMessages, messagesModel, alternativesModel, }: ChatbotTranslationProps);
27
+ readonly translateAllMessagesFx: import("effector").Effect<void, ConversationMessage[], Error>;
28
+ constructor({ api, $key, defaultMessages, messagesModel, alternativesModel, $context, }: ChatbotTranslationProps);
29
29
  private shouldSkipTranslation;
30
30
  private initTranslationSamples;
31
31
  private translateRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/model/translation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,aAAa,EAAmB,KAAK,EAAE,MAAM,UAAU,CAAA;AACnG,OAAO,EAGL,uBAAuB,EAExB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAO/E,KAAK,uBAAuB,GAAG;IAC7B,GAAG,EAAE,UAAU,CAAA;IACf,IAAI,EAAE,KAAK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@@ -15,18 +15,12 @@ export type GetAlternativesResponse = {
15
15
  };
16
16
  };
17
17
  export type PostMessagePayload = {
18
- hint: string | null;
19
18
  language: string;
20
- problem: string;
21
19
  problemAnswer: string[];
22
- solutionImages: {
23
- canvasDrawing: string | null;
24
- };
25
- type: string;
26
- problemId?: string;
27
20
  answer?: string | string[];
28
- grade?: string | null;
29
21
  threadId?: string | null;
22
+ problem: string;
23
+ imageAltText?: string;
30
24
  };
31
25
  export type PostMessageResponse = {
32
26
  message: string;
@@ -74,6 +68,7 @@ export type ChatHintPayload = {
74
68
  stroke?: Stroke[];
75
69
  previousHint?: string;
76
70
  language: string;
71
+ imageAltText?: string;
77
72
  };
78
73
  export type ChatHintResponse = {
79
74
  message: string;
@@ -1 +1 @@
1
- {"version":3,"file":"api.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/types/api.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,cAAc,EAAE,MAAM,CAAA;IACtB,oBAAoB,EAAE,MAAM,CAAA;CAC7B,GAAG,IAAI,CAAA;AAER,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,OAAO,EAAE;QACP,OAAO,EAAE,UAAU,EAAE,CAAA;QACrB,KAAK,EAAE,UAAU,EAAE,CAAA;KACpB,CAAA;CACF,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,cAAc,EAAE;QAAE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,C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Ae,GAAG;IAC5B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA"}
1
+ {"version":3,"file":"api.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/types/api.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,cAAc,EAAE,MAAM,CAAA;IACtB,oBAAoB,EAAE,MAAM,CAAA;CAC7B,GAAG,IAAI,CAAA;AAER,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,OAAO,EAAE;QACP,OAAO,EAAE,UAAU,EAAE,CAAA;QACrB,KAAK,EAAE,UAAU,EAAE,CAAA;KACpB,CAAA;CACF,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;I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7B,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA"}
@@ -27,22 +27,25 @@ export type ChatbotModelProps = {
27
27
  messages: ChatbotMessages;
28
28
  };
29
29
  export type SendHelpParams = {
30
- payload: PostMessagePayload;
31
30
  message: string;
32
- translationTargetLanguage: string;
33
31
  translatedMessage?: string;
34
32
  };
35
33
  export type SendHelpProps = SendHelpParams & {
36
34
  key: string;
37
35
  isTranslated: boolean;
36
+ threadId: string;
37
+ context: ChatbotContext | null;
38
38
  };
39
39
  export type SetHintMessageProps = {
40
40
  key: string;
41
41
  } & ConversationMessage;
42
+ export type StartConversationProps = {
43
+ initOnly?: boolean;
44
+ };
42
45
  export type StartConversationFxData = {
43
46
  key: string;
44
47
  messages: ConversationMessage[];
45
- };
48
+ } & StartConversationProps;
46
49
  export declare enum MessageVariant {
47
50
  SENT = "sent",
48
51
  RECEIVED = "received"
@@ -56,4 +59,12 @@ export type CreateMessageResponse = ExtendWithOptional<PostMessageResponse, Conv
56
59
  export type IChatDrawBoardAdapter = {
57
60
  getVisibleStrokes(): Promise<Stroke[] | null>;
58
61
  };
62
+ export type ChatbotContext = {
63
+ language: string;
64
+ problem: string;
65
+ problemAnswer: string[];
66
+ answer?: string | string[];
67
+ translationTargetLanguage: string;
68
+ imageDescription?: string;
69
+ };
59
70
  //# sourceMappingURL=model.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/types/model.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,UAAU,EACV,sBAAsB,EACtB,MAAM,EACP,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAE/D,MAAM,MAAM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,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAA;CACZ,GAAG,mBAAmB,CAAA;AAEvB,MAAM,MAAM,uBAAuB,GAAG;IACpC,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,mBAAmB,EAAE,CAAA;CAChC,CAAA;AAED,oBAAY,cAAc;IACxB,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,cAAc,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAA;AAEhG,MAAM,MAAM,qBAAqB,GAAG;IAClC,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAA;CAC9C,CAAA"}
1
+ {"version":3,"file":"model.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/types/model.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,UAAU,EACV,sBAAsB,EACtB,MAAM,EACP,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAE/D,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,UAAU,EAAE,CAAA;IACrB,YAAY,EAAE,OAAO,CAAA;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED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,CAAA;CAChC,GAAG,sBAAsB,CAAA;AAE1B,oBAAY,cAAc;IACxB,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,cAAc,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAA;AAEhG,MAAM,MAAM,qBAAqB,GAAG;IAClC,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAA;CAC9C,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC1B,yBAAyB,EAAE,MAAM,CAAA;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA"}
@@ -2,9 +2,7 @@ import { ConversationMessage } from './model.types';
2
2
  import { GetAlternativesResponse } from './api.types';
3
3
  export type TranslateBatchFxProps = {
4
4
  messages: ConversationMessage[];
5
- params: {
6
- targetLanguage: string;
7
- };
5
+ targetLanguage: string;
8
6
  alternatives: GetAlternativesResponse | null;
9
7
  };
10
8
  export type TranslateMessageFxProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"translation.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/types/translation.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IAC/B,MAAM,EAAE;QACN,cAAc,EAAE,MAAM,CAAA;KACvB,CAAA;IACD,YAAY,EAAE,uBAAuB,GAAG,IAAI,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IAC/B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG;IAC9C,YAAY,EAAE,uBAAuB,CAAA;IACrC,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAC7B,CAAA;AACD,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,uBAAuB,GAAG,IAAI,CAAA;IAC5C,WAAW,EAAE,mBAAmB,GAAG,SAAS,CAAA;CAC7C,CAAA;AACD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAC5B,YAAY,EAAE;QACZ,KAAK,EAAE,MAAM,EAAE,CAAA;QACf,OAAO,EAAE,MAAM,EAAE,CAAA;KAClB,GAAG,IAAI,CAAA;CACT,CAAA;AAED,MAAM,MAAM,qBAAqB,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI;IACzE,QAAQ,EAAE,IAAI,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA"}
1
+ {"version":3,"file":"translation.types.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chatbot/types/translation.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IAC/B,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,uBAAuB,GAAG,IAAI,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,mBAAmB,EAAE,CAAA;IAC/B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG;IAC9C,YAAY,EAAE,uBAAuB,CAAA;IACrC,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAC7B,CAAA;AACD,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,uBAAuB,GAAG,IAAI,CAAA;IAC5C,WAAW,EAAE,mBAAmB,GAAG,SAAS,CAAA;CAC7C,CAAA;AACD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAC5B,YAAY,EAAE;QACZ,KAAK,EAAE,MAAM,EAAE,CAAA;QACf,OAAO,EAAE,MAAM,EAAE,CAAA;KAClB,GAAG,IAAI,CAAA;CACT,CAAA;AAED,MAAM,MAAM,qBAAqB,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI;IACzE,QAAQ,EAAE,IAAI,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magmamath/students-features",
3
- "version": "0.3.1-rc.2",
3
+ "version": "0.3.1-rc.4",
4
4
  "description": "Magmamath features library",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/commonjs/index.js",
@@ -7,7 +7,7 @@ import { HelpRequestOption } from './HelpRequestOption'
7
7
 
8
8
  type AlternativesProps = {
9
9
  model: ChatbotModel
10
- onPressAlternative: (message: string, promptKey: string, translatedMessage?: string) => void
10
+ onPressAlternative: (message: string, translatedMessage?: string) => void
11
11
  hasMessages: boolean
12
12
  isHintFeedback: boolean
13
13
  }
@@ -34,10 +34,10 @@ export const Alternatives = ({
34
34
 
35
35
  return (
36
36
  <View style={styles.container}>
37
- {options.map(({ text, promptKey, translatedText }, index) => (
37
+ {options.map(({ text, translatedText }, index) => (
38
38
  <HelpRequestOption
39
39
  key={index}
40
- onPress={() => onPressAlternative(text, promptKey, translatedText)}
40
+ onPress={() => onPressAlternative(text, translatedText)}
41
41
  message={isTranslated ? (translatedText as string) : text}
42
42
  disabled={isTranslationPending}
43
43
  />
@@ -5,15 +5,12 @@ import { ChatbotModel } from '../../model/ChatBotModel'
5
5
  import { ChatMessage } from '../ChatMessage/ChatMessage'
6
6
  import { MessageLoader } from '../ChatMessage/MessageLoader'
7
7
  import { Alternatives } from '../Alternatives/Alternatives'
8
- import { PostMessagePayload } from '../../types/api.types'
9
8
  import { AUDIO_CONFIG, DEFAULT_VOICE, TEXT_TO_SPEECH_CONFIG } from '../../constants'
10
9
  import { MessageVariant, ChatbotRenderer } from '../../types/model.types'
11
10
 
12
11
  type ChatbotMessagesProps = {
13
12
  model: ChatbotModel
14
13
  isHintFeedback: boolean
15
- sendHelpRequestPayload: Omit<PostMessagePayload, 'type'>
16
- translationTargetLanguage: string
17
14
  sanitizeSpeechInput: (speech: string) => string
18
15
  isTextToSpeechEnabled: boolean
19
16
  textToSpeechConfig?: {
@@ -32,8 +29,6 @@ const BOTTOM_OFFSET = Platform.select({
32
29
  export const ChatbotMessages = ({
33
30
  model,
34
31
  isHintFeedback,
35
- sendHelpRequestPayload,
36
- translationTargetLanguage,
37
32
  sanitizeSpeechInput,
38
33
  isTextToSpeechEnabled,
39
34
  textToSpeechConfig,
@@ -64,13 +59,8 @@ export const ChatbotMessages = ({
64
59
  })
65
60
  }
66
61
 
67
- const askChatForHelp = (message: string, promptKey: string, translatedMessage?: string) => {
68
- void model.sendHelpRequestFx({
69
- payload: { ...sendHelpRequestPayload, type: promptKey },
70
- message,
71
- translatedMessage,
72
- translationTargetLanguage,
73
- })
62
+ const askChatForHelp = (message: string, translatedMessage?: string) => {
63
+ void model.sendHelpRequestFx({ message, translatedMessage })
74
64
  }
75
65
 
76
66
  return (
@@ -3,16 +3,13 @@ import { useStoreMap, useUnit } from 'effector-react'
3
3
  import { ChatbotModel } from '../model/ChatBotModel'
4
4
  import { ChatbotMessages } from './ChatMessages/ChatbotMessages'
5
5
  import { ChatControls } from './ChatControls/ChatControls'
6
- import { PostMessagePayload } from '../types/api.types'
7
6
  import { AUDIO_CONFIG, DEFAULT_VOICE } from '../constants'
8
7
  import { ChatbotRenderer } from '../types/model.types'
9
8
  import React from 'react'
10
9
 
11
10
  type ChatbotProps = {
12
11
  model: ChatbotModel
13
- translationTargetLanguage: string
14
12
  isHintFeedback: boolean
15
- sendHelpRequestPayload: Omit<PostMessagePayload, 'type'>
16
13
  sanitizeSpeechInput: (speech: string) => string
17
14
  isTextToSpeechEnabled: boolean
18
15
  isTranslationEnabled: boolean
@@ -27,9 +24,7 @@ type ChatbotProps = {
27
24
 
28
25
  export const Chatbot = ({
29
26
  model,
30
- translationTargetLanguage,
31
27
  isHintFeedback,
32
- sendHelpRequestPayload,
33
28
  sanitizeSpeechInput,
34
29
  isTextToSpeechEnabled = false,
35
30
  textToSpeechConfig,
@@ -42,9 +37,7 @@ export const Chatbot = ({
42
37
  const isAvailable = useStoreMap(model.$currentChatData, ({ isAvailable }) => isAvailable)
43
38
 
44
39
  const translateMessages = () => {
45
- void model.translation.translateAllMessagesFx({
46
- targetLanguage: translationTargetLanguage,
47
- })
40
+ void model.translation.translateAllMessagesFx()
48
41
  }
49
42
 
50
43
  const openChat = () => model.setIsOpen(true)
@@ -59,8 +52,6 @@ export const Chatbot = ({
59
52
  <ChatbotMessages
60
53
  model={model}
61
54
  renderer={renderer}
62
- sendHelpRequestPayload={sendHelpRequestPayload}
63
- translationTargetLanguage={translationTargetLanguage}
64
55
  isHintFeedback={isHintFeedback}
65
56
  sanitizeSpeechInput={sanitizeSpeechInput}
66
57
  isTextToSpeechEnabled={isTextToSpeechEnabled}
@@ -6,6 +6,7 @@ export {
6
6
  type ConversationMessage,
7
7
  type ChatbotRenderer,
8
8
  type ChatbotModelProps,
9
+ type IChatDrawBoardAdapter,
9
10
  } from './types/model.types'
10
11
  export type { PostMessageResponse, ChatAnswer } from './types/api.types'
11
12
  export { ChatMessageHandler } from './model/ChatBotMessageHandler'
@@ -73,6 +73,7 @@ export class ChatMessageHandler {
73
73
  problem,
74
74
  answer,
75
75
  language,
76
+ imageAltText,
76
77
  }: PostMessagePayload): Promise<PostMessageResponse> => {
77
78
  const threadItem = await this.getThreadItem()
78
79
 
@@ -82,6 +83,7 @@ export class ChatMessageHandler {
82
83
  problemDescription: problem,
83
84
  userAnswer: answer,
84
85
  language,
86
+ imageAltText,
85
87
  })
86
88
 
87
89
  threadItem.hints.push(result.message)
@@ -10,12 +10,14 @@ import {
10
10
  } from 'effector'
11
11
  import { createControllerEffect, createEntityFieldStore } from '../../../lib/effector'
12
12
  import {
13
+ ChatbotContext,
13
14
  ChatbotModelProps,
14
15
  ConversationMessage,
15
16
  SendHelpParams,
16
17
  SendHelpProps,
17
18
  SetHintMessageProps,
18
19
  StartConversationFxData,
20
+ StartConversationProps,
19
21
  } from '../types/model.types'
20
22
  import { GetAlternativesResponse } from '../types/api.types'
21
23
  import { ChatbotAPI } from './api'
@@ -47,6 +49,9 @@ export class ChatbotModel {
47
49
  private readonly setLastMessageKey = createEvent<string>()
48
50
  public readonly $lastMessageKey = restore(this.setLastMessageKey, null)
49
51
 
52
+ public readonly setContext = createEvent<null | ChatbotContext>()
53
+ public readonly $context = restore(this.setContext, null)
54
+
50
55
  readonly setScrollActive = createEvent<boolean>()
51
56
  readonly $isScrollActive = restore(this.setScrollActive, false)
52
57
 
@@ -86,6 +91,7 @@ export class ChatbotModel {
86
91
  .reset(this.resetAlternatives)
87
92
 
88
93
  this.translation = new ChatbotTranslation({
94
+ $context: this.$context,
89
95
  defaultMessages: messages,
90
96
  $key: this.$currentKey,
91
97
  api: this.api,
@@ -104,37 +110,56 @@ export class ChatbotModel {
104
110
 
105
111
  private createSendHelpRequestFx() {
106
112
  const effect = attach({
107
- source: [this.$currentKey, this.translation.$isTranslated],
108
- mapParams: (params: SendHelpParams, [key, isTranslated]) => ({
109
- ...params,
113
+ source: [
114
+ this.$currentKey,
115
+ this.translation.$isTranslated,
116
+ this.$currentChatData,
117
+ this.$context,
118
+ ],
119
+ mapParams: (params: SendHelpParams, [key, isTranslated, currentData, context]) => ({
120
+ message: params.message,
121
+ translatedMessage: params.translatedMessage,
122
+ context,
110
123
  key,
111
124
  isTranslated,
125
+ threadId: currentData.threadId,
112
126
  }),
113
127
  effect: createControllerEffect(
114
128
  async ({
115
- payload,
116
129
  message,
117
- translationTargetLanguage: targetLanguage,
118
130
  translatedMessage,
119
131
  key,
120
132
  isTranslated,
133
+ threadId,
134
+ context,
121
135
  }: SendHelpProps) => {
136
+ if (!context) throw new Error('Context is required')
122
137
  this.setLastMessageKey(key)
123
138
  this.messages.setField({
124
139
  key,
125
140
  fn: (currentMessages) => [
126
141
  ...(currentMessages || []),
127
- messagesHelper.createOwn({ message, translatedMessage, threadId: payload.threadId }),
142
+ messagesHelper.createOwn({ message, translatedMessage, threadId }),
128
143
  ],
129
144
  })
130
145
 
131
- const response = await this.api.postMessageFx(payload)
146
+ const response = await this.api.postMessageFx({
147
+ problem: context.problem,
148
+ language: context.language,
149
+ problemAnswer: context.problemAnswer,
150
+ answer: context.answer,
151
+ threadId,
152
+ imageAltText: context.imageDescription,
153
+ })
132
154
  let messages = [messagesHelper.createAnswer(response)]
133
155
  if (response.endMessage) {
134
156
  messages.push(messagesHelper.createLast(this.defaultMessages.endMessage))
135
157
  }
136
158
  if (isTranslated) {
137
- messages = await this.translation.translateMessagesFx({ targetLanguage, messages })
159
+ messages = await this.translation.translateMessagesFx({
160
+ targetLanguage: context.translationTargetLanguage,
161
+ messages,
162
+ })
138
163
  }
139
164
 
140
165
  this.messages.setField({
@@ -174,9 +199,15 @@ export class ChatbotModel {
174
199
 
175
200
  public readonly startConversation = attach({
176
201
  source: this.$currentChatData,
177
- mapParams: (_: void, source) => source,
178
- effect: createEffect(({ key, messages }: StartConversationFxData) => {
179
- if (messages.length) return this.reinitConversation({ key })
202
+ mapParams: (props: StartConversationProps | void, source) => ({
203
+ ...props,
204
+ ...source,
205
+ }),
206
+ effect: createEffect(({ key, messages, initOnly }: StartConversationFxData) => {
207
+ if (messages.length) {
208
+ if (initOnly) return
209
+ return this.reinitConversation({ key })
210
+ }
180
211
  this.messages.setField({ key, data: [this.defaultMessages.start] })
181
212
  this.availableChats.setField({ key, data: true })
182
213
  }),
@@ -5,7 +5,7 @@ import {
5
5
  TranslateMessageFxProps,
6
6
  TranslateRequestProps,
7
7
  } from '../types/translation.types'
8
- import { ChatbotMessages, ConversationMessage } from '../types/model.types'
8
+ import { ChatbotContext, ChatbotMessages, ConversationMessage } from '../types/model.types'
9
9
  import { GetAlternativesResponse } from '../types/api.types'
10
10
  import { decodeHTMLEntities } from '../helpers'
11
11
  import { ChatbotAPI } from './api'
@@ -21,6 +21,7 @@ type ChatbotTranslationProps = {
21
21
  $key: Store<string>
22
22
  defaultMessages: ChatbotMessages
23
23
  messagesModel: EntityFieldStore<ConversationMessage[]>
24
+ $context: Store<ChatbotContext | null>
24
25
  alternativesModel: {
25
26
  set: EventCallable<GetAlternativesResponse | null>
26
27
  $store: Store<GetAlternativesResponse | null>
@@ -30,6 +31,7 @@ type ChatbotTranslationProps = {
30
31
  export class ChatbotTranslation {
31
32
  private readonly api
32
33
  private readonly $key
34
+ private readonly $context
33
35
  private readonly defaultMessages
34
36
  private readonly messagesModel
35
37
  private readonly alternativesModel
@@ -45,17 +47,19 @@ export class ChatbotTranslation {
45
47
  defaultMessages,
46
48
  messagesModel,
47
49
  alternativesModel,
50
+ $context,
48
51
  }: ChatbotTranslationProps) {
49
52
  this.api = api
50
53
  this.$key = $key
54
+ this.$context = $context
51
55
  this.defaultMessages = defaultMessages
52
56
  this.messagesModel = messagesModel
53
57
  this.alternativesModel = alternativesModel
54
58
 
55
59
  this.translateAllMessagesFx = attach({
56
- source: [this.$key, this.messagesModel.$state, this.alternativesModel.$store],
57
- mapParams: (params: TranslateBatchFxProps['params'], [key, messages, alternatives]) => ({
58
- params,
60
+ source: [this.$key, this.messagesModel.$state, this.alternativesModel.$store, this.$context],
61
+ mapParams: (_: void, [key, messages, alternatives, context]) => ({
62
+ targetLanguage: context?.translationTargetLanguage ?? '',
59
63
  messages: messages[key] ?? [],
60
64
  alternatives,
61
65
  }),
@@ -112,7 +116,7 @@ export class ChatbotTranslation {
112
116
  }
113
117
 
114
118
  private readonly translateBatchFx = createEffect(
115
- async ({ messages, params, alternatives }: TranslateBatchFxProps) => {
119
+ async ({ messages, alternatives, targetLanguage }: TranslateBatchFxProps) => {
116
120
  if (this.shouldSkipTranslation(messages)) {
117
121
  return messages
118
122
  }
@@ -130,7 +134,7 @@ export class ChatbotTranslation {
130
134
  alternativesHints: options.alternatives?.hints || [],
131
135
  alternativesDefaults: options.alternatives?.default || [],
132
136
  },
133
- targetLanguage: params.targetLanguage,
137
+ targetLanguage,
134
138
  })
135
139
 
136
140
  translatedTextsList.defaultMessages.forEach((message, index) => {