Skip to content

Commit

Permalink
Remove ApiWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
smokestacklightnin committed Dec 26, 2024
1 parent 59d0104 commit f95790d
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 85 deletions.
62 changes: 0 additions & 62 deletions ragna/deploy/_ui/api_wrapper.py

This file was deleted.

7 changes: 1 addition & 6 deletions ragna/deploy/_ui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from . import js
from . import styles as ui
from .api_wrapper import ApiWrapper
from .main_page import MainPage

pn.extension(
Expand Down Expand Up @@ -68,12 +67,8 @@ def get_template(self):
return template

def index_page(self):
api_wrapper = ApiWrapper(self._engine)

template = self.get_template()
main_page = MainPage(
api_wrapper=api_wrapper, engine=self._engine, template=template
)
main_page = MainPage(engine=self._engine, template=template)
template.main.append(main_page)
return template

Expand Down
3 changes: 1 addition & 2 deletions ragna/deploy/_ui/central_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,11 @@ def _build_message(self, *args, **kwargs) -> Optional[RagnaChatMessage]:
class CentralView(pn.viewable.Viewer):
current_chat = param.ClassSelector(class_=dict, default=None)

def __init__(self, api_wrapper, engine, **params):
def __init__(self, engine, **params):
super().__init__(**params)

# FIXME: make this dynamic from the login
self.user = ""
self.api_wrapper = api_wrapper
self._engine = engine
self.chat_info_button = pn.widgets.Button(
# The name will be filled at runtime in self.header
Expand Down
3 changes: 1 addition & 2 deletions ragna/deploy/_ui/left_sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ class LeftSidebar(pn.viewable.Viewer):
current_chat_id = param.String(default=None)
refresh_counter = param.Integer(default=0)

def __init__(self, api_wrapper, engine, **params):
def __init__(self, engine, **params):
super().__init__(**params)

self.api_wrapper = api_wrapper
self._engine = engine
self.on_click_chat = None
self.on_click_new_chat = None
Expand Down
12 changes: 3 additions & 9 deletions ragna/deploy/_ui/main_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ class MainPage(pn.viewable.Viewer, param.Parameterized):
current_chat_id = param.String(default=None)
chats = param.List(default=None)

def __init__(self, api_wrapper, engine, template):
def __init__(self, engine, template):
super().__init__()
self.api_wrapper = api_wrapper
self._engine = engine
self.template = template

Expand All @@ -24,16 +23,12 @@ def __init__(self, api_wrapper, engine, template):
self.corpus_names = None

self.modal = None
self.central_view = CentralView(
api_wrapper=self.api_wrapper, engine=self._engine
)
self.central_view = CentralView(engine=self._engine)
self.central_view.on_click_chat_info = (
lambda event, title, content: self.show_right_sidebar(title, content)
)

self.left_sidebar = LeftSidebar(
api_wrapper=self.api_wrapper, engine=self._engine
)
self.left_sidebar = LeftSidebar(engine=self._engine)
self.left_sidebar.on_click_chat = self.on_click_chat
self.left_sidebar.on_click_new_chat = self.open_modal

Expand Down Expand Up @@ -78,7 +73,6 @@ async def open_modal(self, event):
await self.refresh_data()

self.modal = ModalConfiguration(
api_wrapper=self.api_wrapper,
engine=self._engine,
components=self.components,
corpus_metadata=self.corpus_metadata,
Expand Down
5 changes: 1 addition & 4 deletions ragna/deploy/_ui/modal_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,9 @@ class ModalConfiguration(pn.viewable.Viewer):

error = param.Boolean(default=False)

def __init__(
self, api_wrapper, engine, components, corpus_names, corpus_metadata, **params
):
def __init__(self, engine, components, corpus_names, corpus_metadata, **params):
super().__init__(chat_name=get_default_chat_name(), **params)

self.api_wrapper = api_wrapper
self._engine = engine

self.corpus_names = corpus_names
Expand Down

0 comments on commit f95790d

Please sign in to comment.