Skip to content

Commit

Permalink
resolve db type for dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilber committed Sep 28, 2023
1 parent 27c19d3 commit 967e10d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pykoi/component/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from pykoi.component.chatbot_database_factory import ChatbotDatabaseFactory
from pykoi.component.constants import FeedbackType
from pykoi.chat.db.comparator_database import ComparatorDatabase
from pykoi.chat.db.qa_database import QuestionAnswerDatabase
from pykoi.chat.db.rag_database import RAGDatabase
from pykoi.chat.db.ranking_database import RankingDatabase
Expand Down Expand Up @@ -42,9 +43,7 @@ class Component:
props (Dict[str, Any]): Additional properties for the component.
"""

def __init__(
self, fetch_func: Optional[Callable], svelte_component: str, **kwargs
):
def __init__(self, fetch_func: Optional[Callable], svelte_component: str, **kwargs):
"""
Initialize a new instance of Component.
Expand All @@ -54,9 +53,7 @@ def __init__(
kwargs: Additional properties for the component.
"""
self.id = str(uuid.uuid4()) # Generate a unique ID
self.data_source = (
DataSource(self.id, fetch_func) if fetch_func else None
)
self.data_source = DataSource(self.id, fetch_func) if fetch_func else None
self.svelte_component = svelte_component
self.props = kwargs

Expand All @@ -81,6 +78,7 @@ def __init__(self, fetch_func: Callable, value_column: List[str], **kwargs):
super().__init__(fetch_func, "Dropdown", **kwargs)
self.value_column = value_column


class RAG(Component):
"""
RAG class represents a RAG component.
Expand Down Expand Up @@ -138,5 +136,8 @@ def __init__(self, database: any, **kwargs):
database (QuestionAnswerDatabase): The database to use for the dashboard.
kwargs: Additional properties for the dashboard.
"""
super().__init__(None, "Feedback", **kwargs)
if isinstance(database, ComparatorDatabase):
super().__init__(None, "CompareDashboard", **kwargs)
else:
super().__init__(None, "Feedback", **kwargs)
self.database = database

0 comments on commit 967e10d

Please sign in to comment.