File size: 679 Bytes
accfebc
 
dc480fb
d38e396
732d546
d38e396
 
 
732d546
f51ee25
 
 
 
 
 
accfebc
f51ee25
accfebc
dc480fb
accfebc
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import streamlit as st
import requests
import os
from dotenv import load_dotenv

load_dotenv()
api_key = os.getenv('HF_API_KEY')
model_path = os.getenv('MODEL_PATH')

def get_model_predictions(text):
    headers = {"Authorization": f"Bearer {api_key}"}
    payload = {"inputs": text}
    response = requests.post(f"https://api.huggingface.co/models/{model_path}", headers=headers, json=payload)
    return response.json()

st.title("My AI Prediction App")

text = st.text_area("Enter text to predict")

if st.button("Predict"):
    if text:
        result = get_model_predictions(text)
        st.write("Prediction:", result)
    else:
        st.write("Please enter some text.")