Spaces:
Sleeping
Sleeping
baptistejamin
commited on
Commit
•
67df4ab
1
Parent(s):
f50ea06
Add tasks
Browse files
app.py
CHANGED
@@ -4,33 +4,40 @@ import os
|
|
4 |
|
5 |
client = OpenAI(api_key=os.getenv("OPENAI_KEY"))
|
6 |
|
7 |
-
def generate_response(
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
|
24 |
|
25 |
def main():
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
|
35 |
if __name__ == "__main__":
|
36 |
-
|
|
|
4 |
|
5 |
client = OpenAI(api_key=os.getenv("OPENAI_KEY"))
|
6 |
|
7 |
+
def generate_response(tache, article):
|
8 |
+
model = "ft:gpt-3.5-turbo-0613:personal::8C0XIiJC"
|
9 |
+
prefix = "Trouve un titre pour cet article:\n\n"
|
10 |
+
|
11 |
+
if tache == "chapeau":
|
12 |
+
model = "gpt-3.5-turbo"
|
13 |
+
prefix = "Trouve un premier paragraphe introductif de 200 signes pour cet article:\n\n"
|
14 |
+
|
15 |
+
response = client.chat.completions.create(
|
16 |
+
model=model,
|
17 |
+
messages=[
|
18 |
+
{
|
19 |
+
"role": "user",
|
20 |
+
"content": prefix + article
|
21 |
+
}
|
22 |
+
],
|
23 |
+
temperature=0.5,
|
24 |
+
max_tokens=256,
|
25 |
+
top_p=1,
|
26 |
+
frequency_penalty=0,
|
27 |
+
presence_penalty=0
|
28 |
+
)
|
29 |
|
30 |
+
return response.choices[0].message.content
|
31 |
|
32 |
def main():
|
33 |
+
interface = gr.Interface(
|
34 |
+
fn=generate_response,
|
35 |
+
inputs=[gr.Dropdown(choices=["titre", "chapeau"], value="titre"), gr.Textbox(lines=50, placeholder="Entrez votre article ici...")],
|
36 |
+
outputs="text",
|
37 |
+
title="Générateur de titre",
|
38 |
+
description="Entrez un article"
|
39 |
+
)
|
40 |
+
interface.launch(auth=("admin", os.getenv("PASSWORD")))
|
41 |
|
42 |
if __name__ == "__main__":
|
43 |
+
main()
|