-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpserver.py
More file actions
56 lines (48 loc) · 2.09 KB
/
Copy pathhttpserver.py
File metadata and controls
56 lines (48 loc) · 2.09 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from recruitment import recruitment,recruitFromOCR
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from pydantic import BaseModel,Field
from typing import List
from htmlResources.WLBatterySimulator.router import router as WLBatteryRouter
description = """
現在開放中の機能は以下の通り:
- 公開求人検索(recruitment)
"""
app = FastAPI(
title="F鯖アステシアちゃんbot 外部API",
description=description,
summary="F鯖アステシアちゃんbotの外部用API。",
version="0.0.1",
contact={
"name": "ふぉめ holmesfems",
"url": "https://youtube.com/@holmesfems",
"email": "holmesfems@gmail.com"
},
license_info={
"name": "MIT License",
"url": "https://opensource.org/license/mit",
},
)
app.include_router(WLBatteryRouter)
app.mount(
"/WLBatterySimulator/static",
StaticFiles(directory="htmlResources/WLBatterySimulator/static"),
name="WLBatterySimulator_static",
)
class OCRRawData(BaseModel):
text: str = Field(description="The raw data of OCR result. Each tag should be separated by line breaks")
pickupOperators: List[str]|None = Field(default=None,description="Specify some operators to always show in the recruitment result")
class TagReplyData(BaseModel):
title: str = Field(description="The recognized tags")
reply: str = Field(description="The result to be displayed on screen")
@app.post('/recruitment/',response_model=TagReplyData,description="Extract tags of arknights public recruitment from raw OCR data, and calculate high-rare tag combination")
def doRecruitment(data:OCRRawData):
text= data.text
matchTag = recruitFromOCR.matchTag(text)
if(matchTag.isEmpty()): return TagReplyData(title="エラー",reply="タグがありません")
matches = matchTag.matches
if(len(matches) > 8):
matches = list(matches)[:8]
reply = recruitment.recruitDoProcess(matches,4,matchTag.isGlobal,showTagLoss=True,pickupOperators=data.pickupOperators)
return TagReplyData(title=reply.embbedTitle,reply=reply.responseForAI)
print("Server started")