Update app.py
Browse files
app.py
CHANGED
|
@@ -11,12 +11,14 @@ openai.api_key = os.getenv('OPENAI_API_KEY')
|
|
| 11 |
|
| 12 |
# Function to classify email
|
| 13 |
def classify_email(email_text):
|
| 14 |
-
response = openai.
|
| 15 |
-
model='gpt-3.5-turbo
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
)
|
| 19 |
-
return response
|
| 20 |
|
| 21 |
# Streamlit interface
|
| 22 |
st.title('Email Classifier')
|
|
|
|
| 11 |
|
| 12 |
# Function to classify email
|
| 13 |
def classify_email(email_text):
|
| 14 |
+
response = openai.ChatCompletion.create(
|
| 15 |
+
model='gpt-3.5-turbo',
|
| 16 |
+
messages=[
|
| 17 |
+
{"role": "system", "content": "You are an email classifier."},
|
| 18 |
+
{"role": "user", "content": f"Classify the following email:\n\n{email_text}\n\nCategories: Spam, Work, Personal, Promotion, Other"}
|
| 19 |
+
]
|
| 20 |
)
|
| 21 |
+
return response['choices'][0]['message']['content'].strip()
|
| 22 |
|
| 23 |
# Streamlit interface
|
| 24 |
st.title('Email Classifier')
|