-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patht_install.py
56 lines (47 loc) · 1.17 KB
/
t_install.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
46
47
48
49
50
51
52
53
54
55
56
import os
from fastapi import FastAPI
from langserve import add_routes
from medprompt.chains import get_runnable
from medprompt.tools import FhirPatientSearchTool, ConvertFhirToTextTool
from medprompt.agents import FhirAgent
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI(
title="Healthcare Tools, Chains and Agents Server",
version="1.0",
description="A simple api server using Langchain's Runnable interfaces and LangServe",
)
# Set all CORS enabled origins
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
expose_headers=["*"],
)
add_routes(
app,
FhirPatientSearchTool(),
path="/search",
)
add_routes(
app,
ConvertFhirToTextTool(),
path="/flatten",
)
add_routes(
app,
FhirAgent.get_agent(),
path="/agent",
)
add_routes(
app,
get_runnable(),
path="/chain",
)
if __name__ == "__main__":
import uvicorn
os.environ["LANGCHAIN_DEBUG"] = "1"
os.environ["LANGCHAIN_LOG_LEVEL"] = "DEBUG"
os.environ["TOKENIZERS_PARALLELISM"] = "false"
uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", 8080)))