Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing file context manager if upload is success #202

Merged
merged 5 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/user-interface/react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/user-interface/react/src/components/chatbot/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export default function Chat ({ sessionId }) {
new LisaChatMessage({
type: 'ai',
content: result,
metadata: metadata,
metadata: useRag ? { ...metadata, ...prev.history[prev.history.length - 1].metadata } : metadata,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we handling an empty history array?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't be empty is RAG is used because when we get the context back it sets a chat history message already

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…if we're already talking about this line it might be cleaner to use prev.history.slice(-1)[0].metadata? I already approved so not blocking at all…more of a preference.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly looking at this code today, it all needs to be re-written, it is pretty nasty. Let's make note of this and I will get a task written to do some cleanup around this chat piece.

}),
),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ export function ContextUploadModal ({
<SpaceBetween direction='horizontal' size='xs'>
<Button
onClick={async () => {
await handleUpload(selectedFiles, handleError, processFile, [FileTypes.TEXT], 10240);
const successfulUploads = await handleUpload(selectedFiles, handleError, processFile, [FileTypes.TEXT], 10240);
if (successfulUploads.length > 0) {
notificationService.generateNotification(`Successfully added file(s) to context ${successfulUploads.join(', ')}`, StatusTypes.SUCCESS);
setShowContextUploadModal(false);
}
}}
disabled={selectedFiles.length === 0}
>
Expand Down
Loading