Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,32 +26,28 @@ def CustomChatGPT(user_input):
|
|
| 26 |
messages.append(user_message)
|
| 27 |
|
| 28 |
while True:
|
| 29 |
-
response = openai.
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
max_tokens=1024,
|
| 33 |
-
n=1,
|
| 34 |
-
stop=None,
|
| 35 |
-
temperature=0.7,
|
| 36 |
)
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
|
|
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
# Add text instructions on top of the input and output boxes
|
| 44 |
input_text = "ここに訂正してほしい英語の作文を置いてください。そして「Submit」を押してください:"
|
| 45 |
output_text = "訂正と説明はここに表示されます:"
|
| 46 |
instructions = "このアプリケーションは、文法と綴りをチェックするために使用できます。作文が約200語(または1つのパラグラフ)の場合に最適に機能します。もし、作成した作文がそれより長い場合は、約200語ずつの部分に分けて、「Submit」してください。例えば、文章が400語の場合は、「Submit」を2回行うことになります。"
|
| 47 |
|
| 48 |
-
#
|
| 49 |
-
background_image = "https://i.pinimg.com/originals/9d/cf/d8/9dcfd8c4d5c2c5ee6c570692cdab26e7.jpg"
|
| 50 |
-
|
| 51 |
-
# Modify the Gradio interface to include the text instructions, image, and theme
|
| 52 |
demo = gradio.Interface(fn=CustomChatGPT, inputs=gradio.inputs.Textbox(lines=5, label=input_text),
|
| 53 |
outputs=gradio.outputs.Textbox(label=output_text),
|
| 54 |
-
title="Teacher Jihan's Checking Assistant", description=instructions
|
| 55 |
-
theme="light", bgcolor=background_image)
|
| 56 |
|
| 57 |
-
demo.launch(share=False, debug=True)
|
|
|
|
| 26 |
messages.append(user_message)
|
| 27 |
|
| 28 |
while True:
|
| 29 |
+
response = openai.ChatCompletion.create(
|
| 30 |
+
model="gpt-3.5-turbo",
|
| 31 |
+
messages=messages
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
)
|
| 33 |
|
| 34 |
+
total_tokens = response['usage']['total_tokens']
|
| 35 |
+
if total_tokens < MAX_TOKENS:
|
| 36 |
+
break
|
| 37 |
|
| 38 |
+
ChatGPT_reply = response["choices"][0]["message"]["content"]
|
| 39 |
+
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
| 40 |
+
|
| 41 |
+
return ChatGPT_reply
|
| 42 |
|
| 43 |
# Add text instructions on top of the input and output boxes
|
| 44 |
input_text = "ここに訂正してほしい英語の作文を置いてください。そして「Submit」を押してください:"
|
| 45 |
output_text = "訂正と説明はここに表示されます:"
|
| 46 |
instructions = "このアプリケーションは、文法と綴りをチェックするために使用できます。作文が約200語(または1つのパラグラフ)の場合に最適に機能します。もし、作成した作文がそれより長い場合は、約200語ずつの部分に分けて、「Submit」してください。例えば、文章が400語の場合は、「Submit」を2回行うことになります。"
|
| 47 |
|
| 48 |
+
# Modify the Gradio interface to include the text instructions and image
|
|
|
|
|
|
|
|
|
|
| 49 |
demo = gradio.Interface(fn=CustomChatGPT, inputs=gradio.inputs.Textbox(lines=5, label=input_text),
|
| 50 |
outputs=gradio.outputs.Textbox(label=output_text),
|
| 51 |
+
title="Teacher Jihan's Checking Assistant", description=instructions)
|
|
|
|
| 52 |
|
| 53 |
+
demo.launch(share=False, debug=True)
|