@cmnd-ai/chatbot-react 1.5.0 → 1.6.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.
@@ -25,7 +25,7 @@ const processStream = async (reader, onData) => {
25
25
  if (dataString === "[DONE]") {
26
26
  onData({
27
27
  completionFinished: true,
28
- finalResponseWithUsageData: false
28
+ finalResponseWithUsageData: false,
29
29
  });
30
30
  }
31
31
  else {
@@ -39,14 +39,14 @@ const processStream = async (reader, onData) => {
39
39
  onData({
40
40
  completionFinished: false,
41
41
  finalResponseWithUsageData: false,
42
- message: fullAssistantMessage
42
+ message: fullAssistantMessage,
43
43
  });
44
44
  }
45
45
  else {
46
46
  //at this point, the dataObject does not have a content propery
47
47
  //and it is completed
48
48
  //get the last message from the dataObject to check if it is a function call
49
- const { messages, completionFinished, finalResponseWithUsageData, chatbotConversationId, conversationId, totalTokens, totalCost } = dataObject;
49
+ const { messages, completionFinished, finalResponseWithUsageData, chatbotConversationId, conversationId, totalTokens, totalCost, } = dataObject;
50
50
  onData({
51
51
  messages,
52
52
  completionFinished,
@@ -54,12 +54,18 @@ const processStream = async (reader, onData) => {
54
54
  conversationId,
55
55
  chatbotConversationId,
56
56
  totalTokens,
57
- totalCost
57
+ totalCost,
58
58
  });
59
59
  }
60
60
  }
61
61
  catch (error) {
62
- fullMessageContext += dataString;
62
+ onData({
63
+ completionFinished: true,
64
+ message: error instanceof Error
65
+ ? error.message
66
+ : "Oops! I ran into a problem.",
67
+ finalResponseWithUsageData: true,
68
+ });
63
69
  }
64
70
  }
65
71
  }
@@ -68,11 +74,9 @@ const processStream = async (reader, onData) => {
68
74
  catch (error) {
69
75
  onData({
70
76
  completionFinished: true,
71
- message: fullAssistantMessage,
72
- finalResponseWithUsageData: true
77
+ message: "Oops! I ran into a problem.",
78
+ finalResponseWithUsageData: true,
73
79
  });
74
- console.error(error);
75
- throw new Error(error);
76
80
  }
77
81
  };
78
82
  export default processStream;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmnd-ai/chatbot-react",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "main": "dist/index.js",
5
5
  "description": "",
6
6
  "type": "module",
package/readme.dev.md ADDED
@@ -0,0 +1,30 @@
1
+ # Development README for @cmnd-ai/chatbot-react
2
+
3
+ ## Getting Started (Development)
4
+
5
+ 1. **Install dependencies:**
6
+
7
+ ```sh
8
+ npm install
9
+ ```
10
+
11
+ 2. **Start the development server:**
12
+
13
+ ```sh
14
+ npm run dev
15
+ ```
16
+
17
+ 3. **Link the package locally:**
18
+ In a separate terminal, run:
19
+
20
+ ```sh
21
+ npm link
22
+ ```
23
+
24
+ 4. **Test in another project:**
25
+ In the project where you want to use `@cmnd-ai/chatbot-react`, run:
26
+ ```sh
27
+ npm link @cmnd-ai/chatbot-react
28
+ ```
29
+
30
+ This will allow you to test your local changes in another project without publishing to npm.