Create main.py
Browse files
main.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from gradio_client import Client
|
2 |
+
|
3 |
+
client = Client("https://ruslanmv-ai-medical-chatbot.hf.space/--replicas/93n5n/")
|
4 |
+
result = client.predict(
|
5 |
+
"Howdy!", # str in 'Input Prompt' Textbox component
|
6 |
+
fn_index=0
|
7 |
+
)
|
8 |
+
print(result)
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
import requests
|
15 |
+
|
16 |
+
API_URL = "https://api-inference.huggingface.co/models/dmis-lab/biobert-base-cased-v1.1"
|
17 |
+
headers = {"Authorization": "Bearer YOUR_HUGGING_FACE_API_KEY"}
|
18 |
+
|
19 |
+
def query(payload):
|
20 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
21 |
+
return response.json()
|
22 |
+
|
23 |
+
# Example query
|
24 |
+
data = {
|
25 |
+
"inputs": {
|
26 |
+
"question": "What are the symptoms of COVID-19?",
|
27 |
+
"context": "COVID-19 symptoms include fever, dry cough, and tiredness. Some patients may have aches and pains, nasal congestion, sore throat or diarrhea."
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
result = query(data)
|
32 |
+
print(result)
|