Pamudu13 commited on
Commit
fc6e4c6
·
verified ·
1 Parent(s): 6ccd5aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -24,8 +24,8 @@ file_name = "Default"
24
  chatbot_name = "Lunar Ai"
25
  word_limit = 2000
26
 
27
- # Introduce the chatbot with its name
28
- system_message = f"You are an AI language assistant named {chatbot_name}. Your sole task is to correct the grammar, spelling, and structure of the sentences provided to you. You must not change the meaning of the sentences, and you should focus only on making them grammatically correct, concise, and clear. Do not add any additional information or provide explanations unless specifically asked. Your responses should be limited to the corrected version of the sentence."
29
  history.append({"role": "system", "content": system_message})
30
 
31
  def get_word_count(text):
@@ -57,14 +57,14 @@ def chat_bot():
57
  first_message = False
58
  history.append({"role": "user", "content": message})
59
 
60
- # Use the ChatCompletion method instead of Completion
61
  response = openai.ChatCompletion.create(
62
- model="gpt-3.5-turbo", # Ensure you are using the right model
63
- messages=history, # Pass the history of messages
64
  max_tokens=150
65
  )
66
 
67
- # Get the assistant's reply
68
  assistant_reply = response['choices'][0]['message']['content']
69
  history.append({"role": "assistant", "content": assistant_reply})
70
 
 
24
  chatbot_name = "Lunar Ai"
25
  word_limit = 2000
26
 
27
+ # Set the chatbot's task to correct grammar, spelling, and structure only
28
+ system_message = f"You are an AI language assistant named {chatbot_name}. Your only task is to correct the grammar, spelling, and structure of the sentences provided to you without changing their meaning. If the input is out of scope, respond by repeating what the user said, with grammatical corrections if necessary."
29
  history.append({"role": "system", "content": system_message})
30
 
31
  def get_word_count(text):
 
57
  first_message = False
58
  history.append({"role": "user", "content": message})
59
 
60
+ # Use the ChatCompletion method to get only grammar-corrected response
61
  response = openai.ChatCompletion.create(
62
+ model="gpt-3.5-turbo",
63
+ messages=history,
64
  max_tokens=150
65
  )
66
 
67
+ # Get the assistant's grammar-corrected response
68
  assistant_reply = response['choices'][0]['message']['content']
69
  history.append({"role": "assistant", "content": assistant_reply})
70