Feature:Add voice dialogue functionality to the agent application (#11668)

### What problem does this PR solve?

Feature:Add voice dialogue functionality to the agent application

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
chanx
2025-12-02 19:39:43 +08:00
committed by GitHub
parent 962bd5f5df
commit 1388c4420d
16 changed files with 677 additions and 60 deletions

View File

@ -3,6 +3,8 @@ import CopyToClipboard from '@/components/copy-to-clipboard';
import { useSetModalState } from '@/hooks/common-hooks';
import { IRemoveMessageById } from '@/hooks/logic-hooks';
import { AgentChatContext } from '@/pages/agent/context';
import { downloadFile } from '@/services/file-manager-service';
import { downloadFileFromBlob } from '@/utils/file-util';
import {
DeleteOutlined,
DislikeOutlined,
@ -12,7 +14,7 @@ import {
SyncOutlined,
} from '@ant-design/icons';
import { Radio, Tooltip } from 'antd';
import { NotebookText } from 'lucide-react';
import { Download, NotebookText } from 'lucide-react';
import { useCallback, useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { ToggleGroup, ToggleGroupItem } from '../ui/toggle-group';
@ -28,6 +30,11 @@ interface IProps {
audioBinary?: string;
showLoudspeaker?: boolean;
showLog?: boolean;
attachment?: {
file_name: string;
doc_id: string;
format: string;
};
}
export const AssistantGroupButton = ({
@ -38,6 +45,7 @@ export const AssistantGroupButton = ({
showLikeButton,
showLoudspeaker = true,
showLog = true,
attachment,
}: IProps) => {
const { visible, hideModal, showModal, onFeedbackOk, loading } =
useSendFeedback(messageId);
@ -98,6 +106,27 @@ export const AssistantGroupButton = ({
<NotebookText className="size-4" />
</ToggleGroupItem>
)}
{!!attachment?.doc_id && (
<ToggleGroupItem
value="g"
onClick={async () => {
try {
const response = await downloadFile({
docId: attachment.doc_id,
ext: attachment.format,
});
const blob = new Blob([response.data], {
type: response.data.type,
});
downloadFileFromBlob(blob, attachment.file_name);
} catch (error) {
console.error('Download failed:', error);
}
}}
>
<Download size={16} />
</ToggleGroupItem>
)}
</ToggleGroup>
{visible && (
<FeedbackModal