Spaces:
Sleeping
Sleeping
Patrick Walukagga
commited on
Commit
·
9f895e9
1
Parent(s):
1007582
Add api endpoints
Browse files- api.py +8 -1
- utils/helpers.py +1 -1
api.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import os
|
|
|
2 |
|
3 |
from fastapi import FastAPI, HTTPException
|
4 |
from gradio_client import Client
|
@@ -6,16 +7,22 @@ from enum import Enum
|
|
6 |
from typing import List, Optional
|
7 |
from pydantic import BaseModel, Field, constr, ConfigDict
|
8 |
from fastapi.responses import FileResponse
|
|
|
9 |
|
10 |
from docs import description, tags_metadata
|
11 |
|
|
|
|
|
|
|
12 |
|
13 |
app = FastAPI(
|
14 |
title="ACRES RAG API",
|
15 |
description=description,
|
16 |
openapi_tags=tags_metadata,
|
17 |
)
|
18 |
-
|
|
|
|
|
19 |
|
20 |
class StudyVariables(str, Enum):
|
21 |
ebola_virus = "Ebola Virus"
|
|
|
1 |
import os
|
2 |
+
import logging
|
3 |
|
4 |
from fastapi import FastAPI, HTTPException
|
5 |
from gradio_client import Client
|
|
|
7 |
from typing import List, Optional
|
8 |
from pydantic import BaseModel, Field, constr, ConfigDict
|
9 |
from fastapi.responses import FileResponse
|
10 |
+
from dotenv import load_dotenv
|
11 |
|
12 |
from docs import description, tags_metadata
|
13 |
|
14 |
+
load_dotenv()
|
15 |
+
logging.basicConfig(level=logging.INFO)
|
16 |
+
logger = logging.getLogger(__name__)
|
17 |
|
18 |
app = FastAPI(
|
19 |
title="ACRES RAG API",
|
20 |
description=description,
|
21 |
openapi_tags=tags_metadata,
|
22 |
)
|
23 |
+
GRADIO_URL = os.getenv("GRADIO_URL", "http://localhost:7860/")
|
24 |
+
logger.info(f"GRADIO_URL: =======> {GRADIO_URL}")
|
25 |
+
client = Client(GRADIO_URL)
|
26 |
|
27 |
class StudyVariables(str, Enum):
|
28 |
ebola_virus = "Ebola Virus"
|
utils/helpers.py
CHANGED
@@ -88,7 +88,7 @@ def append_to_study_files(file_path, new_key, new_value):
|
|
88 |
"Gene Xpert": "data/gene_xpert_zotero_items.json"
|
89 |
}
|
90 |
"""
|
91 |
-
try:
|
92 |
# Read the existing data from the file
|
93 |
with open(file_path, "r") as file:
|
94 |
data = json.load(file)
|
|
|
88 |
"Gene Xpert": "data/gene_xpert_zotero_items.json"
|
89 |
}
|
90 |
"""
|
91 |
+
try:
|
92 |
# Read the existing data from the file
|
93 |
with open(file_path, "r") as file:
|
94 |
data = json.load(file)
|