Skip to content

Commit 83950cf

Browse files
fix: Limiting citation content length in kernel function responses and restrict save history for error response
fix: Limiting citation content length in kernel function responses and restrict save history for error response
2 parents b75d196 + e0a0394 commit 83950cf

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/App/src/components/Chat/Chat.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,9 @@ const Chat: React.FC<ChatProps> = ({
642642
];
643643
}
644644
}
645-
saveToDB(updatedMessages, conversationId, isChatReq);
645+
if (!updatedMessages.find((msg: any) => msg.role=== "error")) {
646+
saveToDB(updatedMessages, conversationId, isChatReq);
647+
}
646648
} catch (e) {
647649
console.log("Catched with an error while chat and save", e);
648650
if (abortController.signal.aborted) {

src/api/plugins/chat_with_data_plugin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ def get_answers_from_calltranscripts(
198198
}
199199
)
200200
answer = completion.choices[0]
201+
202+
# Limit the content inside citations to 300 characters to minimize load
203+
if hasattr(answer.message, 'context') and 'citations' in answer.message.context:
204+
for citation in answer.message.context.get('citations', []):
205+
if isinstance(citation, dict) and 'content' in citation:
206+
citation['content'] = citation['content'][:300] + '...' if len(citation['content']) > 300 else citation['content']
201207
except BaseException:
202208
answer = 'Details could not be retrieved. Please try again later.'
203209
return answer

0 commit comments

Comments
 (0)