-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
123 additions
and
204 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from fastapi import APIRouter, Depends | ||
|
||
from app.handler.dto.eval_dto import EvalV1 | ||
from app.handler.dto.judge_dto import JudgeV1 | ||
from app.handler.dto.reading_dto import ReadingV1 | ||
from app.service.dajare_service import DajareService | ||
|
||
dajare_service = DajareService() | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get('/eval/', status_code=200, response_model=EvalV1.Response, include_in_schema=False) | ||
@router.get('/eval', status_code=200, response_model=EvalV1.Response) | ||
async def eval_v1(request: EvalV1.Request = Depends()): | ||
dajare = dajare_service.eval_dajare(request.dajare) | ||
return EvalV1.Response( | ||
score=dajare.score, | ||
) | ||
|
||
|
||
@router.get('/judge/', status_code=200, response_model=JudgeV1.Response, include_in_schema=False) | ||
@router.get('/judge', status_code=200, response_model=JudgeV1.Response) | ||
async def judge_v1(request: JudgeV1.Request = Depends()): | ||
dajare = dajare_service.judge_dajare(request.dajare) | ||
return JudgeV1.Response( | ||
is_dajare=dajare.is_dajare, | ||
applied_rule=dajare.applied_rule, | ||
) | ||
|
||
|
||
@router.get('/reading/', status_code=200, response_model=ReadingV1.Response, include_in_schema=False) | ||
@router.get('/reading', status_code=200, response_model=ReadingV1.Response) | ||
async def reading_v1(request: ReadingV1.Request = Depends()): | ||
dajare = dajare_service.convert_reading(request.dajare) | ||
return ReadingV1.Response( | ||
reading=dajare.reading, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from fastapi import FastAPI | ||
from fastapi.middleware.cors import CORSMiddleware | ||
|
||
from app.handler.controller import dajare_controller | ||
|
||
|
||
def fastapi_app() -> FastAPI: | ||
app = FastAPI() | ||
|
||
app.add_middleware( | ||
CORSMiddleware, | ||
allow_origins=['*'], | ||
allow_credentials=True, | ||
allow_methods=['*'], | ||
allow_headers=['*'], | ||
) | ||
|
||
app.include_router(dajare_controller.router, prefix='/v1', tags=['dajare']) | ||
app.include_router(dajare_controller.router, prefix='', tags=['dajare']) | ||
|
||
@app.get('/') | ||
def index(): | ||
return "health" | ||
|
||
app.title = 'DaaS API' | ||
app.openapi_tags = [ | ||
{"name": "dajare", "description": "Operation with dajare _(ダジャレ)_ ."} | ||
] | ||
|
||
return app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class EvalV1: | ||
class Request(BaseModel): | ||
dajare: str | ||
|
||
class Response(BaseModel): | ||
score: float |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class JudgeV1: | ||
class Request(BaseModel): | ||
dajare: str | ||
|
||
class Response(BaseModel): | ||
is_dajare: bool | ||
applied_rule: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class ReadingV1: | ||
class Request(BaseModel): | ||
dajare: str | ||
|
||
class Response(BaseModel): | ||
reading: str |
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions
10
core/service/dajare_service.py → app/service/dajare_service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
core/service/engine/eval_engine.py → app/service/engine/eval_engine.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/service/engine/reading_engine.py → app/service/engine/reading_engine.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from core.util import text_util | ||
from app.util import text_util | ||
|
||
|
||
class ReadingEngine: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.