forked from open-webui/open-webui
		
	feat: audio rag support
This commit is contained in:
		
							parent
							
								
									a5b9bbf10b
								
							
						
					
					
						commit
						c6c69924d1
					
				
					 3 changed files with 24 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
	import toast from 'svelte-french-toast';
 | 
			
		||||
	import { onMount, tick } from 'svelte';
 | 
			
		||||
	import { settings } from '$lib/stores';
 | 
			
		||||
	import { calculateSHA256, findWordIndices } from '$lib/utils';
 | 
			
		||||
	import { blobToFile, calculateSHA256, findWordIndices } from '$lib/utils';
 | 
			
		||||
 | 
			
		||||
	import Prompts from './MessageInput/PromptCommands.svelte';
 | 
			
		||||
	import Suggestions from './MessageInput/Suggestions.svelte';
 | 
			
		||||
| 
						 | 
				
			
			@ -124,6 +124,20 @@
 | 
			
		|||
 | 
			
		||||
		try {
 | 
			
		||||
			files = [...files, doc];
 | 
			
		||||
 | 
			
		||||
			if (['audio/mpeg', 'audio/wav'].includes(file['type'])) {
 | 
			
		||||
				const res = await transcribeAudio(localStorage.token, file).catch((error) => {
 | 
			
		||||
					toast.error(error);
 | 
			
		||||
					return null;
 | 
			
		||||
				});
 | 
			
		||||
 | 
			
		||||
				if (res) {
 | 
			
		||||
					console.log(res);
 | 
			
		||||
					const blob = new Blob([res.text], { type: 'text/plain' });
 | 
			
		||||
					file = blobToFile(blob, `${file.name}.txt`);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			const res = await uploadDocToVectorDB(localStorage.token, '', file);
 | 
			
		||||
 | 
			
		||||
			if (res) {
 | 
			
		||||
| 
						 | 
				
			
			@ -202,9 +216,6 @@
 | 
			
		|||
					console.log(file, file.name.split('.').at(-1));
 | 
			
		||||
					if (['image/gif', 'image/jpeg', 'image/png'].includes(file['type'])) {
 | 
			
		||||
						reader.readAsDataURL(file);
 | 
			
		||||
					} else if (['audio/mpeg', 'audio/wav'].includes(file['type'])) {
 | 
			
		||||
						const res = await transcribeAudio(localStorage.token, file);
 | 
			
		||||
						console.log(res);
 | 
			
		||||
					} else if (
 | 
			
		||||
						SUPPORTED_FILE_TYPE.includes(file['type']) ||
 | 
			
		||||
						SUPPORTED_FILE_EXTENSIONS.includes(file.name.split('.').at(-1))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue