codebuff-agent 2.1.74__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codebuff_agent-2.1.74.data/data/etc/jupyter/jupyter_server_config.d/codebuff_agent.json +7 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/package.json +157 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/104.2b8f20f9d1ac2c9db01b.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/150.39fa98117cc8ca590465.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/166.386ff9b2c37ac865fdee.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/216.25cf81131bf7274dabf4.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/353.581bd1cb00746399b62e.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/367.575f9621b63c9a641aa9.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/421.11dac223a2c2da1b09f5.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/432.8513b4c6cc1d1232d165.js +2 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/432.8513b4c6cc1d1232d165.js.LICENSE.txt +19 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/439.ba5b5ef70ec6de214b8c.js +2 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/439.ba5b5ef70ec6de214b8c.js.LICENSE.txt +8 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/481.cc2dec9fa869d66f1407.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/487.0796e931d6e651482c14.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/49.d326f554b6f9ccde6580.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/541.26897ea32845659e36be.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/579.e569d3edd8391fd8fbb3.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/58.eb7cc679f7535cc8a2f1.js +2 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/58.eb7cc679f7535cc8a2f1.js.LICENSE.txt +8 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/666.d9bfdb23f98489d0a188.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/677.d266c39dbed33bc388b3.js +2 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/677.d266c39dbed33bc388b3.js.LICENSE.txt +8 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/68.26b6f59c8454adb17f20.js +204 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/694.4ac443814260057e68f7.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/791.61affb8d3480d3d60e0d.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/848.4d2db09cfbb09374b299.js +2 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/848.4d2db09cfbb09374b299.js.LICENSE.txt +9 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/868.5cfe7e1a348ec5af1b8c.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/97.ea559a5b8a9a09f17c6b.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/remoteEntry.5292fc9c6df7e7920cc8.js +1 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/style.js +4 -0
- codebuff_agent-2.1.74.data/data/share/jupyter/labextensions/codebuff/static/third-party-licenses.json +724 -0
- codebuff_agent-2.1.74.dist-info/METADATA +142 -0
- codebuff_agent-2.1.74.dist-info/RECORD +217 -0
- codebuff_agent-2.1.74.dist-info/WHEEL +4 -0
- codebuff_agent-2.1.74.dist-info/licenses/LICENSE +21 -0
- codebuff_core/__init__.py +153 -0
- codebuff_core/codebuff_config_defaults.json +64 -0
- codebuff_core/core/__init__.py +35 -0
- codebuff_core/core/code_validator.py +1238 -0
- codebuff_core/core/error_classifier.py +579 -0
- codebuff_core/core/exceptions.py +49 -0
- codebuff_core/data/tiktoken_cache/9b5ad71b2ce5302211f9c61530b329a4922fc6a4 +100256 -0
- codebuff_core/directory_policy.py +32 -0
- codebuff_core/factory.py +155 -0
- codebuff_core/interfaces.py +197 -0
- codebuff_core/knowledge/__init__.py +31 -0
- codebuff_core/knowledge/chunking.py +375 -0
- codebuff_core/knowledge/loader.py +339 -0
- codebuff_core/knowledge/watchdog_service.py +354 -0
- codebuff_core/legacy_paths.py +69 -0
- codebuff_core/llm/__init__.py +13 -0
- codebuff_core/llm/service.py +407 -0
- codebuff_core/managers/__init__.py +22 -0
- codebuff_core/managers/config_manager.py +690 -0
- codebuff_core/managers/remote_config.py +673 -0
- codebuff_core/managers/remote_skills.py +539 -0
- codebuff_core/managers/session_manager.py +255 -0
- codebuff_core/middleware/__init__.py +3 -0
- codebuff_core/middleware/error_recovery.py +394 -0
- codebuff_core/middleware/logging_utils.py +33 -0
- codebuff_core/models/__init__.py +111 -0
- codebuff_core/models/agent.py +306 -0
- codebuff_core/models/chat.py +57 -0
- codebuff_core/models/common.py +82 -0
- codebuff_core/models/rag.py +300 -0
- codebuff_core/platform_rules.py +127 -0
- codebuff_core/prompts/__init__.py +44 -0
- codebuff_core/prompts/auto_agent_prompts.py +1278 -0
- codebuff_core/services/__init__.py +30 -0
- codebuff_core/services/agent_service.py +345 -0
- codebuff_core/services/analytics_aggregate.py +837 -0
- codebuff_core/services/chat_service.py +898 -0
- codebuff_core/services/context_condenser.py +306 -0
- codebuff_core/services/pii_guardrail.py +393 -0
- codebuff_core/services/rag_chat_agent.py +2993 -0
- codebuff_core/services/rag_collections.py +2740 -0
- codebuff_core/services/rag_manager.py +890 -0
- codebuff_core/services/rag_service.py +145 -0
- codebuff_core/services/retriever.py +260 -0
- codebuff_core/services/vllm_embedding_service.py +290 -0
- codebuff_core/tests/__init__.py +1 -0
- codebuff_core/tests/conftest.py +81 -0
- codebuff_core/tests/test_error_recovery.py +647 -0
- codebuff_core/tests/test_factory.py +135 -0
- codebuff_core/tests/test_services.py +150 -0
- jupyter_ext/__init__.py +266 -0
- jupyter_ext/_version.py +4 -0
- jupyter_ext/agent/__init__.py +49 -0
- jupyter_ext/agent/agent_factory.py +2270 -0
- jupyter_ext/agent/ast_tools.py +451 -0
- jupyter_ext/agent/autofix_middleware.py +481 -0
- jupyter_ext/agent/background_procs.py +372 -0
- jupyter_ext/agent/code_history_middleware.py +211 -0
- jupyter_ext/agent/codex_autofix.py +160 -0
- jupyter_ext/agent/codex_bridge.py +3339 -0
- jupyter_ext/agent/codex_hooks.py +320 -0
- jupyter_ext/agent/codex_slash.py +685 -0
- jupyter_ext/agent/codex_threads.py +114 -0
- jupyter_ext/agent/content_injection.py +377 -0
- jupyter_ext/agent/continuation_middleware.py +548 -0
- jupyter_ext/agent/custom_skills.py +335 -0
- jupyter_ext/agent/file_diffs.py +99 -0
- jupyter_ext/agent/git_history.py +188 -0
- jupyter_ext/agent/guardrail_middleware.py +421 -0
- jupyter_ext/agent/json_repair_utils.py +54 -0
- jupyter_ext/agent/langchain_tools.py +2673 -0
- jupyter_ext/agent/mermaid_fixer.py +289 -0
- jupyter_ext/agent/mermaid_middleware.py +135 -0
- jupyter_ext/agent/middleware.py +359 -0
- jupyter_ext/agent/middleware_prompts.py +53 -0
- jupyter_ext/agent/observability.py +334 -0
- jupyter_ext/agent/patch_tool_calls.py +57 -0
- jupyter_ext/agent/prompts.py +112 -0
- jupyter_ext/agent/skill_middleware.py +257 -0
- jupyter_ext/agent/skills/airflow_dag_development.md +36 -0
- jupyter_ext/agent/skills/anomaly_detection.md +12 -0
- jupyter_ext/agent/skills/athena_sql.md +156 -0
- jupyter_ext/agent/skills/bdp_table_search.md +33 -0
- jupyter_ext/agent/skills/bigquery.md +65 -0
- jupyter_ext/agent/skills/bigquery_oracle.md +231 -0
- jupyter_ext/agent/skills/bigquery_tuning.md +307 -0
- jupyter_ext/agent/skills/classification_evaluation.md +11 -0
- jupyter_ext/agent/skills/clustering_analysis.md +12 -0
- jupyter_ext/agent/skills/comprehensive_eda.md +11 -0
- jupyter_ext/agent/skills/data_analysis.md +236 -0
- jupyter_ext/agent/skills/data_cleaning_pipeline.md +12 -0
- jupyter_ext/agent/skills/data_loading.md +158 -0
- jupyter_ext/agent/skills/data_quality_report.md +13 -0
- jupyter_ext/agent/skills/dimensionality_reduction.md +12 -0
- jupyter_ext/agent/skills/emr_script_development.md +17 -0
- jupyter_ext/agent/skills/experiment_tracking.md +13 -0
- jupyter_ext/agent/skills/feature_importance_analysis.md +10 -0
- jupyter_ext/agent/skills/hyperparameter_tuning.md +12 -0
- jupyter_ext/agent/skills/hypothesis_testing.md +12 -0
- jupyter_ext/agent/skills/imbalanced_data_handling.md +12 -0
- jupyter_ext/agent/skills/inference.md +392 -0
- jupyter_ext/agent/skills/lambda_function_development.md +19 -0
- jupyter_ext/agent/skills/model_comparison.md +11 -0
- jupyter_ext/agent/skills/model_explainability.md +12 -0
- jupyter_ext/agent/skills/model_training.md +318 -0
- jupyter_ext/agent/skills/pyspark.md +352 -0
- jupyter_ext/agent/skills/python_code_quality.md +35 -0
- jupyter_ext/agent/skills/regression_evaluation.md +12 -0
- jupyter_ext/agent/skills/spring_java_development.md +35 -0
- jupyter_ext/agent/skills/text_preprocessing.md +12 -0
- jupyter_ext/agent/skills/time_series_analysis.md +13 -0
- jupyter_ext/agent/skills/unit_testing.md +203 -0
- jupyter_ext/agent/todo_prompts.py +57 -0
- jupyter_ext/agent/tool_report.py +45 -0
- jupyter_ext/analytics_ingest.py +599 -0
- jupyter_ext/etc/jupyter/jupyter_server_config.d/codebuff_agent.json +7 -0
- jupyter_ext/handlers/__init__.py +8 -0
- jupyter_ext/handlers/analytics_handler.py +170 -0
- jupyter_ext/handlers/benchmark_handler.py +794 -0
- jupyter_ext/handlers/eda_benchmark_handler.py +1328 -0
- jupyter_ext/handlers/rag_admin_handler.py +689 -0
- jupyter_ext/handlers/websocket.py +497 -0
- jupyter_ext/http_handlers.py +8744 -0
- jupyter_ext/idle_monitor.py +346 -0
- jupyter_ext/labextension/package.json +157 -0
- jupyter_ext/labextension/static/104.2b8f20f9d1ac2c9db01b.js +1 -0
- jupyter_ext/labextension/static/150.39fa98117cc8ca590465.js +1 -0
- jupyter_ext/labextension/static/166.386ff9b2c37ac865fdee.js +1 -0
- jupyter_ext/labextension/static/216.25cf81131bf7274dabf4.js +1 -0
- jupyter_ext/labextension/static/353.581bd1cb00746399b62e.js +1 -0
- jupyter_ext/labextension/static/367.575f9621b63c9a641aa9.js +1 -0
- jupyter_ext/labextension/static/421.11dac223a2c2da1b09f5.js +1 -0
- jupyter_ext/labextension/static/432.8513b4c6cc1d1232d165.js +2 -0
- jupyter_ext/labextension/static/432.8513b4c6cc1d1232d165.js.LICENSE.txt +19 -0
- jupyter_ext/labextension/static/439.ba5b5ef70ec6de214b8c.js +2 -0
- jupyter_ext/labextension/static/439.ba5b5ef70ec6de214b8c.js.LICENSE.txt +8 -0
- jupyter_ext/labextension/static/481.cc2dec9fa869d66f1407.js +1 -0
- jupyter_ext/labextension/static/487.0796e931d6e651482c14.js +1 -0
- jupyter_ext/labextension/static/49.d326f554b6f9ccde6580.js +1 -0
- jupyter_ext/labextension/static/541.26897ea32845659e36be.js +1 -0
- jupyter_ext/labextension/static/579.e569d3edd8391fd8fbb3.js +1 -0
- jupyter_ext/labextension/static/58.eb7cc679f7535cc8a2f1.js +2 -0
- jupyter_ext/labextension/static/58.eb7cc679f7535cc8a2f1.js.LICENSE.txt +8 -0
- jupyter_ext/labextension/static/666.d9bfdb23f98489d0a188.js +1 -0
- jupyter_ext/labextension/static/677.d266c39dbed33bc388b3.js +2 -0
- jupyter_ext/labextension/static/677.d266c39dbed33bc388b3.js.LICENSE.txt +8 -0
- jupyter_ext/labextension/static/68.26b6f59c8454adb17f20.js +204 -0
- jupyter_ext/labextension/static/694.4ac443814260057e68f7.js +1 -0
- jupyter_ext/labextension/static/791.61affb8d3480d3d60e0d.js +1 -0
- jupyter_ext/labextension/static/848.4d2db09cfbb09374b299.js +2 -0
- jupyter_ext/labextension/static/848.4d2db09cfbb09374b299.js.LICENSE.txt +9 -0
- jupyter_ext/labextension/static/868.5cfe7e1a348ec5af1b8c.js +1 -0
- jupyter_ext/labextension/static/97.ea559a5b8a9a09f17c6b.js +1 -0
- jupyter_ext/labextension/static/remoteEntry.5292fc9c6df7e7920cc8.js +1 -0
- jupyter_ext/labextension/static/style.js +4 -0
- jupyter_ext/labextension/static/third-party-licenses.json +724 -0
- jupyter_ext/log_paths.py +113 -0
- jupyter_ext/resource_usage.py +519 -0
- jupyter_ext/secrets_bootstrap.py +116 -0
- jupyter_ext/team_access.py +105 -0
- jupyter_ext/tests/__init__.py +1 -0
- jupyter_ext/tests/test_context.py +234 -0
- jupyter_ext/tests/test_factory.py +563 -0
- jupyter_ext/tests/test_file_finder.py +139 -0
- jupyter_ext/tests/test_handlers.py +58 -0
- jupyter_ext/tests/test_mcp_selftest.py +204 -0
- jupyter_ext/tests/test_mermaid_fixer.py +272 -0
- jupyter_ext/tests/test_resource_tiers.py +298 -0
- jupyter_ext/tools/__init__.py +15 -0
- jupyter_ext/tools/base.py +90 -0
- jupyter_ext/tools/context.py +268 -0
- jupyter_ext/tools/dir_complete.py +86 -0
- jupyter_ext/tools/file_finder.py +303 -0
- jupyter_ext/tools/file_tools.py +244 -0
- jupyter_ext/tools/jupyter_tools.py +296 -0
- jupyter_ext/tools/registry.py +159 -0
- jupyter_ext/tools/search_tools.py +230 -0
- jupyter_ext/tools/security_tools.py +657 -0
- jupyter_ext/tools/shell_tools.py +109 -0
- jupyter_ext/tools/user_tools.py +132 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Directory exclusions shared by workspace consumers.
|
|
2
|
+
|
|
3
|
+
Keep purpose-specific generated-output exclusions explicit: AST browsing may
|
|
4
|
+
inspect build output, while autocomplete should not suggest bundled JS files.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
COMMON_EXCLUDED_DIRS = frozenset(
|
|
8
|
+
{
|
|
9
|
+
"__pycache__",
|
|
10
|
+
".git",
|
|
11
|
+
"node_modules",
|
|
12
|
+
".venv",
|
|
13
|
+
"venv",
|
|
14
|
+
".tox",
|
|
15
|
+
".mypy_cache",
|
|
16
|
+
".codebuff-home", # 워크트리 서버의 Qdrant·세션 (scripts/jl_env.sh, 이슈 #116)
|
|
17
|
+
}
|
|
18
|
+
)
|
|
19
|
+
GENERATED_EXCLUDED_DIRS = COMMON_EXCLUDED_DIRS | {
|
|
20
|
+
".ipynb_checkpoints",
|
|
21
|
+
".pytest_cache",
|
|
22
|
+
".ruff_cache",
|
|
23
|
+
"dist",
|
|
24
|
+
"build",
|
|
25
|
+
"target", # Maven·Gradle(Kotlin)·Rust 빌드 산출물 (이슈 #100)
|
|
26
|
+
}
|
|
27
|
+
SEARCH_EXCLUDED_DIRS = GENERATED_EXCLUDED_DIRS | {".env", ".eggs"}
|
|
28
|
+
FILE_INDEX_EXCLUDED_DIRS = GENERATED_EXCLUDED_DIRS | {".eggs", "labextension", "lib"}
|
|
29
|
+
AST_EXCLUDED_DIRS = COMMON_EXCLUDED_DIRS
|
|
30
|
+
|
|
31
|
+
# Relative to the requested search root, so an explicit worktree scope still works.
|
|
32
|
+
EXCLUDED_RELATIVE_DIRS = frozenset({(".claude", "worktrees")})
|
codebuff_core/factory.py
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Codebuff Core - 서비스 팩토리
|
|
3
|
+
|
|
4
|
+
Embedded 서비스 구현을 생성하는 팩토리.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
from typing import Optional
|
|
9
|
+
|
|
10
|
+
from codebuff_core.interfaces import IAgentService, IChatService, IRAGService
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ServiceFactory:
|
|
16
|
+
"""
|
|
17
|
+
서비스 인스턴스를 생성하는 팩토리.
|
|
18
|
+
|
|
19
|
+
싱글톤 패턴으로 애플리케이션 전체에서 일관된 서비스 인스턴스를 보장함.
|
|
20
|
+
|
|
21
|
+
사용법:
|
|
22
|
+
factory = ServiceFactory.get_instance()
|
|
23
|
+
await factory.initialize()
|
|
24
|
+
|
|
25
|
+
agent_service = factory.get_agent_service()
|
|
26
|
+
chat_service = factory.get_chat_service()
|
|
27
|
+
rag_service = factory.get_rag_service()
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
_instance: Optional["ServiceFactory"] = None
|
|
31
|
+
|
|
32
|
+
def __init__(self):
|
|
33
|
+
"""팩토리 초기화 (get_instance() 사용 권장)"""
|
|
34
|
+
self._initialized = False
|
|
35
|
+
|
|
36
|
+
# 서비스 인스턴스 (지연 로딩)
|
|
37
|
+
self._agent_service: Optional[IAgentService] = None
|
|
38
|
+
self._chat_service: Optional[IChatService] = None
|
|
39
|
+
self._rag_service: Optional[IRAGService] = None
|
|
40
|
+
|
|
41
|
+
logger.info("ServiceFactory created")
|
|
42
|
+
|
|
43
|
+
@classmethod
|
|
44
|
+
def get_instance(cls) -> "ServiceFactory":
|
|
45
|
+
"""싱글톤 팩토리 인스턴스 반환"""
|
|
46
|
+
if cls._instance is None:
|
|
47
|
+
cls._instance = ServiceFactory()
|
|
48
|
+
return cls._instance
|
|
49
|
+
|
|
50
|
+
@classmethod
|
|
51
|
+
def reset_instance(cls) -> None:
|
|
52
|
+
"""싱글톤 인스턴스 초기화 (테스트용)"""
|
|
53
|
+
cls._instance = None
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def is_initialized(self) -> bool:
|
|
57
|
+
"""팩토리 초기화 여부 확인"""
|
|
58
|
+
return self._initialized
|
|
59
|
+
|
|
60
|
+
async def initialize(self) -> None:
|
|
61
|
+
"""
|
|
62
|
+
모든 서비스 초기화.
|
|
63
|
+
|
|
64
|
+
임베디드 서비스: RAG 매니저 초기화, 지식 베이스 로드
|
|
65
|
+
"""
|
|
66
|
+
if self._initialized:
|
|
67
|
+
logger.debug("ServiceFactory already initialized")
|
|
68
|
+
return
|
|
69
|
+
|
|
70
|
+
logger.info("Initializing ServiceFactory")
|
|
71
|
+
|
|
72
|
+
from codebuff_core.services.agent_service import EmbeddedAgentService
|
|
73
|
+
from codebuff_core.services.chat_service import EmbeddedChatService
|
|
74
|
+
from codebuff_core.services.rag_service import EmbeddedRAGService
|
|
75
|
+
|
|
76
|
+
# 서비스 인스턴스 생성
|
|
77
|
+
self._agent_service = EmbeddedAgentService()
|
|
78
|
+
self._chat_service = EmbeddedChatService()
|
|
79
|
+
self._rag_service = EmbeddedRAGService()
|
|
80
|
+
|
|
81
|
+
# RAG 서비스 초기화 (비동기 초기화 필요할 수 있음)
|
|
82
|
+
await self._rag_service.initialize()
|
|
83
|
+
|
|
84
|
+
self._initialized = True
|
|
85
|
+
logger.info("ServiceFactory initialization complete")
|
|
86
|
+
|
|
87
|
+
async def shutdown(self) -> None:
|
|
88
|
+
"""모든 서비스 종료 및 리소스 정리"""
|
|
89
|
+
logger.info("Shutting down ServiceFactory")
|
|
90
|
+
|
|
91
|
+
# RAG 서비스 정리
|
|
92
|
+
if self._rag_service and hasattr(self._rag_service, "shutdown"):
|
|
93
|
+
await self._rag_service.shutdown()
|
|
94
|
+
|
|
95
|
+
# 서비스 인스턴스 초기화
|
|
96
|
+
self._agent_service = None
|
|
97
|
+
self._chat_service = None
|
|
98
|
+
self._rag_service = None
|
|
99
|
+
self._initialized = False
|
|
100
|
+
|
|
101
|
+
logger.info("ServiceFactory shutdown complete")
|
|
102
|
+
|
|
103
|
+
def get_agent_service(self) -> IAgentService:
|
|
104
|
+
"""
|
|
105
|
+
Agent 서비스 인스턴스 반환.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
IAgentService 구현체
|
|
109
|
+
|
|
110
|
+
Raises:
|
|
111
|
+
RuntimeError: 팩토리가 초기화되지 않은 경우
|
|
112
|
+
"""
|
|
113
|
+
if not self._initialized:
|
|
114
|
+
raise RuntimeError(
|
|
115
|
+
"ServiceFactory not initialized. Call await factory.initialize() first."
|
|
116
|
+
)
|
|
117
|
+
return self._agent_service
|
|
118
|
+
|
|
119
|
+
def get_chat_service(self) -> IChatService:
|
|
120
|
+
"""
|
|
121
|
+
Chat 서비스 인스턴스 반환.
|
|
122
|
+
|
|
123
|
+
Returns:
|
|
124
|
+
IChatService 구현체
|
|
125
|
+
|
|
126
|
+
Raises:
|
|
127
|
+
RuntimeError: 팩토리가 초기화되지 않은 경우
|
|
128
|
+
"""
|
|
129
|
+
if not self._initialized:
|
|
130
|
+
raise RuntimeError(
|
|
131
|
+
"ServiceFactory not initialized. Call await factory.initialize() first."
|
|
132
|
+
)
|
|
133
|
+
return self._chat_service
|
|
134
|
+
|
|
135
|
+
def get_rag_service(self) -> IRAGService:
|
|
136
|
+
"""
|
|
137
|
+
RAG 서비스 인스턴스 반환.
|
|
138
|
+
|
|
139
|
+
Returns:
|
|
140
|
+
IRAGService 구현체
|
|
141
|
+
|
|
142
|
+
Raises:
|
|
143
|
+
RuntimeError: 팩토리가 초기화되지 않은 경우
|
|
144
|
+
"""
|
|
145
|
+
if not self._initialized:
|
|
146
|
+
raise RuntimeError(
|
|
147
|
+
"ServiceFactory not initialized. Call await factory.initialize() first."
|
|
148
|
+
)
|
|
149
|
+
return self._rag_service
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
# 싱글톤 팩토리 편의 함수
|
|
153
|
+
def get_service_factory() -> ServiceFactory:
|
|
154
|
+
"""싱글톤 ServiceFactory 인스턴스 반환"""
|
|
155
|
+
return ServiceFactory.get_instance()
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Codebuff Core - 서비스 인터페이스
|
|
3
|
+
|
|
4
|
+
에이전트 서비스의 계약을 정의하는 추상 인터페이스.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from abc import ABC, abstractmethod
|
|
8
|
+
from typing import Any, AsyncGenerator, Dict, List, Optional
|
|
9
|
+
|
|
10
|
+
from codebuff_core.models.agent import (
|
|
11
|
+
PlanRequest,
|
|
12
|
+
PlanResponse,
|
|
13
|
+
RefineRequest,
|
|
14
|
+
RefineResponse,
|
|
15
|
+
ReplanRequest,
|
|
16
|
+
ReplanResponse,
|
|
17
|
+
)
|
|
18
|
+
from codebuff_core.models.chat import ChatRequest, ChatResponse
|
|
19
|
+
from codebuff_core.models.rag import SearchRequest, SearchResponse
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class IAgentService(ABC):
|
|
23
|
+
"""
|
|
24
|
+
에이전트 서비스의 추상 인터페이스.
|
|
25
|
+
|
|
26
|
+
계획 생성, 코드 개선, 재계획 작업을 처리합니다.
|
|
27
|
+
EmbeddedAgentService로 구현됩니다.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
@abstractmethod
|
|
31
|
+
async def generate_plan(self, request: PlanRequest) -> PlanResponse:
|
|
32
|
+
"""
|
|
33
|
+
자연어 요청으로부터 실행 계획을 생성합니다.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
request: 사용자 요청과 노트북 컨텍스트가 포함된 계획 생성 요청
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
구조화된 실행 계획이 담긴 PlanResponse
|
|
40
|
+
"""
|
|
41
|
+
...
|
|
42
|
+
|
|
43
|
+
@abstractmethod
|
|
44
|
+
async def refine_code(self, request: RefineRequest) -> RefineResponse:
|
|
45
|
+
"""
|
|
46
|
+
실행 오류 발생 후 코드를 개선합니다.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
request: 실패한 단계와 오류 정보가 포함된 개선 요청
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
수정된 도구 호출이 담긴 RefineResponse
|
|
53
|
+
"""
|
|
54
|
+
...
|
|
55
|
+
|
|
56
|
+
@abstractmethod
|
|
57
|
+
async def replan(self, request: ReplanRequest) -> ReplanResponse:
|
|
58
|
+
"""
|
|
59
|
+
실패한 단계를 어떻게 처리할지 결정합니다.
|
|
60
|
+
|
|
61
|
+
오류 분류를 사용하여 복구 전략을 결정합니다.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
request: 오류 세부사항과 실행 컨텍스트가 포함된 재계획 요청
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
결정과 변경사항이 담긴 ReplanResponse
|
|
68
|
+
"""
|
|
69
|
+
...
|
|
70
|
+
|
|
71
|
+
@abstractmethod
|
|
72
|
+
async def validate_code(
|
|
73
|
+
self, code: str, notebook_context: Optional[Dict] = None
|
|
74
|
+
) -> Dict[str, Any]:
|
|
75
|
+
"""
|
|
76
|
+
실행 전 코드를 검증합니다.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
code: 검증할 Python 코드
|
|
80
|
+
notebook_context: 검증을 위한 선택적 노트북 컨텍스트
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
이슈와 의존성이 포함된 검증 결과
|
|
84
|
+
"""
|
|
85
|
+
...
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class IChatService(ABC):
|
|
89
|
+
"""
|
|
90
|
+
채팅 서비스의 추상 인터페이스.
|
|
91
|
+
|
|
92
|
+
LLM과의 대화형 상호작용을 처리합니다.
|
|
93
|
+
EmbeddedChatService로 구현됩니다.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
@abstractmethod
|
|
97
|
+
async def send_message(self, request: ChatRequest) -> ChatResponse:
|
|
98
|
+
"""
|
|
99
|
+
채팅 메시지를 보내고 응답을 받습니다.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
request: 메시지와 선택적 대화 ID가 포함된 채팅 요청
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
LLM 응답과 대화 ID가 담긴 ChatResponse
|
|
106
|
+
"""
|
|
107
|
+
...
|
|
108
|
+
|
|
109
|
+
@abstractmethod
|
|
110
|
+
async def send_message_stream(
|
|
111
|
+
self, request: ChatRequest
|
|
112
|
+
) -> AsyncGenerator[Dict[str, Any], None]:
|
|
113
|
+
"""
|
|
114
|
+
채팅 메시지를 보내고 스트리밍 응답을 받습니다.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
request: 메시지와 선택적 대화 ID가 포함된 채팅 요청
|
|
118
|
+
|
|
119
|
+
Yields:
|
|
120
|
+
부분 콘텐츠가 포함된 스트림 청크
|
|
121
|
+
"""
|
|
122
|
+
...
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class IRAGService(ABC):
|
|
126
|
+
"""
|
|
127
|
+
RAG 서비스의 추상 인터페이스.
|
|
128
|
+
|
|
129
|
+
검색 증강 생성 작업을 처리합니다.
|
|
130
|
+
EmbeddedRAGService로 구현됩니다.
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
@abstractmethod
|
|
134
|
+
async def search(self, request: SearchRequest) -> SearchResponse:
|
|
135
|
+
"""
|
|
136
|
+
지식 베이스를 검색합니다.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
request: 쿼리와 선택적 필터가 포함된 검색 요청
|
|
140
|
+
|
|
141
|
+
Returns:
|
|
142
|
+
일치하는 문서와 점수가 담긴 SearchResponse
|
|
143
|
+
"""
|
|
144
|
+
...
|
|
145
|
+
|
|
146
|
+
@abstractmethod
|
|
147
|
+
async def get_context_for_query(
|
|
148
|
+
self,
|
|
149
|
+
query: str,
|
|
150
|
+
detected_libraries: Optional[List[str]] = None,
|
|
151
|
+
max_results: int = 5,
|
|
152
|
+
) -> Optional[str]:
|
|
153
|
+
"""
|
|
154
|
+
쿼리에 대한 포맷된 컨텍스트를 가져옵니다 (프롬프트 주입용).
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
query: 사용자 쿼리
|
|
158
|
+
detected_libraries: 쿼리에서 감지된 라이브러리들
|
|
159
|
+
max_results: 포함할 최대 결과 수
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
포맷된 컨텍스트 문자열 또는 사용 불가시 None
|
|
163
|
+
"""
|
|
164
|
+
...
|
|
165
|
+
|
|
166
|
+
@abstractmethod
|
|
167
|
+
def is_ready(self) -> bool:
|
|
168
|
+
"""
|
|
169
|
+
RAG 서비스가 준비되었는지 확인합니다.
|
|
170
|
+
|
|
171
|
+
Returns:
|
|
172
|
+
서비스가 초기화되어 준비되면 True
|
|
173
|
+
"""
|
|
174
|
+
...
|
|
175
|
+
|
|
176
|
+
@abstractmethod
|
|
177
|
+
async def get_index_status(self) -> Dict[str, Any]:
|
|
178
|
+
"""
|
|
179
|
+
현재 인덱스 상태를 가져옵니다.
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
문서 수, 컬렉션 등이 포함된 인덱스 상태
|
|
183
|
+
"""
|
|
184
|
+
...
|
|
185
|
+
|
|
186
|
+
@abstractmethod
|
|
187
|
+
async def trigger_reindex(self, force: bool = False) -> Dict[str, Any]:
|
|
188
|
+
"""
|
|
189
|
+
재인덱싱 작업을 트리거합니다.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
force: True이면 필요하지 않아도 전체 재인덱싱 강제 실행
|
|
193
|
+
|
|
194
|
+
Returns:
|
|
195
|
+
재인덱싱 작업 상태
|
|
196
|
+
"""
|
|
197
|
+
...
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Codebuff Core - Knowledge Base
|
|
3
|
+
|
|
4
|
+
Deterministic library detection and API guide management.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .chunking import (
|
|
8
|
+
DocumentChunker,
|
|
9
|
+
chunk_file,
|
|
10
|
+
)
|
|
11
|
+
from .loader import (
|
|
12
|
+
LIBRARY_DESCRIPTIONS,
|
|
13
|
+
KnowledgeBase,
|
|
14
|
+
KnowledgeLoader,
|
|
15
|
+
LibraryDetector,
|
|
16
|
+
get_knowledge_base,
|
|
17
|
+
get_knowledge_loader,
|
|
18
|
+
get_library_detector,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"KnowledgeBase",
|
|
23
|
+
"KnowledgeLoader",
|
|
24
|
+
"LibraryDetector",
|
|
25
|
+
"get_knowledge_base",
|
|
26
|
+
"get_knowledge_loader",
|
|
27
|
+
"get_library_detector",
|
|
28
|
+
"LIBRARY_DESCRIPTIONS",
|
|
29
|
+
"DocumentChunker",
|
|
30
|
+
"chunk_file",
|
|
31
|
+
]
|