mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
feat: sum
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
from .sum import SUM
|
||||
from .sentiment import Sentiment
|
||||
from .tts import TTS
|
||||
from ..asr.asr import ASR
|
||||
@ -27,4 +28,6 @@ class BlackboxFactory:
|
||||
return self.tts
|
||||
if blackbox_name == "sentiment_engine":
|
||||
return self.sentiment
|
||||
if blackbox_name == "sum":
|
||||
return SUM()
|
||||
raise ValueError("Invalid blockbox type")
|
||||
23
src/blackbox/sum.py
Normal file
23
src/blackbox/sum.py
Normal file
@ -0,0 +1,23 @@
|
||||
from typing import Any, Coroutine
|
||||
|
||||
from fastapi import Request, Response, status
|
||||
from fastapi.responses import JSONResponse
|
||||
from .blackbox import Blackbox
|
||||
|
||||
|
||||
class SUM(Blackbox):
|
||||
|
||||
def valid(self, data: any) -> bool:
|
||||
return isinstance(data, list)
|
||||
|
||||
def processing(self, data: list) -> Coroutine[Any, Any, Any]:
|
||||
return sum(data)
|
||||
|
||||
async def fast_api_handler(self, request: Request) -> Response:
|
||||
try:
|
||||
data = await request.json()
|
||||
except:
|
||||
return JSONResponse(content={"error": "json parse error"}, status_code=status.HTTP_400_BAD_REQUEST)
|
||||
if not self.valid(data):
|
||||
return JSONResponse(content={"error": "format error"}, status_code=status.HTTP_400_BAD_REQUEST)
|
||||
return JSONResponse(content={"result": self.processing(data)}, status_code=status.HTTP_200_OK)
|
||||
@ -5,6 +5,7 @@ from fastapi import Request, Response, status
|
||||
from fastapi.responses import JSONResponse
|
||||
from .blackbox import Blackbox
|
||||
from tts.tts_service import TTService
|
||||
import time
|
||||
|
||||
class TTS(Blackbox):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user