From cf0a8b71fd0ee5eb4b63e8e9b19e079ad81f6690 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Thu, 18 Jun 2026 10:15:07 +0800 Subject: [PATCH] Refactor text chunking implementation and update configuration - Moved SentenceTextChunker and SentenceTextChunkerConfig to the utils module for better organization. - Updated pytest.ini to include the current directory in the Python path. - Added a new utils module with shared utility helpers. - Adjusted import paths in the test files to reflect the new location of text chunking classes. --- pytest.ini | 3 ++- src/api/endpoints.py | 2 +- src/utils/__init__.py | 1 + src/{voice => utils}/text_chunker.py | 0 test/test_text_chunker.py | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 src/utils/__init__.py rename src/{voice => utils}/text_chunker.py (100%) diff --git a/pytest.ini b/pytest.ini index ed2e4b8..b7a5232 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,4 @@ [pytest] +pythonpath = . markers = - integration: marks tests that need access to external services \ No newline at end of file + integration: marks tests that need access to external services diff --git a/src/api/endpoints.py b/src/api/endpoints.py index 28b9601..852b1d9 100644 --- a/src/api/endpoints.py +++ b/src/api/endpoints.py @@ -7,7 +7,7 @@ from fastgpt_client.exceptions import ( ) from ..core.fastgpt_client import get_fastgpt_client from ..core.config import Config -from ..voice.text_chunker import SentenceTextChunker, SentenceTextChunkerConfig +from ..utils.text_chunker import SentenceTextChunker, SentenceTextChunkerConfig from loguru import logger import json import re diff --git a/src/utils/__init__.py b/src/utils/__init__.py new file mode 100644 index 0000000..f46a82a --- /dev/null +++ b/src/utils/__init__.py @@ -0,0 +1 @@ +"""Shared utility helpers.""" diff --git a/src/voice/text_chunker.py b/src/utils/text_chunker.py similarity index 100% rename from src/voice/text_chunker.py rename to src/utils/text_chunker.py diff --git a/test/test_text_chunker.py b/test/test_text_chunker.py index cb2f2ad..d608a2d 100644 --- a/test/test_text_chunker.py +++ b/test/test_text_chunker.py @@ -1,4 +1,4 @@ -from src.voice.text_chunker import SentenceTextChunker, SentenceTextChunkerConfig +from src.utils.text_chunker import SentenceTextChunker, SentenceTextChunkerConfig def test_chinese_sentence_chunks_wait_for_lookahead():