Skip to content

Conversation

@lyjeileen
Copy link
Collaborator

@lyjeileen lyjeileen commented May 1, 2024

Changes

  • Include file names in the message

Note: The alert is only be shown in the storybook to show the content being sent.

Before

Screenshot 2024-05-01 at 9 31 10 AM

After

Screenshot 2024-05-01 at 9 29 17 AM

Copy link
Contributor

@Shiti Shiti left a comment

Choose a reason for hiding this comment

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

I've suggested minor renames to clarify functionality.


export default function MultimodalInput(props: MultimodalInputProps) {
const [fileCount, setFileCount] = useState(0)
const [fileList, setFileList] = useState<string[]>([])
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const [fileList, setFileList] = useState<string[]>([])
const [fileNames, setFileNames] = useState<string[]>([])

useState<HTMLDivElement>()
const inputRef = useRef<HTMLDivElement>(null)
const hasAddedFiles = fileCount > 0
const hasAddedFiles = fileList.length > 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const hasAddedFiles = fileList.length > 0
const hasAddedFiles = fileNames.length > 0

props.ws.send(formattedMessage)
setMessageId(getUUID())
setFileCount(0)
setFileList([])
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
setFileList([])
setFileNames([])


function handleFileCountChange(fileCountChange: 1 | -1) {
setFileCount((prev) => prev + fileCountChange)
function handleFileListChange(action: 'add' | 'remove', fileName: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
function handleFileListChange(action: 'add' | 'remove', fileName: string) {
function handleFileUpdates(action: 'add' | 'remove', fileName: string) {

uploadFileEndpoint={props.uploadFileEndpoint}
deleteFileEndpoint={props.deleteFileEndpoint}
handleFileCountChange={handleFileCountChange}
handleFileListChange={handleFileListChange}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
handleFileListChange={handleFileListChange}
onFileUpdates={handleFileListChange}

UploaderProps,
| 'messageId'
| 'handleFileCountChange'
| 'handleFileListChange'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| 'handleFileListChange'
| 'onFileUpdate'

})
.catch(() => {
props.handleFileCountChange(1)
props.handleFileListChange('add', fileName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
props.handleFileListChange('add', fileName)
props.onFileUpdate('add', fileName)

...fileNamesRef.current,
[fileName]: fileNamesRef.current[fileName]--,
}
props.handleFileListChange('remove', fileName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
props.handleFileListChange('remove', fileName)
props.onFileUpdate('remove', fileName)

})
.catch((error) => {
props.handleFileCountChange(-1)
props.handleFileListChange('remove', fileName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
props.handleFileListChange('remove', fileName)
props.onFileUpdate('remove', fileName)

setAddedFiles((prev) => [...prev, newAddedFile])

props.handleFileCountChange(1)
props.handleFileListChange('add', fileName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
props.handleFileListChange('add', fileName)
props.onFileUpdate('add', fileName)

messageId: string
/** A function to handle changes in the file count. Parent component should use this to track file count change and handle submit accordingly. */
handleFileCountChange: (fileCountChange: 1 | -1) => void
/** A function to handle changes in the file list. Parent component should use this to track file names and handle submit accordingly. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/** A function to handle changes in the file list. Parent component should use this to track file names and handle submit accordingly. */
/** A function to handle changes in the file list. The parent component should use this to track file names and handle submit accordingly. */

Shiti
Shiti previously approved these changes May 1, 2024
@Shiti Shiti merged commit aa6b590 into rustic-ai:main May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants