mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-14 00:53:25 +00:00
fix: singleton
This commit is contained in:
@ -7,7 +7,9 @@ from fastapi.responses import JSONResponse
|
||||
from ..asr.rapid_paraformer.utils import read_yaml
|
||||
from ..asr.rapid_paraformer import RapidParaformer
|
||||
from .blackbox import Blackbox
|
||||
from injector import singleton
|
||||
|
||||
@singleton
|
||||
class ASR(Blackbox):
|
||||
|
||||
def __init__(self, path = ".env.yaml") -> None:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
from fastapi import Request, Response,status
|
||||
from fastapi.responses import JSONResponse
|
||||
from injector import inject
|
||||
from injector import inject, singleton
|
||||
|
||||
from .asr import ASR
|
||||
from .tesou import Tesou
|
||||
@ -8,6 +8,7 @@ from .tts import TTS
|
||||
|
||||
from .blackbox import Blackbox
|
||||
|
||||
@singleton
|
||||
class AudioChat(Blackbox):
|
||||
|
||||
@inject
|
||||
|
||||
@ -3,9 +3,10 @@ from fastapi.responses import JSONResponse
|
||||
import speech_recognition as sr
|
||||
import filetype
|
||||
import io
|
||||
|
||||
from injector import singleton
|
||||
from .blackbox import Blackbox
|
||||
|
||||
@singleton
|
||||
class AudioToText(Blackbox):
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
|
||||
@ -9,8 +9,9 @@ from .tesou import Tesou
|
||||
from .fastchat import Fastchat
|
||||
from .g2e import G2E
|
||||
from .text_and_image import TextAndImage
|
||||
from injector import inject
|
||||
from injector import inject, singleton
|
||||
|
||||
@singleton
|
||||
class BlackboxFactory:
|
||||
models = {}
|
||||
|
||||
@ -40,7 +41,7 @@ class BlackboxFactory:
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self.processing(*args, **kwargs)
|
||||
|
||||
def create_blackbox(self, blackbox_name: str) -> Blackbox:
|
||||
def call_blackbox(self, blackbox_name: str) -> Blackbox:
|
||||
model = self.models.get(blackbox_name)
|
||||
if model is None:
|
||||
raise ValueError("Invalid blockbox type")
|
||||
|
||||
@ -6,8 +6,10 @@ from fastapi.responses import JSONResponse
|
||||
from .blackbox import Blackbox
|
||||
from lagent.llms.lmdepoly_wrapper import LMDeployClient
|
||||
from lagent.llms.meta_template import INTERNLM2_META as META
|
||||
from injector import singleton
|
||||
|
||||
class Sentiment(Blackbox):
|
||||
@singleton
|
||||
class Emotion(Blackbox):
|
||||
|
||||
def __init__(self, model_name, model_url) -> None:
|
||||
self.model = LMDeployClient(
|
||||
@ -7,6 +7,8 @@ from .blackbox import Blackbox
|
||||
import requests
|
||||
import json
|
||||
|
||||
from injector import singleton
|
||||
@singleton
|
||||
class Fastchat(Blackbox):
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
|
||||
@ -7,7 +7,8 @@ from .blackbox import Blackbox
|
||||
import requests
|
||||
import json
|
||||
from openai import OpenAI
|
||||
|
||||
from injector import singleton
|
||||
@singleton
|
||||
class G2E(Blackbox):
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
|
||||
@ -6,7 +6,8 @@ from fastapi.responses import JSONResponse
|
||||
from ..sentiment_engine.sentiment_engine import SentimentEngine
|
||||
from .blackbox import Blackbox
|
||||
|
||||
|
||||
from injector import singleton
|
||||
@singleton
|
||||
class Sentiment(Blackbox):
|
||||
|
||||
def __init__(self) -> None:
|
||||
|
||||
@ -7,7 +7,9 @@ from ..configuration import TesouConf
|
||||
from .blackbox import Blackbox
|
||||
|
||||
import requests
|
||||
from injector import singleton
|
||||
|
||||
@singleton
|
||||
class Tesou(Blackbox):
|
||||
url: str
|
||||
|
||||
|
||||
@ -4,7 +4,8 @@ from fastapi import Request, Response, status
|
||||
from fastapi.responses import JSONResponse
|
||||
from .blackbox import Blackbox
|
||||
|
||||
|
||||
from injector import singleton
|
||||
@singleton
|
||||
class TextAndImage(Blackbox):
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
|
||||
@ -3,7 +3,8 @@ from fastapi.responses import JSONResponse
|
||||
from .blackbox import Blackbox
|
||||
from gtts import gTTS
|
||||
from io import BytesIO
|
||||
|
||||
from injector import singleton
|
||||
@singleton
|
||||
class TextToAudio(Blackbox):
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
|
||||
@ -6,7 +6,9 @@ from fastapi import Request, Response, status
|
||||
from fastapi.responses import JSONResponse
|
||||
from .blackbox import Blackbox
|
||||
from ..tts.tts_service import TTService
|
||||
from injector import singleton
|
||||
|
||||
@singleton
|
||||
class TTS(Blackbox):
|
||||
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
|
||||
Reference in New Issue
Block a user