diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..30cf57e --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..5c38e4b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..fbf2f7e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/youlbot-webui.iml b/.idea/youlbot-webui.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/youlbot-webui.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/__pycache__/api_client.cpython-312.pyc b/__pycache__/api_client.cpython-312.pyc new file mode 100644 index 0000000..4b7ab73 Binary files /dev/null and b/__pycache__/api_client.cpython-312.pyc differ diff --git a/__pycache__/app.cpython-312.pyc b/__pycache__/app.cpython-312.pyc new file mode 100644 index 0000000..e825013 Binary files /dev/null and b/__pycache__/app.cpython-312.pyc differ diff --git a/__pycache__/config.cpython-312.pyc b/__pycache__/config.cpython-312.pyc new file mode 100644 index 0000000..a38387f Binary files /dev/null and b/__pycache__/config.cpython-312.pyc differ diff --git a/__pycache__/container.cpython-312.pyc b/__pycache__/container.cpython-312.pyc new file mode 100644 index 0000000..9d93c81 Binary files /dev/null and b/__pycache__/container.cpython-312.pyc differ diff --git a/__pycache__/services.cpython-312.pyc b/__pycache__/services.cpython-312.pyc new file mode 100644 index 0000000..eaf7196 Binary files /dev/null and b/__pycache__/services.cpython-312.pyc differ diff --git a/services/__init__.py b/services/__init__.py new file mode 100644 index 0000000..ec02651 --- /dev/null +++ b/services/__init__.py @@ -0,0 +1,5 @@ +from services.chat import ChatService +from services.document import DocumentService +from services.tts import TTSService + +__all__ = ["ChatService", "DocumentService", "TTSService"] diff --git a/services/__pycache__/__init__.cpython-312.pyc b/services/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..eeb5809 Binary files /dev/null and b/services/__pycache__/__init__.cpython-312.pyc differ diff --git a/services/__pycache__/chat.cpython-312.pyc b/services/__pycache__/chat.cpython-312.pyc new file mode 100644 index 0000000..426387b Binary files /dev/null and b/services/__pycache__/chat.cpython-312.pyc differ diff --git a/services/__pycache__/document.cpython-312.pyc b/services/__pycache__/document.cpython-312.pyc new file mode 100644 index 0000000..da32776 Binary files /dev/null and b/services/__pycache__/document.cpython-312.pyc differ diff --git a/services/__pycache__/tts.cpython-312.pyc b/services/__pycache__/tts.cpython-312.pyc new file mode 100644 index 0000000..db08854 Binary files /dev/null and b/services/__pycache__/tts.cpython-312.pyc differ diff --git a/services/chat.py b/services/chat.py new file mode 100644 index 0000000..2e58ae8 --- /dev/null +++ b/services/chat.py @@ -0,0 +1,26 @@ +from typing import AsyncIterator + +from api_client import APIClientProtocol + + +class ChatService: + def __init__(self, api_client: APIClientProtocol): + self._api = api_client + + def chat( + self, message: str, user_id: str, show_thinking: bool + ) -> AsyncIterator[tuple[str, str | None]]: + return self._api.chat(message, user_id, show_thinking) + + async def reset(self, user_id: str) -> None: + await self._api.reset(user_id) + + async def save_feedback( + self, + user_id: str, + user_msg: str, + asst_msg: str, + rating: int, + run_id: str | None, + ) -> None: + await self._api.save_feedback(user_id, user_msg, asst_msg, rating, run_id) diff --git a/services/document.py b/services/document.py new file mode 100644 index 0000000..d4c5661 --- /dev/null +++ b/services/document.py @@ -0,0 +1,15 @@ +from api_client import APIClientProtocol + + +class DocumentService: + def __init__(self, api_client: APIClientProtocol): + self._api = api_client + + async def ingest(self, file_path: str) -> dict: + return await self._api.ingest(file_path) + + async def list_documents(self) -> list[str]: + return await self._api.list_documents() + + async def delete_document(self, source: str) -> None: + await self._api.delete_document(source) diff --git a/services.py b/services/tts.py similarity index 58% rename from services.py rename to services/tts.py index 2c64341..c5425d7 100644 --- a/services.py +++ b/services/tts.py @@ -1,51 +1,11 @@ -"""ChatService, DocumentService, TTSService.""" import asyncio import platform import subprocess import tempfile -from typing import AsyncIterator -from api_client import APIClientProtocol from config import AppConfig -class ChatService: - def __init__(self, api_client: APIClientProtocol): - self._api = api_client - - def chat( - self, message: str, user_id: str, show_thinking: bool - ) -> AsyncIterator[tuple[str, str | None]]: - return self._api.chat(message, user_id, show_thinking) - - async def reset(self, user_id: str) -> None: - await self._api.reset(user_id) - - async def save_feedback( - self, - user_id: str, - user_msg: str, - asst_msg: str, - rating: int, - run_id: str | None, - ) -> None: - await self._api.save_feedback(user_id, user_msg, asst_msg, rating, run_id) - - -class DocumentService: - def __init__(self, api_client: APIClientProtocol): - self._api = api_client - - async def ingest(self, file_path: str) -> dict: - return await self._api.ingest(file_path) - - async def list_documents(self) -> list[str]: - return await self._api.list_documents() - - async def delete_document(self, source: str) -> None: - await self._api.delete_document(source) - - class TTSService: def __init__(self, config: AppConfig): self._voice = config.tts_voice