老师,service_dependencies.py文件中下面这个方法中使用到了FileAppConfigRepository这个类,我的疑问是service_dependencies.py文件在接口层,而FileAppConfigRepository在基础设施层,在DDD中接口层能访问基础设置层吗?在视频5-7中好像没有说明。
def get_app_config_service() -> AppConfigService:
"""获取应用配置服务"""
# 1.获取数据仓库并打印日志
logger.info("加载获取AppConfigService")
file_app_config_repository = FileAppConfigRepository(settings.app_config_filepath)
# 2.实例化AppConfigService
return AppConfigService(app_config_repository=file_app_config_repository)
第二个疑问,app_config_routes.py文件中使用了LLMConfig类,app_config_routes.py在接口层,LLMConfig类在领域层,在DDD中接口层能访问领域层吗?在视频5-7中好像没有说明。
@router.get(
path="/llm",
response_model=Response[LLMConfig],
summary="获取LLM配置信息",
description="包含LLM提供商的base_url、temperature、model_name、max_tokens"
)
async def get_llm_config(
app_config_service: AppConfigService = Depends(get_app_config_service)
) -> Response[LLMConfig]:
"""获取LLM配置信息"""
llm_config = await app_config_service.get_llm_config()
return Response.success(data=llm_config.model_dump(exclude={"api_key"}))