Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
def CustomChatGPT(user_input):
|
| 2 |
global messages
|
| 3 |
essay_keywords = ["essay", "エッセイ", "論文"]
|
|
@@ -27,3 +39,14 @@ def CustomChatGPT(user_input):
|
|
| 27 |
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
| 28 |
|
| 29 |
return ChatGPT_reply
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
import gradio
|
| 3 |
+
import os
|
| 4 |
+
import re
|
| 5 |
+
|
| 6 |
+
openai.api_key = os.environ.get("API_TOKEN")
|
| 7 |
+
|
| 8 |
+
messages = [{"role": "system", "content": "You are an education expert who can correct essays. You are bilingual in English and Japanese"}]
|
| 9 |
+
|
| 10 |
+
MAX_TOKENS = 4096
|
| 11 |
+
MAX_HISTORY = 1
|
| 12 |
+
|
| 13 |
def CustomChatGPT(user_input):
|
| 14 |
global messages
|
| 15 |
essay_keywords = ["essay", "エッセイ", "論文"]
|
|
|
|
| 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 |
+
|
| 47 |
+
# Modify the Gradio interface to include the text instructions and image
|
| 48 |
+
demo = gradio.Interface(fn=CustomChatGPT, inputs=gradio.inputs.Textbox(lines=5, label=input_text),
|
| 49 |
+
outputs=gradio.outputs.Textbox(label=output_text),
|
| 50 |
+
title="Teacher Jihan's Checking Assistant")
|
| 51 |
+
|
| 52 |
+
demo.launch(share=False, debug=True)
|