Youssouf Traore
commited on
Commit
·
045c254
1
Parent(s):
d9dc495
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,31 @@
|
|
1 |
import gradio as gr
|
2 |
import openai
|
3 |
import os
|
|
|
|
|
|
|
4 |
|
5 |
title = "Mariam 💎"
|
6 |
description = """" Banana Banana ? 👀 bon ok ok. Bref comme vous le voyez c'est simple ! Pas besoin d'explication. C'est un script simple, c'est basé sur néoX, python, et gradio.
|
7 |
|
8 |
Mon numéro : +24165362371"""
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
description_ocr = """Quand tu finis d'importer le texte sélectionne le et copie le !!!!"""
|
|
|
|
|
|
|
|
|
11 |
#app 1
|
12 |
|
13 |
import requests
|
@@ -38,14 +56,8 @@ def infer(im):
|
|
38 |
return text
|
39 |
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
#app 2
|
46 |
|
47 |
-
openai.api_key = os.environ.get("OPENAI_API_KEY")
|
48 |
-
|
49 |
def gpt(prompt):
|
50 |
if not prompt:
|
51 |
return "Veuillez saisir une question."
|
@@ -65,14 +77,130 @@ def gpt(prompt):
|
|
65 |
print(answer)
|
66 |
return answer
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
|
70 |
#interface 1
|
71 |
app1 = gr.Interface(fn = infer,title="Mariam -Ocr ",description=description_ocr, inputs=[gr.Image(type="pil")], outputs=["text"])
|
72 |
-
#interface 2
|
73 |
|
|
|
74 |
app2 = gr.Interface(fn = gpt,title="Mariam-U", description=description, inputs=gr.Textbox(label="Question:",lines=8), outputs=gr.Textbox())
|
75 |
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import openai
|
3 |
import os
|
4 |
+
import math as matha
|
5 |
+
|
6 |
+
openai.api_key = os.environ.get("OPENAI_API_KEY")
|
7 |
|
8 |
title = "Mariam 💎"
|
9 |
description = """" Banana Banana ? 👀 bon ok ok. Bref comme vous le voyez c'est simple ! Pas besoin d'explication. C'est un script simple, c'est basé sur néoX, python, et gradio.
|
10 |
|
11 |
Mon numéro : +24165362371"""
|
12 |
|
13 |
+
title_c = "Calculateur de moyenne !"
|
14 |
+
description_c = """Entrez vos notes pour chaque matière pour calculer votre moyenne.
|
15 |
+
Note : les coefficients de cette app sont adaptés à la classe de première S uniquement. Je ferais une mise à jour plus tard si j'ai le temps.
|
16 |
+
la conduite est fixé à 14/20.
|
17 |
+
Et ici la virgule s'écrit avec le point.
|
18 |
+
|
19 |
+
Exemple : 12,5 devient 12.5
|
20 |
+
|
21 |
+
Contact : +241065362371"""
|
22 |
+
|
23 |
+
|
24 |
description_ocr = """Quand tu finis d'importer le texte sélectionne le et copie le !!!!"""
|
25 |
+
|
26 |
+
title_f = "Travail argumentative"
|
27 |
+
description_french = " Esseu je dois encore expliquer ?"
|
28 |
+
|
29 |
#app 1
|
30 |
|
31 |
import requests
|
|
|
56 |
return text
|
57 |
|
58 |
|
|
|
|
|
|
|
|
|
59 |
#app 2
|
60 |
|
|
|
|
|
61 |
def gpt(prompt):
|
62 |
if not prompt:
|
63 |
return "Veuillez saisir une question."
|
|
|
77 |
print(answer)
|
78 |
return answer
|
79 |
|
80 |
+
df gpt_francais(french_prompt,choix):
|
81 |
+
if not french_prompt:
|
82 |
+
return "Veuillez saisir un thème ."
|
83 |
+
|
84 |
+
fi_prompt = """Je veux faire mon travail de français de niveau lycé sous la forme d'un travail argumentatif . La question du travail est la suivante: f"{french_prompt}". tu devras {choix} ce thème.
|
85 |
+
|
86 |
+
jai besoin dune introduction(avec une problématique et l'annonce du plan), de 3 arguments(avec explication et example et illustration) et d'une conclusion avec une ouverture(donné sous forme de phrase interogative ) """
|
87 |
+
response = openai.Completion.create(
|
88 |
+
model="text-davinci-003",
|
89 |
+
prompt=fi_prompt,
|
90 |
+
temperature=0.9,
|
91 |
+
max_tokens=3900,
|
92 |
+
top_p=1)
|
93 |
+
|
94 |
+
answer = response.choices[0].text.strip()
|
95 |
+
print(answer)
|
96 |
+
return answer
|
97 |
+
|
98 |
+
|
99 |
+
|
100 |
+
def gpt_philo(phi_prompt):
|
101 |
+
if not phi_prompt:
|
102 |
+
return "Veuillez saisir un sujet."
|
103 |
+
|
104 |
+
haha = """ Je veux faire mon travail de philosophie de niveau lycé sous la forme d'une dissertation . La question du travail est la suivante: "{phi_prompt}". en te basant sur le plan suiavnt :
|
105 |
+
|
106 |
+
INTRODUCTION:
|
107 |
+
|
108 |
+
- Amorcer le sujet avec moins de deux phrase
|
109 |
+
-Poser le problème
|
110 |
+
- Formulée la problématique autour de deux questions essentielles:
|
111 |
+
- Question-thèse
|
112 |
+
-Question-antithèse:
|
113 |
+
|
114 |
+
DEVELOPPEMENT
|
115 |
+
|
116 |
+
Première Partie: Formuler la thèse initiale
|
117 |
+
|
118 |
+
- ler Argument:
|
119 |
+
- Explication de l'argument
|
120 |
+
- Illustration (soit avec un exemple de la vie courante soit avec une citation philosophique)
|
121 |
+
- De plus,De.même, Dans cette optique.(2e Argument)
|
122 |
+
-Explication de l'argument.
|
123 |
+
-illustration.
|
124 |
+
-Transition.
|
125 |
+
- De plus,De.même, Dans cette optique.(3e Argument)
|
126 |
+
-Explication de l'argument.
|
127 |
+
-illustration
|
128 |
+
|
129 |
+
Deuxième Partie: Formuler l'antithèse
|
130 |
+
|
131 |
+
-1er Argument:
|
132 |
+
-Explication de l'argument.
|
133 |
+
-Illustration
|
134 |
+
- Par ailleurs, En outre, De même.(2ème Argument)
|
135 |
+
-Explication de l'argument.
|
136 |
+
- Illustration
|
137 |
+
- De plus,De.même, Dans cette optique.(3e Argument)
|
138 |
+
-Explication de l'argument.
|
139 |
+
-illustration.
|
140 |
+
|
141 |
+
CONCLUSION
|
142 |
+
|
143 |
+
1. Bilan de la réflexion:
|
144 |
+
-Résumer les grandes parties de la réflexion
|
145 |
+
2. Prise de position"""
|
146 |
+
|
147 |
+
response = openai.Completion.create(
|
148 |
+
model="text-davinci-003",prompt=haha,
|
149 |
+
temperature=0.9,
|
150 |
+
max_tokens=3500,
|
151 |
+
top_p=1)
|
152 |
+
|
153 |
+
answer = response.choices[0].text.strip()
|
154 |
+
|
155 |
+
return answer
|
156 |
+
|
157 |
+
|
158 |
+
def calcul(math, francais, physique, svt, philo, eps, thea, hist, anglais):
|
159 |
+
math = math * 5
|
160 |
+
francais = francais * 3
|
161 |
+
physique = physique * 4
|
162 |
+
svt = svt * 3
|
163 |
+
philo = philo * 2
|
164 |
+
eps = eps * 2
|
165 |
+
thea = thea * 3
|
166 |
+
anglais = anglais * 2
|
167 |
+
hist = hist * 3
|
168 |
+
conduite = 14 * 1
|
169 |
+
total = math + francais + physique + svt + philo + eps + thea + hist + anglais + conduite
|
170 |
+
r = total/28
|
171 |
+
return matha.trunc(r*100)/100
|
172 |
+
|
173 |
|
174 |
|
175 |
#interface 1
|
176 |
app1 = gr.Interface(fn = infer,title="Mariam -Ocr ",description=description_ocr, inputs=[gr.Image(type="pil")], outputs=["text"])
|
|
|
177 |
|
178 |
+
#interface 2
|
179 |
app2 = gr.Interface(fn = gpt,title="Mariam-U", description=description, inputs=gr.Textbox(label="Question:",lines=8), outputs=gr.Textbox())
|
180 |
|
181 |
+
#interface3
|
182 |
+
|
183 |
+
app3 = gr.Interface(fn =gpt_francais,title="Mariam-French",
|
184 |
+
title = title_f, description=description_french, inputs=[ gr.Textbox(label="Sujet:",lines=8),gr.Radio(["Etaye", "refute"])] ,outputs=gr.Textbox())
|
185 |
+
|
186 |
+
|
187 |
+
#interface4
|
188 |
+
|
189 |
+
app4 = gr.Interface(fn =gpt_philo,title="Mariam-Philo",
|
190 |
+
title= "Dissertation philo", description="Ah..banana banana...", inputs=gr.Textbox(label="Sujet:",lines=8),outputs=gr.Textbox())
|
191 |
+
|
192 |
+
#interface5
|
193 |
+
app5 = gr.Interface(fn=calcul, inputs=[gr.inputs.Number(label="Math"),
|
194 |
+
gr.inputs.Number(label="Français"),
|
195 |
+
gr.inputs.Number(label="Physique"),
|
196 |
+
gr.inputs.Number(label="SVT"),
|
197 |
+
gr.inputs.Number(label="Philo"),
|
198 |
+
gr.inputs.Number(label="EPS"),
|
199 |
+
gr.inputs.Number(label="Théâtre"),
|
200 |
+
gr.inputs.Number(label="Histoire"),
|
201 |
+
gr.inputs.Number(label="Anglais")
|
202 |
+
], outputs = gr.Textbox(label="Moyenne"), title=title_c, description=description_c)
|
203 |
+
|
204 |
+
demo = gr.TabbedInterface([app1, app2,app3,app4,app5], ["OCR", "MARIAM-u","Mariam-French","Mariam-Philo","Note Calc"])
|
205 |
|
206 |
+
demo.launch()
|