added support for additional more user-friendly interfaces, improved some part of the application loading process to make it a bit simpler

This commit is contained in:
faraphel 2025-01-12 12:52:19 +01:00
parent 1a49aa3779
commit f647c960dd
20 changed files with 353 additions and 107 deletions

View file

@ -0,0 +1,40 @@
import abc
import fastapi
import gradio
import source
class BaseInterface(abc.ABC):
def __init__(self, model: "source.model.base.BaseModel"):
self.model = model
@property
def route(self) -> str:
"""
The route to the interface
:return: the route to the interface
"""
return f"{self.model.api_base}/interface"
@abc.abstractmethod
def get_gradio_application(self) -> gradio.Blocks:
"""
Get a gradio application
:return: a gradio application
"""
def mount(self, application: fastapi.FastAPI) -> None:
"""
Mount the interface on an application
:param application: the application to mount the interface on
:param path: the path where to mount the application
"""
gradio.mount_gradio_app(
application,
self.get_gradio_application(),
self.route
)

View file

@ -0,0 +1 @@
from .BaseInterface import BaseInterface