AjayKr09 commited on
Commit
7b35252
·
verified ·
1 Parent(s): c5cf007

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
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.Completion.create(
15
- model='gpt-3.5-turbo-instruct',
16
- prompt=f'Classify the following email:\n\n{email_text}\n\nCategories: Spam, Work, Personal, Promotion, Other',
17
- max_tokens=50
 
 
18
  )
19
- return response.choices[0].text.strip()
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')