Skip to content

Commit

Permalink
chore: prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
mikbry committed Feb 29, 2024
1 parent 1122b5e commit 8017363
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
33 changes: 19 additions & 14 deletions webapp/components/views/Threads/Thread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,24 +340,29 @@ function Thread({
return returnedMessage;
};

const clearPrompt = (conversation: Conversation | undefined, newConversations = conversations) => {
const clearPrompt = (
conversation: Conversation | undefined,
newConversations = conversations,
) => {
setChangedPrompt(undefined);

let updatedConversations = newConversations;
if (conversation) {
updatedConversations = updateConversation({ ...conversation, currentPrompt: undefined, temp: false }, newConversations);
updatedConversations = updateConversation(
{ ...conversation, currentPrompt: undefined, temp: false },
newConversations,
);
updateConversations(updatedConversations);
}
return updatedConversations;
}
};

const handleSendMessage = async () => {
if (conversationId === undefined) {
return;
}
const action = currentPrompt.tokens.find((to) => to.type === PromptTokenType.Action);


if (action) {
let updatedConversation = selectedConversation;
let updatedConversations = conversations;
Expand All @@ -366,27 +371,27 @@ function Thread({
if (command) {
command.execute?.(action.value);
if (command.label === 'System') {
const message = createMessage({ role: 'system', name: 'system' }, currentPrompt.text, currentPrompt.raw);
const message = createMessage(
{ role: 'system', name: 'system' },
currentPrompt.text,
currentPrompt.raw,
);
let updatedConversationId: string | undefined;
({
updatedConversationId,
updatedConversations,
} = await updateMessagesAndConversation(
({ updatedConversationId, updatedConversations } = await updateMessagesAndConversation(
[message],
getConversationMessages(conversationId),
));

updatedConversation = getConversation(
updatedConversationId,
updatedConversations,
) as Conversation;

}
}
clearPrompt(updatedConversation, updatedConversations);
return;
};
}

const mentions = currentPrompt.tokens.filter((to) => to.type === PromptTokenType.Mention);
const modelItem =
mentions.length === 1
Expand Down Expand Up @@ -457,7 +462,7 @@ function Thread({
updatedConversations = updateConversation(conversation, updatedConversations);
updateConversations(updatedConversations); */
updatedConversations = clearPrompt(conversation, updatedConversations);

logger.info('onSendMessage', updatedMessages, conversation);
message = await sendMessage(message, updatedMessages, conversation, updatedConversations);

Expand Down
5 changes: 4 additions & 1 deletion webapp/utils/parsers/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ const validator = (
state = PromptTokenState.Disabled;
}
} else if (type === PromptTokenType.Action) {
if (parsedPrompt.text.trim().length > 0 || (previousToken && previousToken.type !== PromptTokenType.Text)) {
if (
parsedPrompt.text.trim().length > 0 ||
(previousToken && previousToken.type !== PromptTokenType.Text)
) {
type = PromptTokenType.Text;
} else {
if (isEditing) {
Expand Down

0 comments on commit 8017363

Please sign in to comment.