Spaces:
Running
Running
update emoji
Browse files
README.md
CHANGED
@@ -20,7 +20,7 @@ ChatGPT as a writing partner.
|
|
20 |
|
21 |
```bash
|
22 |
$ git clone https://github.com/Spico197/writing-comrade
|
23 |
-
$ cd writing-comrade
|
24 |
$ pip install -r requirements.txt
|
25 |
$ python app.py
|
26 |
```
|
|
|
20 |
|
21 |
```bash
|
22 |
$ git clone https://github.com/Spico197/writing-comrade
|
23 |
+
$ cd writing-comrade
|
24 |
$ pip install -r requirements.txt
|
25 |
$ python app.py
|
26 |
```
|
app.py
CHANGED
@@ -33,7 +33,7 @@ def chat(task_type: str, text: str, api_key: str, tgt_lang: str = "") -> str:
|
|
33 |
messages = [
|
34 |
{
|
35 |
"role": "system",
|
36 |
-
"content": "You are a helpful writing assistant
|
37 |
},
|
38 |
{"role": "user", "content": prompt},
|
39 |
]
|
@@ -49,10 +49,10 @@ def chat(task_type: str, text: str, api_key: str, tgt_lang: str = "") -> str:
|
|
49 |
finish_reason = res["choices"][0]["finish_reason"]
|
50 |
if len(messages) >= 5:
|
51 |
break
|
52 |
-
|
53 |
response_text = " ".join(
|
54 |
[msg["content"] for msg in messages if msg["role"] == "assistant"]
|
55 |
-
)
|
|
|
56 |
return response_text
|
57 |
|
58 |
|
@@ -70,7 +70,7 @@ with gr.Blocks(css="") as demo:
|
|
70 |
|
71 |
with gr.Row().style(equal_height=True):
|
72 |
with gr.Column(scale=3):
|
73 |
-
emojis = "
|
74 |
task_type = gr.Radio([f"{emojis[i]}{k.title()}" for i, k in enumerate(instructions.keys())], label="Task")
|
75 |
with gr.Column(min_width=100):
|
76 |
tgt_lang = gr.Textbox(label="Target language in translation")
|
@@ -87,4 +87,4 @@ with gr.Blocks(css="") as demo:
|
|
87 |
chat, inputs=[task_type, text_input, api_key, tgt_lang], outputs=text_output
|
88 |
)
|
89 |
|
90 |
-
demo.launch()
|
|
|
33 |
messages = [
|
34 |
{
|
35 |
"role": "system",
|
36 |
+
"content": f"You are a helpful writing assistant who can do {task_type}.",
|
37 |
},
|
38 |
{"role": "user", "content": prompt},
|
39 |
]
|
|
|
49 |
finish_reason = res["choices"][0]["finish_reason"]
|
50 |
if len(messages) >= 5:
|
51 |
break
|
|
|
52 |
response_text = " ".join(
|
53 |
[msg["content"] for msg in messages if msg["role"] == "assistant"]
|
54 |
+
).strip()
|
55 |
+
|
56 |
return response_text
|
57 |
|
58 |
|
|
|
70 |
|
71 |
with gr.Row().style(equal_height=True):
|
72 |
with gr.Column(scale=3):
|
73 |
+
emojis = "⌨️🥊💎🍦🚌🎤"
|
74 |
task_type = gr.Radio([f"{emojis[i]}{k.title()}" for i, k in enumerate(instructions.keys())], label="Task")
|
75 |
with gr.Column(min_width=100):
|
76 |
tgt_lang = gr.Textbox(label="Target language in translation")
|
|
|
87 |
chat, inputs=[task_type, text_input, api_key, tgt_lang], outputs=text_output
|
88 |
)
|
89 |
|
90 |
+
demo.launch(show_error=True)
|