Skip to content

Commit

Permalink
fix: Clear Message in New Conversation
Browse files Browse the repository at this point in the history
  • Loading branch information
Arindam200 committed Jan 25, 2024
1 parent caa2361 commit 1d723f8
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/app/components/Copilot/Copilot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export function createNewConversation() {
GlobalConversationID = _conversation.id;
})
}


})
}

Expand Down Expand Up @@ -117,6 +119,22 @@ export function CopilotChat(): React.JSX.Element {
setData(event.target.value);
};

// handles the ask button click.
const handleCopilotAskbuttonClick = async (chatInputData, setMessage)=>{
CopilotStreamController.getInstance().askQGPT({
query: chatInputData,
setMessage,
});
setData("");
}

// handles the new conversation button click.
const handleNewConversation = async () => {
createNewConversation();
setMessage("")
setData("")
};

// for setting the initial copilot chat that takes place on page load.
useEffect(() => {
const getInitialChat = async () => {
Expand All @@ -137,7 +155,7 @@ export function CopilotChat(): React.JSX.Element {
<div className="header">
<div>
<h1>Copilot Chat</h1>
<button className="button" onClick={createNewConversation}>Create Fresh Conversation</button>
<button className="button" onClick={handleNewConversation}>Create Fresh Conversation</button>
</div>
<div className="footer">
<button>back</button>
Expand All @@ -148,7 +166,7 @@ export function CopilotChat(): React.JSX.Element {
<div className="chat-box">
<div className="text-area">
<textarea placeholder="Type your prompt here..." value={chatInputData} onChange={handleCopilotChatInputChange}></textarea>
<button onClick={() => CopilotStreamController.getInstance().askQGPT({ query: chatInputData, setMessage })}>Ask</button>
<button onClick={() => handleCopilotAskbuttonClick(chatInputData,setMessage) }>Ask</button>
</div>
<div className="messages">
<div>
Expand All @@ -158,4 +176,4 @@ export function CopilotChat(): React.JSX.Element {
</div>
</div>
);
}
}

0 comments on commit 1d723f8

Please sign in to comment.