fix add inference client
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import os
|
|
4 |
import logging
|
5 |
from utils.meldrx import MeldRxAPI
|
6 |
from utils.oneclick import generate_discharge_paper_one_click
|
|
|
7 |
|
8 |
logging.basicConfig(level=logging.INFO)
|
9 |
logger = logging.getLogger(__name__)
|
@@ -23,6 +24,13 @@ meldrx_api = MeldRxAPI(
|
|
23 |
redirect_uri=REDIRECT_URI
|
24 |
)
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
@app.route('/')
|
27 |
def index():
|
28 |
return render_template('index.html')
|
@@ -67,7 +75,7 @@ def one_click():
|
|
67 |
logger.info(f"One-click request - ID: {patient_id}, First: {first_name}, Last: {last_name}, Action: {action}")
|
68 |
|
69 |
pdf_path, status, basic_summary, ai_summary = generate_discharge_paper_one_click(
|
70 |
-
meldrx_api,
|
71 |
)
|
72 |
|
73 |
if action == "Display Summary":
|
|
|
4 |
import logging
|
5 |
from utils.meldrx import MeldRxAPI
|
6 |
from utils.oneclick import generate_discharge_paper_one_click
|
7 |
+
from huggingface_hub import InferenceClient
|
8 |
|
9 |
logging.basicConfig(level=logging.INFO)
|
10 |
logger = logging.getLogger(__name__)
|
|
|
24 |
redirect_uri=REDIRECT_URI
|
25 |
)
|
26 |
|
27 |
+
|
28 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
29 |
+
if not HF_TOKEN:
|
30 |
+
raise ValueError("HF_TOKEN environment variable not set.")
|
31 |
+
client = InferenceClient(api_key=HF_TOKEN)
|
32 |
+
MODEL_NAME = "meta-llama/Llama-3.3-70B-Instruct"
|
33 |
+
|
34 |
@app.route('/')
|
35 |
def index():
|
36 |
return render_template('index.html')
|
|
|
75 |
logger.info(f"One-click request - ID: {patient_id}, First: {first_name}, Last: {last_name}, Action: {action}")
|
76 |
|
77 |
pdf_path, status, basic_summary, ai_summary = generate_discharge_paper_one_click(
|
78 |
+
meldrx_api, client, patient_id, first_name, last_name
|
79 |
)
|
80 |
|
81 |
if action == "Display Summary":
|