-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Enable Editing of Previous Messages in Chat Interface #3176
Comments
Hey @TorstenC! I'm here to help you with any bugs, questions, or contributions. Let me know what you need assistance with! To enable the editing of previous messages in the Quivr web interface, you can leverage the existing Backend Changes
from fastapi import APIRouter, HTTPException
from uuid import UUID
from pydantic import BaseModel
class UpdateMessageRequest(BaseModel):
message_id: UUID
new_content: str
router = APIRouter()
@router.put("/chat/{chat_id}/message")
async def update_message(chat_id: UUID, request: UpdateMessageRequest):
try:
updated_message = chat_service.update_message_by_id(request.message_id, {"content": request.new_content})
return updated_message
except Exception as e:
raise HTTPException(status_code=500, detail=str(e)) Frontend Changes
import { useState } from "react";
const MessageRow = ({ message, onUpdate }) => {
const [isEditing, setIsEditing] = useState(false);
const [newContent, setNewContent] = useState(message.content);
const handleEdit = () => {
setIsEditing(true);
};
const handleSave = () => {
onUpdate(message.id, newContent);
setIsEditing(false);
};
return (
<div>
{isEditing ? (
<input
type="text"
value={newContent}
onChange={(e) => setNewContent(e.target.value)}
/>
) : (
<span>{message.content}</span>
)}
<button onClick={handleEdit}>Edit</button>
{isEditing && <button onClick={handleSave}>Save</button>}
</div>
);
};
import { useState } from "react";
import axios from "axios";
const Chat = ({ chatId, messages }) => {
const [chatMessages, setChatMessages] = useState(messages);
const handleUpdateMessage = async (messageId, newContent) => {
try {
const response = await axios.put(`/chat/${chatId}/message`, {
message_id: messageId,
new_content: newContent,
});
setChatMessages((prevMessages) =>
prevMessages.map((msg) =>
msg.id === messageId ? { ...msg, content: newContent } : msg
)
);
} catch (error) {
console.error("Failed to update message", error);
}
};
return (
<div>
{chatMessages.map((message) => (
<MessageRow key={message.id} message={message} onUpdate={handleUpdateMessage} />
))}
</div>
);
}; SummaryBy implementing these changes, you can enable the editing of previous messages in the Quivr web interface, enhancing the flexibility and accuracy of interactions with the language model. This feature will allow users to clarify and adjust their queries and responses, making the chat dialogue more efficient and effective. |
The Feature
I propose that the Quivr web interface should provide the capability to edit previous messages from both the user and the agent before submitting (round-trip). This functionality should be similar to the feature available at
console.anthropic.com/workbench
andplatform.openai.com/playground/chat
.Motivation, pitch
This feature significantly simplifies the chat dialogue and enhances collaboration efficiency with the language model (LLM). Here are two typical use cases that illustrate the advantages:
Clarification and Context Addition: If I forget to specify that my question relates to Linux, I can update my original query with “in Linux” and remove the irrelevant part of the agent’s response (e.g., related to Windows) before asking my follow-up question.
Specific Adjustments in Responses: If the response includes a placeholder for a file path such as "your/path/to/config.yaml," I can replace this placeholder with the correct path. This ensures that all further code adjustments include the correct path.
By allowing the editing of previous messages, interactions become clearer and more precise, minimizing misunderstandings and making the workflow smoother.
Twitter / LinkedIn details
No response
The text was updated successfully, but these errors were encountered: