ui chat ui fixes (#8105)

This commit is contained in:
Ishaan Jaff 2025-01-29 18:53:49 -08:00 committed by GitHub
parent 31e967cbbd
commit d10bd67d33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -190,17 +190,19 @@ const ChatUI: React.FC<ChatUIProps> = ({
return;
}
// Create message object without model field for API call
const newUserMessage = { role: "user", content: inputMessage };
const updatedChatHistory = [...chatHistory, newUserMessage];
// Create chat history for API call - strip out model field
const apiChatHistory = [...chatHistory.map(({ role, content }) => ({ role, content })), newUserMessage];
setChatHistory(updatedChatHistory);
// Update UI with full message object (including model field for display)
setChatHistory([...chatHistory, newUserMessage]);
try {
if (selectedModel) {
await generateModelResponse(
updatedChatHistory,
apiChatHistory,
(chunk, model) => updateUI("assistant", chunk, model),
selectedModel,
effectiveApiKey