Skip to content

Commit

Permalink
coral-web: Only force enable file reader on send if files exist in co…
Browse files Browse the repository at this point in the history
…nversation (#28)

only force enable file reader on send if files exist
  • Loading branch information
misspia-cohere committed Apr 24, 2024
1 parent 328593c commit 05e1a4b
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ const Conversation: React.FC<Props> = ({ conversationId, welcomeMessageEnabled =
};

const handleSend = (msg?: string, overrideTools?: Tool[]) => {
const enableFileLoaderTool =
(files.length > 0 || composerFiles.length > 0) && !!defaultFileLoaderTool;
const filesExist = files.length > 0 || composerFiles.length > 0;
const enableFileLoaderTool = filesExist && !!defaultFileLoaderTool;
const chatOverrideTools: Tool[] = [
...(overrideTools ?? []),
...(enableFileLoaderTool ? [{ name: defaultFileLoaderTool.name }] : []),
Expand All @@ -170,7 +170,9 @@ const Conversation: React.FC<Props> = ({ conversationId, welcomeMessageEnabled =
if (startOption !== StartOptionKey.DOCUMENTS) {
setStartOption(StartOptionKey.DOCUMENTS);
}
enableDefaultFileLoaderTool();
if (filesExist) {
enableDefaultFileLoaderTool();
}
send({ suggestedMessage: msg }, { tools: chatOverrideTools });
};

Expand Down

0 comments on commit 05e1a4b

Please sign in to comment.