diff --git a/config_example.json b/config_example.json new file mode 100644 index 0000000..665a1e9 --- /dev/null +++ b/config_example.json @@ -0,0 +1,3 @@ +{ + "access_token": "your token" +} diff --git a/main.py b/main.py new file mode 100644 index 0000000..1f306d9 --- /dev/null +++ b/main.py @@ -0,0 +1,44 @@ +from revChatGPT.V1 import Chatbot +import gradio as gr +import json + +print(f'[INFO] Loading Config...') +with open('config.json', 'r') as f: + config = json.load(f) +print(config) + +print(f'[INFO] Initializing Chatbot API...') +chatbot = Chatbot(config=config) + +def submit(x): + for data in chatbot.ask(x): + message = data["message"] + return message + +print(f'[INFO] Warming up chatgpt to behave as an English writing improver...') + +init_prompt = """ +I would like to engage your services as an academic writing consultant to improve my writing. +I will provide you with text that requires refinement, and you will enhance it with more academic language and sentence structures. +The essence of the text should remain unaltered, including any LaTeX commands. +I request that you provide only the improved version of the text without any further explanations. +""" + +response = submit(init_prompt) + +print(f'[INFO] Warming up: \n{response}') + +print(f'[INFO] Starting Gradio APP...') + +with gr.Blocks() as app: + gr.Markdown("### ChatGPT, please help to improve my paper writing!") + + with gr.Row(): + + text_input = gr.Textbox(label="Input", lines=10) + text_output = gr.Textbox(label="Output", lines=10) + + text_button = gr.Button("Submit") + text_button.click(submit, inputs=text_input, outputs=text_output) + +app.launch() \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..bfbe05a --- /dev/null +++ b/readme.md @@ -0,0 +1,27 @@ +## ChatGPT, please help to improve my paper writing! + +A thin wrapper of chatgpt with a gradio interface for improving academic writing. + +The initialization prompt (also rewritten with chatgpt): +``` +I would like to engage your services as an academic writing consultant to improve my writing. +I will provide you with text that requires refinement, and you will enhance it with more academic language and sentence structures. +The essence of the text should remain unaltered, including any LaTeX commands. +I request that you provide only the improved version of the text without any further explanations. +``` + +### Usage +```bash +### install +git clone https://github.com/ashawkey/chatgpt_please_improve_my_paper_writing.git +cd chatgpt_please_improve_my_paper_writing +pip install -r requirements.txt + +### create a config.json and put your email/password/access_token into it. +# please refer to https://github.com/acheong08/ChatGPT for a valid config. +# usually the access_token from https://chat.openai.com/api/auth/session is enough. +cp config_example.json config.json + +### run gradio +python main.py +``` \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..bd0708d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +revChatGPT +gradio \ No newline at end of file