mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-10-22 09:28:42 +00:00
Co-authored-by: 夏姜 <wenfengjiang.jwf@digital-engine.com> Co-authored-by: aries_ckt <916701291@qq.com> Co-authored-by: wb-lh513319 <wb-lh513319@alibaba-inc.com> Co-authored-by: csunny <cfqsunny@163.com>
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
"""Client for vis protocol."""
|
||
from typing import Dict, Type
|
||
|
||
from .base import Vis
|
||
from .tags.vis_agent_message import VisAgentMessages
|
||
from .tags.vis_agent_plans import VisAgentPlans
|
||
from .tags.vis_api_response import VisApiResponse
|
||
from .tags.vis_app_link import VisAppLink
|
||
from .tags.vis_chart import VisChart
|
||
from .tags.vis_code import VisCode
|
||
from .tags.vis_dashboard import VisDashboard
|
||
from .tags.vis_plugin import VisPlugin
|
||
|
||
|
||
class VisClient:
|
||
"""Client for vis protocol."""
|
||
|
||
def __init__(self):
|
||
"""Client for vis protocol."""
|
||
self._vis_tag: Dict[str, Vis] = {}
|
||
|
||
def register(self, vis_cls: Type[Vis]):
|
||
"""Register the vis protocol."""
|
||
self._vis_tag[vis_cls.vis_tag()] = vis_cls()
|
||
|
||
def get(self, tag_name):
|
||
"""Get the vis protocol by tag name."""
|
||
if tag_name not in self._vis_tag:
|
||
raise ValueError(f"Vis protocol tags not yet supported![{tag_name}]")
|
||
return self._vis_tag[tag_name]
|
||
|
||
def tag_names(self):
|
||
"""Return the tag names of the vis protocol."""
|
||
self._vis_tag.keys()
|
||
|
||
|
||
vis_client = VisClient()
|
||
|
||
vis_client.register(VisCode)
|
||
vis_client.register(VisChart)
|
||
vis_client.register(VisDashboard)
|
||
vis_client.register(VisAgentPlans)
|
||
vis_client.register(VisAgentMessages)
|
||
vis_client.register(VisPlugin)
|
||
vis_client.register(VisAppLink)
|
||
vis_client.register(VisApiResponse)
|