Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
ashawkey committed Feb 20, 2023
0 parents commit 7663f5d
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"access_token": "your token"
}
44 changes: 44 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -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()
27 changes: 27 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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
```
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
revChatGPT
gradio

0 comments on commit 7663f5d

Please sign in to comment.