forked from animal-squad/project-s-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (28 loc) · 1.1 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from fastapi import FastAPI
from config.log import get_logger
from entity.request_dto import ExtractRequest
from entity.response_dto import ExtractResponse
from model.gpt_model import GPTModel
from service.metadata_extractor import MetadataExtractor
from service.content_extractor import ContentExtractor
from service.content_reader import ContentReader
from service.crawlability_checker import CrawlabilityChecker
app = FastAPI()
gpt_model = GPTModel(get_logger("GPTLogger"))
crawlability_checker = CrawlabilityChecker()
content_extractor = ContentExtractor()
content_reader = ContentReader(crawlability_checker, content_extractor, get_logger("CrawlabilityLogger"))
extractor_logger = get_logger("ExtractorLogger")
metadata_extractor = MetadataExtractor(gpt_model, content_reader, extractor_logger)
@app.get("/ai")
async def health_check():
return "Good"
@app.post("/ai/extract")
async def classify_main(req: ExtractRequest):
"""
메타 데이터 추출 엔드포인트
"""
data = {
"links": metadata_extractor.extract_metadata_batch(req.links),
}
return ExtractResponse(**data)