Spaces:
Running
Running
update emoji
Browse files
app.py
CHANGED
|
@@ -17,7 +17,7 @@ def chat(task_type: str, text: str, api_key: str) -> str:
|
|
| 17 |
openai.api_key = api_key
|
| 18 |
|
| 19 |
prompt = ""
|
| 20 |
-
task_type = task_type.lower()
|
| 21 |
if task_type == "freestyle":
|
| 22 |
prompt = text
|
| 23 |
else:
|
|
@@ -53,14 +53,17 @@ with gr.Blocks(css="") as demo:
|
|
| 53 |
gr.Markdown("# ✒️ Writing Comrade")
|
| 54 |
gr.Markdown("Comrade, I'm your faithful writing fellow powered by ChatGPT. Destination, commander?")
|
| 55 |
gr.Markdown(
|
| 56 |
-
"🎮 This demo is hosted on: https://huggingface.co/spaces/Spico/writing-comrade <br />
|
|
|
|
|
|
|
| 57 |
)
|
| 58 |
|
| 59 |
with gr.Row():
|
| 60 |
-
api_key = gr.Textbox(label=
|
| 61 |
|
| 62 |
with gr.Row():
|
| 63 |
-
|
|
|
|
| 64 |
text_button = gr.Button("Can~ do!")
|
| 65 |
|
| 66 |
with gr.Row():
|
|
|
|
| 17 |
openai.api_key = api_key
|
| 18 |
|
| 19 |
prompt = ""
|
| 20 |
+
task_type = task_type[1:].strip().lower()
|
| 21 |
if task_type == "freestyle":
|
| 22 |
prompt = text
|
| 23 |
else:
|
|
|
|
| 53 |
gr.Markdown("# ✒️ Writing Comrade")
|
| 54 |
gr.Markdown("Comrade, I'm your faithful writing fellow powered by ChatGPT. Destination, commander?")
|
| 55 |
gr.Markdown(
|
| 56 |
+
"🎮 This demo is hosted on: https://huggingface.co/spaces/Spico/writing-comrade <br />"
|
| 57 |
+
"⭐ Star me on GitHub: https://github.com/Spico197/writing-comrade <br />"
|
| 58 |
+
"You may want to follow this instruction to get an API key: https://help.openai.com/en/articles/4936850-where-do-i-find-my-secret-api-key"
|
| 59 |
)
|
| 60 |
|
| 61 |
with gr.Row():
|
| 62 |
+
api_key = gr.Textbox(label='OpenAI API Key')
|
| 63 |
|
| 64 |
with gr.Row():
|
| 65 |
+
emojis = "🪄🥊💎🫧🎤"
|
| 66 |
+
task_type = gr.Radio([f"{emojis[i]}{k.title()}" for i, k in enumerate(instructions.keys())], label="Task")
|
| 67 |
text_button = gr.Button("Can~ do!")
|
| 68 |
|
| 69 |
with gr.Row():
|