From b2840d78cd84913dd1f83bfdf71aea9d352e8c7d Mon Sep 17 00:00:00 2001 From: Massimiliano Angelino Date: Thu, 14 Mar 2024 10:51:05 +0100 Subject: [PATCH] fix(claude prompt): improved claude prompts and fix to model interface selection --- .../request-handler/adapters/bedrock/claude.py | 11 +++++++---- .../src/components/chatbot/chat-input-panel.tsx | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/model-interfaces/langchain/functions/request-handler/adapters/bedrock/claude.py b/lib/model-interfaces/langchain/functions/request-handler/adapters/bedrock/claude.py index 65325e48b..363c73413 100644 --- a/lib/model-interfaces/langchain/functions/request-handler/adapters/bedrock/claude.py +++ b/lib/model-interfaces/langchain/functions/request-handler/adapters/bedrock/claude.py @@ -63,13 +63,16 @@ def get_prompt(self): return prompt_template def get_condense_question_prompt(self): - template = """ + template = """ {chat_history} + -Human: Given the above conversation and a follow up input, rephrase the follow up input to be a standalone question, in the same language as the follow up input. -Follow Up Input: {question} + +{question} + -Assistant:""" +Given the conversation inside the tags , rephrase the follow up question you find inside to be a standalone question, in the same language as the follow up question. +""" return PromptTemplate( input_variables=["chat_history", "question"], diff --git a/lib/user-interface/react-app/src/components/chatbot/chat-input-panel.tsx b/lib/user-interface/react-app/src/components/chatbot/chat-input-panel.tsx index f7ed0cf5a..7878f0d03 100644 --- a/lib/user-interface/react-app/src/components/chatbot/chat-input-panel.tsx +++ b/lib/user-interface/react-app/src/components/chatbot/chat-input-panel.tsx @@ -316,6 +316,17 @@ export default function ChatInputPanel(props: ChatInputPanelProps) { } }, [props.configuration]); + const hasImagesInChatHistory = function (): boolean { + return ( + messageHistoryRef.current.filter( + (x) => + x.type == ChatBotMessageType.Human && + x.metadata?.files && + (x.metadata.files as object[]).length > 0 + ).length > 0 + ); + }; + const handleSendMessage = () => { if (!state.selectedModel) return; if (props.running) return; @@ -331,9 +342,7 @@ export default function ChatInputPanel(props: ChatInputPanelProps) { action: ChatBotAction.Run, modelInterface: (props.configuration.files && props.configuration.files.length > 0) || - (messageHistoryRef.current.filter( - (x) => x.metadata?.files !== undefined - ).length > 0 && + (hasImagesInChatHistory() && state.selectedModelMetadata?.inputModalities.includes( ChabotInputModality.Image )) @@ -355,7 +364,7 @@ export default function ChatInputPanel(props: ChatInputPanelProps) { }, }, }; - + console.log(request); setState((state) => ({ ...state, value: "",