From 18ef40f6f4983ffab2fd6260badd9bff61433de2 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Tue, 25 Jun 2024 01:42:32 -0700 Subject: [PATCH] MP: bifurcate generate-text --- src/apps/chat/AppChat.tsx | 1 + src/apps/chat/components/composer/ChatModeMenu.tsx | 5 +++++ src/apps/chat/components/composer/Composer.tsx | 4 ++-- src/apps/chat/editors/_handleExecute.ts | 3 +++ src/apps/chat/editors/chat-stream.ts | 8 +++++++- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/apps/chat/AppChat.tsx b/src/apps/chat/AppChat.tsx index 244e6b517..a3ac514cb 100644 --- a/src/apps/chat/AppChat.tsx +++ b/src/apps/chat/AppChat.tsx @@ -57,6 +57,7 @@ export const CHAT_NOVEL_TITLE = 'Chat'; */ export type ChatModeId = | 'generate-text' + | 'generate-text-v1' | 'generate-text-beam' | 'append-user' | 'generate-image' diff --git a/src/apps/chat/components/composer/ChatModeMenu.tsx b/src/apps/chat/components/composer/ChatModeMenu.tsx index 749ed4b0e..537140e81 100644 --- a/src/apps/chat/components/composer/ChatModeMenu.tsx +++ b/src/apps/chat/components/composer/ChatModeMenu.tsx @@ -19,6 +19,11 @@ const ChatModeItems: { [key in ChatModeId]: ChatModeDescription } = { description: 'Persona replies', canAttach: true, }, + 'generate-text-v1': { + label: 'Chat (1.16)', + description: 'Persona replies (stable)', + canAttach: true, + }, 'generate-text-beam': { label: 'Beam', // Best of, Auto-Prime, Top Pick, Select Best description: 'Combine multiple models', // Smarter: combine... diff --git a/src/apps/chat/components/composer/Composer.tsx b/src/apps/chat/components/composer/Composer.tsx index 40171bf1b..336bc82f5 100644 --- a/src/apps/chat/components/composer/Composer.tsx +++ b/src/apps/chat/components/composer/Composer.tsx @@ -148,7 +148,7 @@ export function Composer(props: { // composer-overlay: for the reply-to state, comes from the conversation overlay const { replyToGenerateText } = useChatOverlayStore(conversationOverlayStore, useShallow(store => ({ - replyToGenerateText: chatModeId === 'generate-text' ? store.replyToText?.trim() || null : null, + replyToGenerateText: (chatModeId === 'generate-text' || chatModeId === 'generate-text-v1') ? store.replyToText?.trim() || null : null, }))); // don't load URLs if the user is typing a command or there's no capability @@ -546,7 +546,7 @@ export function Composer(props: { }, [attachAppendDataTransfer, eatDragEvent, setComposeText]); - const isText = chatModeId === 'generate-text'; + const isText = chatModeId === 'generate-text' || chatModeId === 'generate-text-v1'; const isTextBeam = chatModeId === 'generate-text-beam'; const isAppend = chatModeId === 'append-user'; const isReAct = chatModeId === 'generate-react'; diff --git a/src/apps/chat/editors/_handleExecute.ts b/src/apps/chat/editors/_handleExecute.ts index ca1daa3c9..1a2007bc3 100644 --- a/src/apps/chat/editors/_handleExecute.ts +++ b/src/apps/chat/editors/_handleExecute.ts @@ -73,6 +73,9 @@ export async function _handleExecute(chatModeId: ChatModeId, conversationId: DCo case 'generate-text': return await runAssistantUpdatingState(conversationId, cHandler.viewHistory('generate-text'), chatLLMId, getUXLabsHighPerformance() ? 0 : getInstantAppChatPanesCount()); + case 'generate-text-v1': + return await runAssistantUpdatingState(conversationId, cHandler.viewHistory('generate-text-v1'), chatLLMId, getUXLabsHighPerformance() ? 0 : getInstantAppChatPanesCount()); + case 'generate-text-beam': cHandler.beamInvoke(cHandler.viewHistory('generate-text-beam'), [], null); return true; diff --git a/src/apps/chat/editors/chat-stream.ts b/src/apps/chat/editors/chat-stream.ts index 395f69f6a..e1ec40ee6 100644 --- a/src/apps/chat/editors/chat-stream.ts +++ b/src/apps/chat/editors/chat-stream.ts @@ -14,7 +14,12 @@ import { ChatAutoSpeakType, getChatAutoAI } from '../store-app-chat'; /** * The main "chat" function. TODO: this is here so we can soon move it to the data model. */ -export async function runAssistantUpdatingState(conversationId: string, history: Readonly, assistantLlmId: DLLMId, parallelViewCount: number) { +export async function runAssistantUpdatingState( + conversationId: string, + history: Readonly, + assistantLlmId: DLLMId, + parallelViewCount: number, +) { const cHandler = ConversationsManager.getHandler(conversationId); // ai follow-up operations (fire/forget) @@ -67,6 +72,7 @@ export async function runAssistantUpdatingState(conversationId: string, history: return messageStatus.outcome === 'success'; } + type StreamMessageOutcome = 'success' | 'aborted' | 'errored'; type StreamMessageStatus = { outcome: StreamMessageOutcome, errorMessage?: string }; type StreamMessageUpdate = Pick;