Skip to content

Commit

Permalink
Log doc name if only one doc selected
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinEtchells committed Nov 11, 2024
1 parent 677777c commit 6e1b86a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion django_app/frontend/src/js/custom-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Custom events are used for communication between web components. Here is a list
| chat-response-start | /chats | (none) | When the streaming connection is opened |
| chat-response-end | /chats | title: string<br/>session_id: string | When the stream "end" event is sent from the server |
| doc-complete | /chats<br/>/documents | file-status: HTMLElement | When a document status changes to "complete" |
| selected-docs-change | /chats | string[] of document IDs | When a user selects or deselects a document |
| selected-docs-change | /chats | {id: string, name: string}[] | When a user selects or deselects a document |
| stop-streaming | /chats | (none) | When a user presses the stop-streaming button, or an unexpected disconnection has occured |
| chat-title-change | /chats | title: string<br/>session_id: string<br/>sender: string | When the chat title is changed by the user |
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class ChatController extends HTMLElement {
`You selected ${selectedDocuments.length || "no"} document${selectedDocuments.length === 1 ? "" : "s"}`,
"You sent this prompt"
];
// add filename to activity if only one file
if (selectedDocuments.length === 1) {
activites[0] += ` (${selectedDocuments[0].name})`;
}
activites.forEach((activity) => {
userMessage.addActivity(activity, "user");
});
Expand All @@ -47,7 +51,7 @@ class ChatController extends HTMLElement {

aiMessage.stream(
userText,
selectedDocuments,
selectedDocuments.map(doc => doc.id),
activites,
llm,
this.dataset.sessionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class DocumentSelector extends HTMLElement {
let selectedDocuments = [];
documents.forEach((document) => {
if (document.checked) {
selectedDocuments.push(document.value);
selectedDocuments.push({
id: document.value,
name: this.querySelector(`[for="${document.id}"]`)?.textContent
});
}
});
const evt = new CustomEvent("selected-docs-change", {
Expand Down

0 comments on commit 6e1b86a

Please sign in to comment.