Files
DB-GPT/dbgpt/agent/resource/resource_loader.py
明天 d5afa6e206 Native data AI application framework based on AWEL+AGENT (#1152)
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>
2024-02-07 17:43:27 +08:00

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