get authorization code fix
Browse files- app.py +22 -22
- utils/generators.py +5 -3
app.py
CHANGED
|
@@ -70,28 +70,28 @@ CALLBACK_MANAGER = CallbackManager(
|
|
| 70 |
)
|
| 71 |
|
| 72 |
|
| 73 |
-
class CallbackManager:
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
|
| 96 |
def generate_discharge_paper_one_click():
|
| 97 |
"""One-click function to fetch patient data and generate discharge paper with AI Content."""
|
|
|
|
| 70 |
)
|
| 71 |
|
| 72 |
|
| 73 |
+
# class CallbackManager:
|
| 74 |
+
# def __init__(self, redirect_uri: str, client_secret: str = None):
|
| 75 |
+
# client_id = os.getenv("APPID")
|
| 76 |
+
# if not client_id:
|
| 77 |
+
# raise ValueError("APPID environment variable not set.")
|
| 78 |
+
# workspace_id = os.getenv("WORKSPACE_URL")
|
| 79 |
+
# if not workspace_id:
|
| 80 |
+
# raise ValueError("WORKSPACE_URL environment variable not set.")
|
| 81 |
+
# self.api = MeldRxAPI(client_id, client_secret, workspace_id, redirect_uri)
|
| 82 |
+
# self.auth_code = None
|
| 83 |
+
# self.access_token = None
|
| 84 |
+
|
| 85 |
+
# def handle_callback(self, callback_url: str) -> str:
|
| 86 |
+
# """Handles the callback URL and extracts the code automatically."""
|
| 87 |
+
# self.auth_code = extract_code_from_url(callback_url)
|
| 88 |
+
# if not self.auth_code:
|
| 89 |
+
# return "No authentication code found in URL."
|
| 90 |
+
|
| 91 |
+
# if self.api.authenticate_with_code(self.auth_code):
|
| 92 |
+
# self.access_token = self.api.access_token
|
| 93 |
+
# return f"Authentication successful! Access Token: {self.access_token[:10]}... (truncated)"
|
| 94 |
+
# return "Authentication failed. Please check the authorization code."
|
| 95 |
|
| 96 |
def generate_discharge_paper_one_click():
|
| 97 |
"""One-click function to fetch patient data and generate discharge paper with AI Content."""
|
utils/generators.py
CHANGED
|
@@ -10,9 +10,7 @@ from huggingface_hub import InferenceClient # Import InferenceClient
|
|
| 10 |
from urllib.parse import urlparse, parse_qs # Import URL parsing utilities
|
| 11 |
from utils.callbackmanager import CallbackManager
|
| 12 |
from prompts import system_instructions
|
| 13 |
-
|
| 14 |
-
logging.basicConfig(level=logging.INFO)
|
| 15 |
-
logger = logging.getLogger(__name__)
|
| 16 |
|
| 17 |
# Import PDF utilities
|
| 18 |
from pdfutils import PDFGenerator, generate_discharge_summary
|
|
@@ -26,6 +24,10 @@ import csv # For CSV
|
|
| 26 |
import io # For IO operations
|
| 27 |
from PIL import Image # For image handling
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# Initialize Inference Client - Ensure YOUR_HF_TOKEN is set in environment variables or replace with your actual token
|
| 30 |
HF_TOKEN = os.getenv("HF_TOKEN") # Or replace with your actual token string
|
| 31 |
if not HF_TOKEN:
|
|
|
|
| 10 |
from urllib.parse import urlparse, parse_qs # Import URL parsing utilities
|
| 11 |
from utils.callbackmanager import CallbackManager
|
| 12 |
from prompts import system_instructions
|
| 13 |
+
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Import PDF utilities
|
| 16 |
from pdfutils import PDFGenerator, generate_discharge_summary
|
|
|
|
| 24 |
import io # For IO operations
|
| 25 |
from PIL import Image # For image handling
|
| 26 |
|
| 27 |
+
# Set up logging
|
| 28 |
+
logging.basicConfig(level=logging.INFO)
|
| 29 |
+
logger = logging.getLogger(__name__)
|
| 30 |
+
|
| 31 |
# Initialize Inference Client - Ensure YOUR_HF_TOKEN is set in environment variables or replace with your actual token
|
| 32 |
HF_TOKEN = os.getenv("HF_TOKEN") # Or replace with your actual token string
|
| 33 |
if not HF_TOKEN:
|