Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,8 +24,8 @@ file_name = "Default"
|
|
| 24 |
chatbot_name = "Lunar Ai"
|
| 25 |
word_limit = 2000
|
| 26 |
|
| 27 |
-
#
|
| 28 |
-
system_message = f"You are an AI language assistant named {chatbot_name}. Your
|
| 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
|
| 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
|
| 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 |
|