fixed the life cycle of the models (they couldn't unload anymore) and simplified the implementation of the Python models

This commit is contained in:
faraphel 2025-01-12 21:26:50 +01:00
parent f647c960dd
commit 8bf28e4c48
9 changed files with 96 additions and 111 deletions

View file

@ -44,7 +44,7 @@ class ChatInterface(base.BaseInterface):
# send back the messages, clear the user prompt, disable the system prompt
return assistant_message
def get_gradio_application(self):
def get_application(self):
# create a gradio interface
with gradio.Blocks(analytics_enabled=False) as application:
# header

View file

@ -7,7 +7,7 @@ import source
class BaseInterface(abc.ABC):
def __init__(self, model: "source.model.base.BaseModel"):
def __init__(self, model: "source._model.base.BaseModel"):
self.model = model
@property
@ -20,7 +20,7 @@ class BaseInterface(abc.ABC):
return f"{self.model.api_base}/interface"
@abc.abstractmethod
def get_gradio_application(self) -> gradio.Blocks:
def get_application(self) -> gradio.Blocks:
"""
Get a gradio application
:return: a gradio application
@ -35,6 +35,6 @@ class BaseInterface(abc.ABC):
gradio.mount_gradio_app(
application,
self.get_gradio_application(),
self.get_application(),
self.route
)