-
Notifications
You must be signed in to change notification settings - Fork 236
/
app.py
45 lines (34 loc) · 1.24 KB
/
app.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
37
38
39
40
41
42
43
44
45
import logging
import pathway as pw
from dotenv import load_dotenv
from pathway.xpacks.llm.question_answering import SummaryQuestionAnswerer
from pathway.xpacks.llm.servers import QASummaryRestServer
from pydantic import BaseModel, ConfigDict, InstanceOf
# To use advanced features with Pathway Scale, get your free license key from
# https://pathway.com/features and paste it below.
# To use Pathway Community, comment out the line below.
pw.set_license_key("demo-license-key-with-telemetry")
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(name)s %(levelname)s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
load_dotenv()
class App(BaseModel):
question_answerer: InstanceOf[SummaryQuestionAnswerer]
host: str = "0.0.0.0"
port: int = 8000
with_cache: bool = True
terminate_on_error: bool = False
def run(self) -> None:
server = QASummaryRestServer(self.host, self.port, self.question_answerer)
server.run(
with_cache=self.with_cache,
terminate_on_error=self.terminate_on_error,
)
model_config = ConfigDict(extra="forbid")
if __name__ == "__main__":
with open("app.yaml") as f:
config = pw.load_yaml(f)
app = App(**config)
app.run()