Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions code/frontend/src/components/Answer/Answer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ export const Answer = ({
}
}, [isActive, synthesizer]);

useEffect(() => {
return () => {
if (isSpeaking) {
resetSpeech();
}
};
}, []);

useEffect(() => {
setChevronIsExpanded(isRefAccordionOpen);
// if (chevronIsExpanded && refContainer.current) {
Expand Down Expand Up @@ -221,7 +229,7 @@ export const Answer = ({
const handleSpeakPauseResume = () => {
if (isSpeaking) {
if (isPaused) {
onSpeak(index, "speak");
onSpeak(index, "speak", resetSpeech);
audioDestination?.resume();
setIsPaused(false);
setStartTime(Date.now());
Expand All @@ -238,7 +246,7 @@ export const Answer = ({
}
}
} else {
onSpeak(index, "speak");
onSpeak(index, "speak", resetSpeech);
startSpeech();
}
};
Expand Down
21 changes: 19 additions & 2 deletions code/frontend/src/pages/chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const [ASSISTANT, TOOL, ERROR] = ["assistant", "tool", "error"];
const Chat = () => {
const lastQuestionRef = useRef<string>("");
const chatMessageStreamEnd = useRef<HTMLDivElement | null>(null);
const audioStopRef = useRef<(() => void) | null>(null);
const [isLoading, setIsLoading] = useState<boolean>(false);
const [isGenerating, setIsGenerating] = useState<boolean>(false); // Add this state
const [showLoadingMessage, setShowLoadingMessage] = useState<boolean>(false);
Expand Down Expand Up @@ -303,11 +304,13 @@ const Chat = () => {
};

const clearChat = () => {
audioStopRef.current?.();
lastQuestionRef.current = "";
setActiveCitation(undefined);
setAnswers([]);
setConversationId(uuidv4());
setSelectedConvId("");
setActiveCardIndex(null);
};

const stopGenerating = () => {
Expand Down Expand Up @@ -385,9 +388,12 @@ const Chat = () => {
[]
);

const handleSpeech = (index: number, status: string) => {
const handleSpeech = (index: number, status: string, stopAudioFn?: () => void) => {
if (status != "pause") setActiveCardIndex(index);
setIsTextToSpeachActive(status == "speak" ? true : false);
if (status == "speak" && stopAudioFn) {
audioStopRef.current = stopAudioFn;
}
};
const onSetShowHistoryPanel = () => {
if (!showHistoryPanel) {
Expand Down Expand Up @@ -423,8 +429,15 @@ const Chat = () => {
console.error("No conversation Id found");
return;
}

if (id !== selectedConvId) {
audioStopRef.current?.();
setActiveCardIndex(null);
}

const messages = getMessagesByConvId(id);
if (messages.length === 0) {
setAnswers([]);
setFetchingConvMessages(true);
const responseMessages = await historyRead(id);
setAnswers(responseMessages);
Expand All @@ -433,7 +446,10 @@ const Chat = () => {
} else {
setAnswers(messages);
}
setSelectedConvId(id);

if (id !== selectedConvId) {
setSelectedConvId(id);
}
};

useEffect(() => {
Expand Down Expand Up @@ -477,6 +493,7 @@ const Chat = () => {
);
setChatHistory(tempChatHistory);
if (id === selectedConvId) {
audioStopRef.current?.();
lastQuestionRef.current = "";
setActiveCitation(undefined);
setAnswers([]);
Expand Down
4 changes: 4 additions & 0 deletions docs/LOCAL_DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ azd env set USE_KEY_VAULT false

Also please refer to the section on [setting up RBAC auth](#authenticate-using-rbac).


## 🛠️ Troubleshooting
If you encounter any issues during the deployment process, please refer to the [TroubleShootingSteps](TroubleShootingSteps.md) document for detailed steps and solutions.

## Deployment Options & Steps

### Sandbox or WAF Aligned Deployment Options
Expand Down
3 changes: 3 additions & 0 deletions docs/NON_DEVCONTAINER_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ The Azure Developer CLI (`azd`) is a developer-centric command-line interface (C
> **Note:** This solution accelerator requires **Azure Developer CLI (azd) version 1.18.0 or higher**. Please ensure you have the latest version installed before proceeding with deployment. [Download azd here](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd).

> Select your desired `subscription` and `location`. Wait a moment for the resource deployment to complete, click the website endpoint and you will see the web app page.

## 🛠️ Troubleshooting
If you encounter any issues during the deployment process, please refer to the [TroubleShootingSteps](TroubleShootingSteps.md) document for detailed steps and solutions.
Loading
Loading