https://github.com/karthiksoman/ncats_llm_summarization
https://github.com/karthiksoman/ncats_llm_summarization
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/karthiksoman/ncats_llm_summarization
- Owner: karthiksoman
- License: apache-2.0
- Created: 2024-08-10T07:58:15.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-10-25T02:59:18.000Z (7 months ago)
- Last Synced: 2024-10-25T04:17:20.052Z (7 months ago)
- Language: Python
- Size: 144 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Biomedical Translator Data Summarization API
This repository contains a Flask-based API that generates summaries of structured responses from the [Biomedical Data Translator system](https://ui.transltr.io/demo) in natural language.
Currently, the API is hosted in the following URL:
https://biosummary.pythonanywhere.com
### Summary Endpoint
API has the summary endpoint called **"/summary"**.
It currently accepts JSON structured data which holds the user "query" and the "results" which has the following structure (Eg. refer this [sample data](https://github.com/karthiksoman/ncats_llm_summarization/blob/main/sample_data/mvp1-2ad7c20f-c252-4c15-bdf2-f4e4b5e7b50c.json)):
```
{
"query": "",
"results": [
{
"name": "",
"paths": [
"",
"",
""
]
}
]
}
```The list of biological paths represents the mechanistic explanation of how that answer (i.e., the biomedical concept) relates to the query.
#### Make an API call
**/summary** endpoint accepts **POST** request. Here is a snippet for calling the endpoint from python:
```
import requestsapi_endpoint = "https://biosummary.pythonanywhere.com/summary"
def stream_response(url, data):
headers = {'Content-Type': 'application/json'}
response = requests.post(url, json=data, headers=headers, stream=True)
if response.status_code == 200:
for chunk in response.iter_content(chunk_size=1, decode_unicode=True):
if chunk:
print(chunk, end='', flush=True)
else:
print(f"Error: {response.status_code}")
print(response.text)stream_response(api_endpoint, data)
```**Note:** 'data' is the JSON data as mentioned above
Refer [demo](https://github.com/karthiksoman/ncats_llm_summarization/blob/main/demo.ipynb) notebook for more details.