File size: 851 Bytes
fa79fa8 |
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 26 27 28 |
import streamlit as st
import openai
# Set your OpenAI API key
openai.api_key = 'your_openai_api_key'
# Function to classify email
def classify_email(email_text):
response = openai.Completion.create(
model='gpt-3.5-turbo-instruct',
prompt=f'Classify the following email:\n\n{email_text}\n\nCategories: Spam, Work, Personal, Promotion, Other',
max_tokens=50
)
return response.choices[0].text.strip()
# Streamlit interface
st.title('Email Classifier')
st.write('Enter the email text below and click "Classify" to determine its category.')
email_text = st.text_area('Email Text', height=300)
if st.button('Classify'):
if email_text:
category = classify_email(email_text)
st.write(f'The email is classified as: **{category}**')
else:
st.write('Please enter some text to classify.')
|