diff --git a/.github/labeler.yml b/.github/labeler.yml index 0c9b1838..057772a5 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,23 +1,31 @@ repo: - - '*' +- changed-files: + - any-glob-to-any-file: '*' github: - - .github/**/* +- changed-files: + - any-glob-to-any-file: '.github/**/*' application: - - application/**/* +- changed-files: + - any-glob-to-any-file: 'application/**/*' docs: - - docs/**/* +- changed-files: + - any-glob-to-any-file: 'docs/**/*' extensions: - - extensions/**/* +- changed-files: + - any-glob-to-any-file: 'extensions/**/*' frontend: - - frontend/**/* +- changed-files: + - any-glob-to-any-file: 'frontend/**/*' scripts: - - scripts/**/* +- changed-files: + - any-glob-to-any-file: 'scripts/**/*' tests: - - tests/**/* +- changed-files: + - any-glob-to-any-file: 'tests/**/*' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be0263ff..090a69db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -34,7 +34,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker images to docker.io and ghcr.io - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: file: './application/Dockerfile' platforms: linux/amd64 diff --git a/.github/workflows/cife.yml b/.github/workflows/cife.yml index 4b1cbf3b..711cab29 100644 --- a/.github/workflows/cife.yml +++ b/.github/workflows/cife.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -35,7 +35,7 @@ jobs: # Runs a single command using the runners shell - name: Build and push Docker images to docker.io and ghcr.io - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: file: './frontend/Dockerfile' platforms: linux/amd64, linux/arm64 diff --git a/.github/workflows/docker-develop-build.yml b/.github/workflows/docker-develop-build.yml index 0bfc7e70..5a22b1a1 100644 --- a/.github/workflows/docker-develop-build.yml +++ b/.github/workflows/docker-develop-build.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -36,7 +36,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker images to docker.io and ghcr.io - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: file: './application/Dockerfile' platforms: linux/amd64 diff --git a/.github/workflows/docker-develop-fe-build.yml b/.github/workflows/docker-develop-fe-build.yml index 14dbccc5..317635bd 100644 --- a/.github/workflows/docker-develop-fe-build.yml +++ b/.github/workflows/docker-develop-fe-build.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -36,7 +36,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker images to docker.io and ghcr.io - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: file: './frontend/Dockerfile' platforms: linux/amd64 diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 7bdbab64..74b9d7d5 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -10,7 +10,7 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/labeler@v4 + - uses: actions/labeler@v5 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" sync-labels: true diff --git a/README.md b/README.md index 8f5897fa..eeecb598 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,6 @@ Say goodbye to time-consuming manual searches, and let None: + """Init params.""" + super().__init__(*args, **kwargs) + self._concat_slides = concat_slides + self._slide_separator = slide_separator + + def _init_parser(self) -> Dict: + """Init parser.""" + return {} + + def parse_file(self, file: Path, errors: str = "ignore") -> Union[str, List[str]]: + r""" + Parse a .pptx file and extract text from each slide. + Args: + file (Path): Path to the .pptx file. + errors (str): Error handling policy ('ignore' by default). + Returns: + Union[str, List[str]]: Concatenated text if concat_slides is True, + otherwise a list of slide texts. + """ + + try: + from pptx import Presentation + except ImportError: + raise ImportError("pptx module is required to read .PPTX files.") + + try: + presentation = Presentation(file) + slide_texts=[] + + # Iterate over each slide in the presentation + for slide in presentation.slides: + slide_text="" + + # Iterate over each shape in the slide + for shape in slide.shapes: + # Check if the shape has a 'text' attribute and append that to the slide_text + if hasattr(shape,"text"): + slide_text+=shape.text + + slide_texts.append(slide_text.strip()) + + if self._concat_slides: + return self._slide_separator.join(slide_texts) + else: + return slide_texts + + except Exception as e: + raise e \ No newline at end of file diff --git a/application/requirements.txt b/application/requirements.txt index 6ea1d1ba..2f28c2ea 100644 --- a/application/requirements.txt +++ b/application/requirements.txt @@ -14,6 +14,7 @@ esutils==1.0.1 Flask==3.0.3 faiss-cpu==1.8.0.post1 flask-restx==1.3.0 +gTTS==2.3.2 gunicorn==23.0.0 html2text==2024.2.26 javalang==0.13.0 @@ -65,6 +66,7 @@ pymongo==4.8.0 pypdf2==3.0.1 python-dateutil==2.9.0.post0 python-dotenv==1.0.1 +python-pptx==1.0.2 qdrant-client==1.11.0 redis==5.0.1 referencing==0.30.2 @@ -84,4 +86,4 @@ urllib3==2.2.3 vine==5.1.0 wcwidth==0.2.13 werkzeug==3.0.4 -yarl==1.11.1 +yarl==1.11.1 \ No newline at end of file diff --git a/application/retriever/brave_search.py b/application/retriever/brave_search.py index 29666a57..1fd844b2 100644 --- a/application/retriever/brave_search.py +++ b/application/retriever/brave_search.py @@ -75,7 +75,6 @@ class BraveRetSearch(BaseRetriever): if len(self.chat_history) > 1: tokens_current_history = 0 # count tokens in history - self.chat_history.reverse() for i in self.chat_history: if "prompt" in i and "response" in i: tokens_batch = num_tokens_from_string(i["prompt"]) + num_tokens_from_string( diff --git a/application/retriever/classic_rag.py b/application/retriever/classic_rag.py index b87b5852..6a67cb38 100644 --- a/application/retriever/classic_rag.py +++ b/application/retriever/classic_rag.py @@ -78,7 +78,6 @@ class ClassicRAG(BaseRetriever): if len(self.chat_history) > 1: tokens_current_history = 0 # count tokens in history - self.chat_history.reverse() for i in self.chat_history: if "prompt" in i and "response" in i: tokens_batch = num_tokens_from_string(i["prompt"]) + num_tokens_from_string( @@ -97,7 +96,6 @@ class ClassicRAG(BaseRetriever): llm = LLMCreator.create_llm( settings.LLM_NAME, api_key=settings.API_KEY, user_api_key=self.user_api_key ) - completion = llm.gen_stream(model=self.gpt_model, messages=messages_combine) for line in completion: yield {"answer": str(line)} diff --git a/application/retriever/duckduck_search.py b/application/retriever/duckduck_search.py index d746ecaa..6ae56226 100644 --- a/application/retriever/duckduck_search.py +++ b/application/retriever/duckduck_search.py @@ -92,7 +92,6 @@ class DuckDuckSearch(BaseRetriever): if len(self.chat_history) > 1: tokens_current_history = 0 # count tokens in history - self.chat_history.reverse() for i in self.chat_history: if "prompt" in i and "response" in i: tokens_batch = num_tokens_from_string(i["prompt"]) + num_tokens_from_string( diff --git a/application/tts/base.py b/application/tts/base.py new file mode 100644 index 00000000..143bed73 --- /dev/null +++ b/application/tts/base.py @@ -0,0 +1,10 @@ +from abc import ABC, abstractmethod + + +class BaseTTS(ABC): + def __init__(self): + pass + + @abstractmethod + def text_to_speech(self, *args, **kwargs): + pass \ No newline at end of file diff --git a/application/tts/elevenlabs.py b/application/tts/elevenlabs.py new file mode 100644 index 00000000..e1b3db27 --- /dev/null +++ b/application/tts/elevenlabs.py @@ -0,0 +1,29 @@ +from io import BytesIO +import base64 +from application.tts.base import BaseTTS + + +class ElevenlabsTTS(BaseTTS): + def __init__(self): + from elevenlabs.client import ElevenLabs + + self.client = ElevenLabs( + api_key="ELEVENLABS_API_KEY", + ) + + + def text_to_speech(self, text): + lang = "en" + audio = self.client.generate( + text=text, + model="eleven_multilingual_v2", + voice="Brian", + ) + audio_data = BytesIO() + for chunk in audio: + audio_data.write(chunk) + audio_bytes = audio_data.getvalue() + + # Encode to base64 + audio_base64 = base64.b64encode(audio_bytes).decode("utf-8") + return audio_base64, lang diff --git a/application/tts/google_tts.py b/application/tts/google_tts.py new file mode 100644 index 00000000..ee70161e --- /dev/null +++ b/application/tts/google_tts.py @@ -0,0 +1,19 @@ +import io +import base64 +from gtts import gTTS +from application.tts.base import BaseTTS + + +class GoogleTTS(BaseTTS): + def __init__(self): + pass + + + def text_to_speech(self, text): + lang = "en" + audio_fp = io.BytesIO() + tts = gTTS(text=text, lang=lang, slow=False) + tts.write_to_fp(audio_fp) + audio_fp.seek(0) + audio_base64 = base64.b64encode(audio_fp.read()).decode("utf-8") + return audio_base64, lang diff --git a/application/usage.py b/application/usage.py index aba0ec77..e87ebe38 100644 --- a/application/usage.py +++ b/application/usage.py @@ -1,10 +1,9 @@ import sys -from pymongo import MongoClient from datetime import datetime -from application.core.settings import settings +from application.core.mongo_db import MongoDB from application.utils import num_tokens_from_string -mongo = MongoClient(settings.MONGO_URI) +mongo = MongoDB.get_client() db = mongo["docsgpt"] usage_collection = db["token_usage"] diff --git a/application/worker.py b/application/worker.py index f8f38afa..33cd90e5 100755 --- a/application/worker.py +++ b/application/worker.py @@ -8,8 +8,8 @@ from urllib.parse import urljoin import requests from bson.objectid import ObjectId -from pymongo import MongoClient +from application.core.mongo_db import MongoDB from application.core.settings import settings from application.parser.file.bulk import SimpleDirectoryReader from application.parser.open_ai_func import call_openai_api @@ -18,7 +18,7 @@ from application.parser.schema.base import Document from application.parser.token_func import group_split from application.utils import count_tokens_docs -mongo = MongoClient(settings.MONGO_URI) +mongo = MongoDB.get_client() db = mongo["docsgpt"] sources_collection = db["sources"] diff --git a/docs/theme.config.jsx b/docs/theme.config.jsx index 2b868db7..777a0ed5 100644 --- a/docs/theme.config.jsx +++ b/docs/theme.config.jsx @@ -51,6 +51,9 @@ const config = { footer: { text: `MIT ${new Date().getFullYear()} © DocsGPT`, }, + editLink: { + content: 'Edit this page on GitHub', + }, logo() { return (
diff --git a/extensions/discord/bot.py b/extensions/discord/bot.py index 3cb1d1e2..94daf7e2 100644 --- a/extensions/discord/bot.py +++ b/extensions/discord/bot.py @@ -1,25 +1,60 @@ import os import re - +import logging +import aiohttp import discord -import requests from discord.ext import commands import dotenv dotenv.load_dotenv() -# Replace 'YOUR_BOT_TOKEN' with your bot's token +# Enable logging +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) + +# Bot configuration TOKEN = os.getenv("DISCORD_TOKEN") -PREFIX = '@DocsGPT' -BASE_API_URL = 'http://localhost:7091' +PREFIX = '!' # Command prefix +BASE_API_URL = os.getenv("API_BASE", "https://gptcloud.arc53.com") +API_URL = BASE_API_URL + "/api/answer" +API_KEY = os.getenv("API_KEY") intents = discord.Intents.default() intents.message_content = True bot = commands.Bot(command_prefix=PREFIX, intents=intents) +# Store conversation history per user +conversation_histories = {} + +def chunk_string(text, max_length=2000): + """Splits a string into chunks of a specified maximum length.""" + # Create list to store the split strings + chunks = [] + # Loop through the text, create substrings with max_length + while len(text) > max_length: + # Find last space within the limit + idx = text.rfind(' ', 0, max_length) + # Ensure we don't have an empty part + if idx == -1: + # If no spaces, just take chunk + chunks.append(text[:max_length]) + text = text[max_length:] + else: + # Push whatever we've got up to the last space + chunks.append(text[:idx]) + text = text[idx+1:] + # Catches the remaining part + chunks.append(text) + return chunks + +def escape_markdown(text): + """Escapes Discord markdown characters.""" + escape_chars = r'\*_$$$$()~>#+-=|{}.!' + return re.sub(f'([{re.escape(escape_chars)}])', r'\\\1', text) def split_string(input_str): + """Splits the input string to detect bot mentions.""" pattern = r'^<@!?{0}>\s*'.format(bot.user.id) match = re.match(pattern, input_str) if match: @@ -27,42 +62,97 @@ def split_string(input_str): return str(bot.user.id), content return None, input_str - @bot.event async def on_ready(): print(f'{bot.user.name} has connected to Discord!') - -async def fetch_answer(question): - data = { - 'sender': 'discord', - 'question': question, - 'history': '' +async def generate_answer(question, messages, conversation_id): + """Generates an answer using the external API.""" + payload = { + "question": question, + "api_key": API_KEY, + "history": messages, + "conversation_id": conversation_id } - headers = {"Content-Type": "application/json", - "Accept": "application/json"} - response = requests.post(BASE_API_URL + '/api/answer', json=data, headers=headers) - if response.status_code == 200: - return response.json()['answer'] - return 'Sorry, I could not fetch the answer.' + headers = { + "Content-Type": "application/json; charset=utf-8" + } + timeout = aiohttp.ClientTimeout(total=60) + async with aiohttp.ClientSession(timeout=timeout) as session: + async with session.post(API_URL, json=payload, headers=headers) as resp: + if resp.status == 200: + data = await resp.json() + conversation_id = data.get("conversation_id") + answer = data.get("answer", "Sorry, I couldn't find an answer.") + return {"answer": answer, "conversation_id": conversation_id} + else: + return {"answer": "Sorry, I couldn't find an answer.", "conversation_id": None} +@bot.command(name="start") +async def start(ctx): + """Handles the /start command.""" + await ctx.send(f"Hi {ctx.author.mention}! How can I assist you today?") + +@bot.command(name="custom_help") +async def custom_help_command(ctx): + """Handles the /custom_help command.""" + help_text = ( + "Here are the available commands:\n" + "`!start` - Begin a new conversation with the bot\n" + "`!help` - Display this help message\n\n" + "You can also mention me or send a direct message to ask a question!" + ) + await ctx.send(help_text) @bot.event async def on_message(message): if message.author == bot.user: return - content = message.content.strip() - prefix, content = split_string(content) - if prefix is None: - return - - part_prefix = str(bot.user.id) - if part_prefix == prefix: - answer = await fetch_answer(content) - await message.channel.send(answer) - + # Process commands first await bot.process_commands(message) + # Check if the message is in a DM channel + if isinstance(message.channel, discord.DMChannel): + content = message.content.strip() + else: + # In guild channels, check if the message mentions the bot at the start + content = message.content.strip() + prefix, content = split_string(content) + if prefix is None: + return + part_prefix = str(bot.user.id) + if part_prefix != prefix: + return # Bot not mentioned at the start, so do not process -bot.run(TOKEN) + # Now process the message + user_id = message.author.id + if user_id not in conversation_histories: + conversation_histories[user_id] = { + "history": [], + "conversation_id": None + } + + conversation = conversation_histories[user_id] + conversation["history"].append({"prompt": content}) + + # Generate the answer + response_doc = await generate_answer( + content, + conversation["history"], + conversation["conversation_id"] + ) + answer = response_doc["answer"] + conversation_id = response_doc["conversation_id"] + + answer_chunks = chunk_string(answer) + for chunk in answer_chunks: + await message.channel.send(chunk) + + conversation["history"][-1]["response"] = answer + conversation["conversation_id"] = conversation_id + + # Keep conversation history to last 10 exchanges + conversation["history"] = conversation["history"][-10:] + +bot.run(TOKEN) \ No newline at end of file diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 4087e4f5..9973bb9e 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -3075,6 +3075,24 @@ "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", "dev": true }, + "node_modules/easy-speech": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/easy-speech/-/easy-speech-2.4.0.tgz", + "integrity": "sha512-wpMv29DEoeP/eyXr4aXpDqd9DvlXl7aQs7BgfKbjGVxqkmQPgNmpbF5YULaTH5bc/5qrteg5MDfCD2Zd0qr4rQ==", + "funding": [ + { + "type": "GitHub", + "url": "https://github.com/sponsors/jankapunkt" + }, + { + "type": "PayPal", + "url": "https://paypal.me/kuesterjan" + } + ], + "engines": { + "node": ">= 14.x" + } + }, "node_modules/electron-to-chromium": { "version": "1.5.11", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.11.tgz", diff --git a/frontend/src/Navigation.tsx b/frontend/src/Navigation.tsx index b38ade53..ce23e90e 100644 --- a/frontend/src/Navigation.tsx +++ b/frontend/src/Navigation.tsx @@ -39,6 +39,8 @@ import { setSelectedDocs, setSourceDocs, } from './preferences/preferenceSlice'; +import Spinner from './assets/spinner.svg'; +import SpinnerDark from './assets/spinner-dark.svg'; import { selectQueries } from './conversation/conversationSlice'; import Upload from './upload/Upload'; import Help from './components/Help'; @@ -70,6 +72,7 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) { const conversations = useSelector(selectConversations); const modalStateDeleteConv = useSelector(selectModalStateDeleteConv); const conversationId = useSelector(selectConversationId); + const [isDeletingConversation, setIsDeletingConversation] = useState(false); const { isMobile } = useMediaQuery(); const [isDarkTheme] = useDarkTheme(); @@ -91,25 +94,28 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) { const navigate = useNavigate(); useEffect(() => { - if (!conversations) { + if (!conversations?.data) { fetchConversations(); } if (queries.length === 0) { resetConversation(); } - }, [conversations, dispatch]); + }, [conversations?.data, dispatch]); async function fetchConversations() { + dispatch(setConversations({ ...conversations, loading: true })); return await getConversations() .then((fetchedConversations) => { dispatch(setConversations(fetchedConversations)); }) .catch((error) => { console.error('Failed to fetch conversations: ', error); + dispatch(setConversations({ data: null, loading: false })); }); } const handleDeleteAllConversations = () => { + setIsDeletingConversation(true); conversationService .deleteAll() .then(() => { @@ -119,6 +125,7 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) { }; const handleDeleteConversation = (id: string) => { + setIsDeletingConversation(true); conversationService .delete(id, {}) .then(() => { @@ -205,6 +212,7 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) { setNavOpen(!isMobile); }, [isMobile]); useDefaultDocument(); + return ( <> {!navOpen && ( @@ -306,13 +314,22 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) { id="conversationsMainDiv" className="mb-auto h-[78vh] overflow-y-auto overflow-x-hidden dark:text-white" > - {conversations && conversations.length > 0 ? ( + {conversations?.loading && !isDeletingConversation && ( +
+ Loading... +
+ )} + {conversations?.data && conversations.data.length > 0 ? (

{t('chats')}

- {conversations?.map((conversation) => ( + {conversations.data?.map((conversation) => ( + + diff --git a/frontend/src/assets/speaker.svg b/frontend/src/assets/speaker.svg new file mode 100644 index 00000000..6c379177 --- /dev/null +++ b/frontend/src/assets/speaker.svg @@ -0,0 +1,4 @@ + + + + diff --git a/frontend/src/assets/stopspeech.svg b/frontend/src/assets/stopspeech.svg new file mode 100644 index 00000000..f77a235b --- /dev/null +++ b/frontend/src/assets/stopspeech.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/frontend/src/components/TextToSpeechButton.tsx b/frontend/src/components/TextToSpeechButton.tsx new file mode 100644 index 00000000..2cb9e8f8 --- /dev/null +++ b/frontend/src/components/TextToSpeechButton.tsx @@ -0,0 +1,94 @@ +import { useState, useRef } from 'react'; +import Speaker from '../assets/speaker.svg?react'; +import Stopspeech from '../assets/stopspeech.svg?react'; +import LoadingIcon from '../assets/Loading.svg?react'; // Add a loading icon SVG here +const apiHost = import.meta.env.VITE_API_HOST || 'https://docsapi.arc53.com'; + +export default function SpeakButton({ + text, + colorLight, + colorDark, +}: { + text: string; + colorLight?: string; + colorDark?: string; +}) { + const [isSpeaking, setIsSpeaking] = useState(false); + const [isLoading, setIsLoading] = useState(false); + const [isSpeakHovered, setIsSpeakHovered] = useState(false); + const audioRef = useRef(null); + + const handleSpeakClick = async () => { + if (isSpeaking) { + // Stop audio if it's currently playing + audioRef.current?.pause(); + audioRef.current = null; + setIsSpeaking(false); + return; + } + + try { + // Set loading state and initiate TTS request + setIsLoading(true); + + const response = await fetch(apiHost + '/api/tts', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ text }), + }); + + const data = await response.json(); + + if (data.success && data.audio_base64) { + // Create and play the audio + const audio = new Audio(`data:audio/mp3;base64,${data.audio_base64}`); + audioRef.current = audio; + + audio.play().then(() => { + setIsSpeaking(true); + setIsLoading(false); + + // Reset when audio ends + audio.onended = () => { + setIsSpeaking(false); + audioRef.current = null; + }; + }); + } else { + console.error('Failed to retrieve audio.'); + setIsLoading(false); + } + } catch (error) { + console.error('Error fetching audio from TTS endpoint', error); + setIsLoading(false); + } + }; + + return ( +
+ {isLoading ? ( + + ) : isSpeaking ? ( + setIsSpeakHovered(true)} + onMouseLeave={() => setIsSpeakHovered(false)} + /> + ) : ( + setIsSpeakHovered(true)} + onMouseLeave={() => setIsSpeakHovered(false)} + /> + )} +
+ ); +} diff --git a/frontend/src/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx index 2ccf1ca3..a9a05168 100644 --- a/frontend/src/conversation/ConversationBubble.tsx +++ b/frontend/src/conversation/ConversationBubble.tsx @@ -7,7 +7,6 @@ import remarkGfm from 'remark-gfm'; import remarkMath from 'remark-math'; import rehypeKatex from 'rehype-katex'; import 'katex/dist/katex.min.css'; - import DocsGPT3 from '../assets/cute_docsgpt3.svg'; import Dislike from '../assets/dislike.svg?react'; import Document from '../assets/document.svg'; @@ -23,6 +22,7 @@ import { } from '../preferences/preferenceSlice'; import classes from './ConversationBubble.module.css'; import { FEEDBACK, MESSAGE_TYPE } from './conversationModels'; +import SpeakButton from '../components/TextToSpeechButton'; const DisableSourceFE = import.meta.env.VITE_DISABLE_SOURCE_FE || false; @@ -336,6 +336,14 @@ const ConversationBubble = forwardRef<
+
+
+ {/* Add SpeakButton here */} +
+
{type === 'ERROR' && (
{retryBtn}
diff --git a/frontend/src/index.css b/frontend/src/index.css index 9b87724a..4319403e 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -4,6 +4,7 @@ :root { --viewport-height: 100vh; + font-synthesis: none !important; } @supports (height: 100dvh) { diff --git a/frontend/src/locale/en.json b/frontend/src/locale/en.json index a1f254ac..b1268df7 100644 --- a/frontend/src/locale/en.json +++ b/frontend/src/locale/en.json @@ -12,7 +12,7 @@ "cancel": "Cancel", "help": "Help", "emailUs": "Email us", - "documentation": "documentation", + "documentation": "Documentation", "demo": [ { "header": "Learn about DocsGPT", @@ -86,7 +86,7 @@ "start": "Start Chatting", "name": "Name", "choose": "Choose Files", - "info": "Please upload .pdf, .txt, .rst, .csv, .xlsx, .docx, .md, .html, .epub, .json, .zip limited to 25mb", + "info": "Please upload .pdf, .txt, .rst, .csv, .xlsx, .docx, .md, .html, .epub, .json, .pptx, .zip limited to 25mb", "uploadedFiles": "Uploaded Files", "cancel": "Cancel", "train": "Train", diff --git a/frontend/src/locale/es.json b/frontend/src/locale/es.json index 6a096ffd..296dbb16 100644 --- a/frontend/src/locale/es.json +++ b/frontend/src/locale/es.json @@ -12,7 +12,7 @@ "cancel": "Cancelar", "help": "Asistencia", "emailUs": "Envíanos un correo", - "documentation": "documentación", + "documentation": "Documentación", "demo": [ { "header": "Aprende sobre DocsGPT", @@ -86,7 +86,7 @@ "start": "Empezar a chatear", "name": "Nombre", "choose": "Seleccionar Archivos", - "info": "Por favor, suba archivos .pdf, .txt, .rst, .csv, .xlsx, .docx, .md, .html, .epub, .json, .zip limitados a 25 MB", + "info": "Por favor, suba archivos .pdf, .txt, .rst, .csv, .xlsx, .docx, .md, .html, .epub, .json, .pptx, .zip limitados a 25 MB", "uploadedFiles": "Archivos Subidos", "cancel": "Cancelar", "train": "Entrenar", diff --git a/frontend/src/locale/jp.json b/frontend/src/locale/jp.json index 841a477b..a69ae31f 100644 --- a/frontend/src/locale/jp.json +++ b/frontend/src/locale/jp.json @@ -86,7 +86,7 @@ "start": "チャットを開始する", "name": "名前", "choose": "ファイルを選択", - "info": ".pdf, .txt, .rst, .docx, .md, .json, .zipファイルを25MBまでアップロードしてください", + "info": ".pdf, .txt, .rst, .docx, .md, .json, .pptx, .zipファイルを25MBまでアップロードしてください", "uploadedFiles": "アップロードされたファイル", "cancel": "キャンセル", "train": "トレーニング", diff --git a/frontend/src/locale/zh-TW.json b/frontend/src/locale/zh-TW.json index 35df818b..fa0638f4 100644 --- a/frontend/src/locale/zh-TW.json +++ b/frontend/src/locale/zh-TW.json @@ -80,7 +80,7 @@ "remote": "遠端", "name": "名稱", "choose": "選擇檔案", - "info": "請上傳 .pdf, .txt, .rst, .docx, .md, .json, .zip 檔案,大小限制為 25MB", + "info": "請上傳 .pdf, .txt, .rst, .docx, .md, .json, .pptx, .zip 檔案,大小限制為 25MB", "uploadedFiles": "已上傳的檔案", "cancel": "取消", "train": "訓練", diff --git a/frontend/src/locale/zh.json b/frontend/src/locale/zh.json index 710c5e3e..51f8bfe9 100644 --- a/frontend/src/locale/zh.json +++ b/frontend/src/locale/zh.json @@ -86,7 +86,7 @@ "start": "开始聊天", "name": "名称", "choose": "选择文件", - "info": "请上传 .pdf, .txt, .rst, .csv, .xlsx, .docx, .md, .html, .epub, .json, .zip 文件,限 25MB", + "info": "请上传 .pdf, .txt, .rst, .csv, .xlsx, .docx, .md, .html, .epub, .json, .pptx, .zip 文件,限 25MB", "uploadedFiles": "已上传文件", "cancel": "取消", "train": "训练", diff --git a/frontend/src/preferences/preferenceApi.ts b/frontend/src/preferences/preferenceApi.ts index a8e46a72..ed730f7c 100644 --- a/frontend/src/preferences/preferenceApi.ts +++ b/frontend/src/preferences/preferenceApi.ts @@ -21,9 +21,10 @@ export async function getDocs(): Promise { } } -export async function getConversations(): Promise< - { name: string; id: string }[] | null -> { +export async function getConversations(): Promise<{ + data: { name: string; id: string }[] | null; + loading: boolean; +}> { try { const response = await conversationService.getConversations(); const data = await response.json(); @@ -34,10 +35,10 @@ export async function getConversations(): Promise< conversations.push(conversation as { name: string; id: string }); }); - return conversations; + return { data: conversations, loading: false }; } catch (error) { console.log(error); - return null; + return { data: null, loading: false }; } } diff --git a/frontend/src/preferences/preferenceSlice.ts b/frontend/src/preferences/preferenceSlice.ts index 6fb2480b..c566ba70 100644 --- a/frontend/src/preferences/preferenceSlice.ts +++ b/frontend/src/preferences/preferenceSlice.ts @@ -15,7 +15,10 @@ export interface Preference { token_limit: number; selectedDocs: Doc | null; sourceDocs: Doc[] | null; - conversations: { name: string; id: string }[] | null; + conversations: { + data: { name: string; id: string }[] | null; + loading: boolean; + }; modalState: ActiveState; } @@ -34,7 +37,10 @@ const initialState: Preference = { retriever: 'classic', } as Doc, sourceDocs: null, - conversations: null, + conversations: { + data: null, + loading: false, + }, modalState: 'INACTIVE', }; diff --git a/frontend/src/store.ts b/frontend/src/store.ts index 565ea8cc..5843d493 100644 --- a/frontend/src/store.ts +++ b/frontend/src/store.ts @@ -23,7 +23,10 @@ const preloadedState: { preference: Preference } = { chunks: JSON.parse(chunks ?? '2').toString(), token_limit: token_limit ? parseInt(token_limit) : 2000, selectedDocs: doc !== null ? JSON.parse(doc) : null, - conversations: null, + conversations: { + data: null, + loading: false, + }, sourceDocs: [ { name: 'default', diff --git a/frontend/src/upload/Upload.tsx b/frontend/src/upload/Upload.tsx index 2da284c3..81ce9f2b 100644 --- a/frontend/src/upload/Upload.tsx +++ b/frontend/src/upload/Upload.tsx @@ -321,6 +321,8 @@ function Upload({ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': [ '.xlsx', ], + 'application/vnd.openxmlformats-officedocument.presentationml.presentation': + ['.pptx'], }, }); diff --git a/lexeu-competition.md b/lexeu-competition.md index 1077de29..e8824438 100644 --- a/lexeu-competition.md +++ b/lexeu-competition.md @@ -12,8 +12,8 @@ Welcome to the LLM Document Analysis by [LexEU](https://www.lexeu.ai/) competiti ### 📆 Timeline: - **Competition Announcement:** 1st October -- **Deadline for Submissions:** 27th October -- **Results Announcement:** Early November/ Late October +- **Deadline for Submissions:** 8th November +- **Results Announcement:** Early November ## 📜 How to Participate: diff --git a/run-with-docker-compose.sh b/run-with-docker-compose.sh index 61aab467..145b1e23 100755 --- a/run-with-docker-compose.sh +++ b/run-with-docker-compose.sh @@ -4,8 +4,8 @@ source .env if [[ -n "$OPENAI_API_BASE" ]] && [[ -n "$OPENAI_API_VERSION" ]] && [[ -n "$AZURE_DEPLOYMENT_NAME" ]] && [[ -n "$AZURE_EMBEDDINGS_DEPLOYMENT_NAME" ]]; then echo "Running Azure Configuration" - docker compose -f docker-compose-azure.yaml build && docker compose -f docker-compose-azure.yaml up + docker compose -f docker-compose-azure.yaml up --build else echo "Running Plain Configuration" - docker compose build && docker compose up + docker compose up --build fi