mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-10-23 01:49:58 +00:00
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com> Co-authored-by: lcx01800250 <lcx01800250@alibaba-inc.com> Co-authored-by: licunxing <864255598@qq.com> Co-authored-by: Aralhi <xiaoping0501@gmail.com> Co-authored-by: xuyuan23 <643854343@qq.com> Co-authored-by: aries_ckt <916701291@qq.com> Co-authored-by: hzh97 <2976151305@qq.com>
26 lines
812 B
Python
26 lines
812 B
Python
from collections import defaultdict
|
|
from typing import Any, Dict, List, Optional, Tuple, Union
|
|
|
|
from .resource_api import ResourceClient, ResourceType
|
|
|
|
|
|
class ResourceLoader:
|
|
def __init__(self):
|
|
self._resource_api_instance = defaultdict(ResourceClient)
|
|
|
|
def get_resesource_api(
|
|
self, resource_type: ResourceType
|
|
) -> Optional[ResourceClient]:
|
|
if not resource_type:
|
|
return None
|
|
|
|
if resource_type not in self._resource_api_instance:
|
|
raise ValueError(
|
|
f"No loader available for resource of type {resource_type.value}"
|
|
)
|
|
|
|
return self._resource_api_instance[resource_type]
|
|
|
|
def register_resesource_api(self, api_instance: ResourceClient):
|
|
self._resource_api_instance[api_instance.type] = api_instance
|