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:
Generated
+10
@@ -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
|
||||
Generated
+9
@@ -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>
|
||||
Generated
+8
@@ -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
@@ -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>
|
||||
Generated
+9
@@ -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.
@@ -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.
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user