Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

feat: frontend additions for preload classifiers on backend #497

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
remove unused zustand
  • Loading branch information
vasudev-io committed Nov 23, 2024
commit d8b5fbe9e153ef03964e2bdf6a64293d03fcc912
41 changes: 18 additions & 23 deletions src/hooks/useSubmitQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ export const useSubmitQuery = () => {
updateLastConversationMessage,
addToast,
updateLastMessageSentTimestamp,
setModelClassification,
setSearchClassification,
} = useStore(
useShallow((state) => ({
addAttachment: state.addAttachment,
Expand All @@ -176,8 +174,6 @@ export const useSubmitQuery = () => {
updateLastConversationMessage: state.updateLastConversationMessage,
addToast: state.addToast,
updateLastMessageSentTimestamp: state.updateLastMessageSentTimestamp,
setModelClassification: state.setModelClassification,
setSearchClassification: state.setSearchClassification,
})),
)

Expand Down Expand Up @@ -667,7 +663,7 @@ export const useSubmitQuery = () => {

// If it's a string, assume it's a URL (could be a local URL)
if (typeof attachment.value === 'string') {
fileOrUrl = attachment.value // Pass the URL directly
fileOrUrl = attachment.value
} else {
const fileName = `${uuidv4()}.${attachment.type}`
const mimeType = getFileType(attachment)
Expand All @@ -688,11 +684,27 @@ export const useSubmitQuery = () => {
search = uploadedFile.search
}
}
}),
})
)

await Promise.all(uploadFilePromises)

// Build form data
const formData = await buildFormData({
prompt: query,
conversationId,
attachedContext,
availableContexts,
})

// Add model and search if available
if (model) {
formData.append('model', model)
}
if (search !== undefined) {
formData.append('search', String(search))
}

// Add non-uploadable attachments to attachedContext
attachments
.filter((a) => !isUploadableAttachment(a))
Expand Down Expand Up @@ -756,23 +768,6 @@ export const useSubmitQuery = () => {
}
availableContexts.context.push(windowListAttachment)

// Build FormData using the updated builder
const formData = await buildFormData({
prompt: query,
conversationId,
llmProvider: 'anthropic',
attachedContext,
availableContexts,
})

// Add model and search if available
if (model) {
formData.append('model', model)
}
if (search !== undefined) {
formData.append('search', String(search))
}

// @ts-expect-error
addConversationMessage(conversationId, {
role: 'user',
Expand Down