@credithub/harlan-components 1.40.3 → 1.40.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.
@@ -113,16 +113,25 @@ var GenerativeAI = function (_a) {
113
113
  var newContent = nonEmptyFragments
114
114
  .map(function (e) { return e.message.content; })
115
115
  .join('');
116
- incrementalResponseRef.current =
117
- incrementalResponseRef.current + newContent;
116
+ incrementalResponseRef.current += newContent;
117
+ setMessageHistory(function (prevMessages) {
118
+ var updatedMessages = __spreadArray([], prevMessages, true);
119
+ var lastMessage = updatedMessages[updatedMessages.length - 1];
120
+ if (lastMessage && lastMessage.role === 'assistant') {
121
+ lastMessage.content = incrementalResponseRef.current;
122
+ }
123
+ else {
124
+ updatedMessages.push({
125
+ role: 'assistant',
126
+ content: incrementalResponseRef.current
127
+ });
128
+ }
129
+ return updatedMessages;
130
+ });
118
131
  }
119
132
  if (response.some(function (e) { return e.done; })) {
120
- var aiMessage_1 = incrementalResponseRef.current;
121
- setQueryEnabled(false);
122
133
  incrementalResponseRef.current = '';
123
- setMessageHistory(function (prevMessages) { return __spreadArray(__spreadArray([], prevMessages, true), [
124
- { role: 'assistant', content: aiMessage_1 }
125
- ], false); });
134
+ setQueryEnabled(false);
126
135
  }
127
136
  };
128
137
  useEffect(function () {
@@ -153,9 +162,7 @@ var GenerativeAI = function (_a) {
153
162
  var query = createQueryAndMessages(serializedData, messageHistory);
154
163
  return query;
155
164
  }, [queryEnabled, serializedData, messageHistory]);
156
- var _r = useStreamQuery(
157
- // Trocar endpoint na API
158
- "SELECT FROM 'LlamaApi'.'Consulta'", queryData, !!queryData), response = _r.response, error = _r.error, isLoading = _r.isLoading, refetch = _r.refetch;
165
+ var _r = useStreamQuery("SELECT FROM 'LlamaApi'.'Consulta'", queryData, !!queryData), response = _r.response, error = _r.error, isLoading = _r.isLoading, refetch = _r.refetch;
159
166
  useEffect(function () {
160
167
  abortControllerRef.current = new AbortController();
161
168
  return function () {