Refactor: split services.py into services/ package

ChatService → services/chat.py
DocumentService → services/document.py
TTSService → services/tts.py
services/__init__.py re-exports all three for backward-compatible imports

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sal
2026-06-01 17:39:52 +09:00
parent d81a2f5888
commit 1e93def909
18 changed files with 88 additions and 40 deletions
+10
View File
@@ -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
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="py_ai" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_24" default="true" project-jdk-name="py_ai" project-jdk-type="Python SDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/youlbot-webui.iml" filepath="$PROJECT_DIR$/.idea/youlbot-webui.iml" />
</modules>
</component>
</project>
Generated
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5
View File
@@ -0,0 +1,5 @@
from services.chat import ChatService
from services.document import DocumentService
from services.tts import TTSService
__all__ = ["ChatService", "DocumentService", "TTSService"]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+26
View File
@@ -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)
+15
View File
@@ -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)
-40
View File
@@ -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