Spaces:
Sleeping
Sleeping
DiningSystem
commited on
Commit
·
6d5f1d4
0
Parent(s):
Duplicate from CVH-vn1210/essay_edit
Browse files- .gitattributes +34 -0
- README.md +14 -0
- app.py +32 -0
- requirements.txt +1 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Essay Edit
|
3 |
+
emoji: 🏃
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: red
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.29.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: mit
|
11 |
+
duplicated_from: CVH-vn1210/essay_edit
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import os
|
3 |
+
import gradio as gr
|
4 |
+
openai.api_key = os.environ['openai']
|
5 |
+
def write_essay(prompt, temperature, frequency_penalty, presence_penalty, max_token, model="gpt-3.5-turbo"):
|
6 |
+
temp_list = prompt.split()
|
7 |
+
temperature = temperature/10
|
8 |
+
frequency_penalty = frequency_penalty/10 - 2
|
9 |
+
presence_penalty = presence_penalty/10 -2
|
10 |
+
if len(temp_list) >= 500:
|
11 |
+
new_prompt = " ".join(temp_list[0:500])
|
12 |
+
else:
|
13 |
+
new_prompt = prompt
|
14 |
+
|
15 |
+
response = openai.ChatCompletion.create(
|
16 |
+
model=model,
|
17 |
+
messages=[{"role": "user", "content": new_prompt}],
|
18 |
+
#prompt=new_prompt,
|
19 |
+
max_tokens=int(max_token),
|
20 |
+
temperature=temperature,
|
21 |
+
frequency_penalty=frequency_penalty,
|
22 |
+
presence_penalty=presence_penalty
|
23 |
+
)
|
24 |
+
|
25 |
+
message = response.choices[0]["message"]["content"]
|
26 |
+
#print(message)
|
27 |
+
return message
|
28 |
+
demo = gr.Interface(fn=write_essay, inputs=["text",gr.Slider(0, 20, value=4, step=1, label="Creative vs Focus", info="Increase for creative and decrease for more focused"),
|
29 |
+
gr.Slider(0, 40, value=20, step=1, label="Frequency of words", info="Increase to decrease repeated words"),
|
30 |
+
gr.Slider(0, 40, value=20, step=1, label="Presence of words", info="Increase to decrease already appeared words"),"text"
|
31 |
+
], outputs="text")
|
32 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
openai
|