Erfan11 commited on
Commit
2c3db68
1 Parent(s): 5490a28

Create streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +25 -0
streamlit_app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import os
4
+ from dotenv import load_dotenv
5
+
6
+ load_dotenv()
7
+ api_key = os.getenv('HF_API_KEY')
8
+ model_path = os.getenv('MODEL_PATH')
9
+
10
+ def get_model_predictions(text):
11
+ headers = {"Authorization": f"Bearer {api_key}"}
12
+ payload = {"inputs": text}
13
+ response = requests.post(f"https://api.huggingface.co/models/{model_path}", headers=headers, json=payload)
14
+ return response.json()
15
+
16
+ st.title("My AI Prediction App")
17
+
18
+ text = st.text_area("Enter text to predict")
19
+
20
+ if st.button("Predict"):
21
+ if text:
22
+ result = get_model_predictions(text)
23
+ st.write("Prediction:", result)
24
+ else:
25
+ st.write("Please enter some text.")