forked from Aleph-Alpha/intelligence-layer-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
31 lines (23 loc) · 856 Bytes
/
run.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
"""Fastapi server to run predictions."""
from dotenv import load_dotenv
from fastapi import Depends, FastAPI
from intelligence_layer.core import ControlModel, LuminousControlModel, NoOpTracer
from intelligence_layer.examples.classify.classify import (
ClassifyInput,
SingleLabelClassifyOutput,
)
from intelligence_layer.examples.classify.prompt_based_classify import (
PromptBasedClassify,
)
app = FastAPI()
load_dotenv()
def model() -> ControlModel:
return LuminousControlModel("luminous-base-control")
@app.post("/classify")
async def classify(
classify_input: ClassifyInput,
luminous_control_model: LuminousControlModel = Depends(model),
) -> SingleLabelClassifyOutput:
classify = PromptBasedClassify(luminous_control_model)
classify_output = classify.run(classify_input, NoOpTracer())
return classify_output