Commit
·
5f7ee7d
1
Parent(s):
0295484
Update writing_assistant_app.py
Browse files- writing_assistant_app.py +8 -3
writing_assistant_app.py
CHANGED
@@ -5,12 +5,16 @@ import gradio as gr
|
|
5 |
# Configure votre clé API
|
6 |
openai.api_key = os.environ['OpenaiKey']
|
7 |
|
8 |
-
def writing_assistant(debut, suite):
|
9 |
# Construction de la requête
|
10 |
-
prompt = f"DEBUT = '{debut}'\n\n SUITE = '{suite}'\n\n
|
|
|
|
|
|
|
|
|
11 |
|
12 |
messages = [
|
13 |
-
{"role": "system", "content": f"Tu es un auteur contemporain."},
|
14 |
{"role": "user", "content": prompt}
|
15 |
]
|
16 |
|
@@ -31,6 +35,7 @@ iface = gr.Interface(
|
|
31 |
inputs=[
|
32 |
gr.inputs.Textbox(lines=5, label="Début"),
|
33 |
gr.inputs.Textbox(lines=5, label="Suite")
|
|
|
34 |
],
|
35 |
outputs=gr.outputs.Textbox(label="Texte réécrit"),
|
36 |
title="Assistant d'écriture",
|
|
|
5 |
# Configure votre clé API
|
6 |
openai.api_key = os.environ['OpenaiKey']
|
7 |
|
8 |
+
def writing_assistant(debut, suite, instructions):
|
9 |
# Construction de la requête
|
10 |
+
prompt = f"DEBUT = '{debut}'\n\n SUITE = '{suite}'\n\n
|
11 |
+
Peux-tu réécrire SUITE en reprenant le style littéraire de DEBUT
|
12 |
+
(ton, rythme, registre de vocabulaire, type de mots, taille des phrases, ponctuation...) ?
|
13 |
+
N'ajoute pas d'autres éléments narratifs que ceux mentionnés dans SUITE.
|
14 |
+
\n\n {instructions}"
|
15 |
|
16 |
messages = [
|
17 |
+
{"role": "system", "content": f"Tu es un assistant d'écriture. Tu aides un auteur contemporain à écrire, en t'inspirant de son style littéraire."},
|
18 |
{"role": "user", "content": prompt}
|
19 |
]
|
20 |
|
|
|
35 |
inputs=[
|
36 |
gr.inputs.Textbox(lines=5, label="Début"),
|
37 |
gr.inputs.Textbox(lines=5, label="Suite")
|
38 |
+
gr.inputs.Textbox(lines=2, label="Instructions additionnelles")
|
39 |
],
|
40 |
outputs=gr.outputs.Textbox(label="Texte réécrit"),
|
41 |
title="Assistant d'écriture",
|