Spaces:
Runtime error
Runtime error
lucas-wa commited on
Commit ·
7678c37
1
Parent(s): dbbf6b6
Update interface
Browse files- server/app.py +1 -2
- web/src/App.jsx +36 -10
server/app.py
CHANGED
|
@@ -28,8 +28,7 @@ app.add_middleware(
|
|
| 28 |
|
| 29 |
|
| 30 |
@app.post("/generate_questions")
|
| 31 |
-
|
| 32 |
-
print(body)
|
| 33 |
if body.promptValue:
|
| 34 |
query = body.promptValue
|
| 35 |
else:
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
@app.post("/generate_questions")
|
| 31 |
+
def generate_questions(body: Body):
|
|
|
|
| 32 |
if body.promptValue:
|
| 33 |
query = body.promptValue
|
| 34 |
else:
|
web/src/App.jsx
CHANGED
|
@@ -15,6 +15,7 @@ import { Input } from "@/components/ui/input"
|
|
| 15 |
|
| 16 |
function App() {
|
| 17 |
|
|
|
|
| 18 |
const [subject, setSubject] = useState("");
|
| 19 |
const [difficultie, setDifficultie] = useState("");
|
| 20 |
|
|
@@ -25,7 +26,21 @@ function App() {
|
|
| 25 |
|
| 26 |
const [promptValue, setPromptValue] = useState('');
|
| 27 |
|
| 28 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
{ label: "Fisiologia", value: "fisiologia" },
|
| 30 |
{ label: "Embriologia", value: "embriologia" },
|
| 31 |
{ label: "Citologia", value: "citologia" },
|
|
@@ -47,7 +62,7 @@ function App() {
|
|
| 47 |
setIsLoading(true);
|
| 48 |
try {
|
| 49 |
|
| 50 |
-
const body = promptMode ? { promptValue } : { subject, difficultie };
|
| 51 |
|
| 52 |
const res = await fetch("/generate_questions", {
|
| 53 |
method: "POST",
|
|
@@ -129,12 +144,16 @@ function App() {
|
|
| 129 |
className="flex flex-col gap-2.5 top-0 h-full ">
|
| 130 |
<fieldset>
|
| 131 |
<h2>Selecione uma matéria:</h2>
|
| 132 |
-
<Select defaultValue="biologia">
|
| 133 |
<SelectTrigger className="w-[180px]">
|
| 134 |
<SelectValue placeholder="Matéria" />
|
| 135 |
</SelectTrigger>
|
| 136 |
<SelectContent>
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
</SelectContent>
|
| 139 |
</Select>
|
| 140 |
<h2>Selecione um conteúdo:</h2>
|
|
@@ -142,10 +161,17 @@ function App() {
|
|
| 142 |
<SelectTrigger className="w-[180px]">
|
| 143 |
<SelectValue placeholder="Conteúdo" />
|
| 144 |
</SelectTrigger>
|
| 145 |
-
<SelectContent
|
| 146 |
-
{
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
</SelectContent>
|
| 150 |
</Select>
|
| 151 |
<h2>Selecione uma dificuldade:</h2>
|
|
@@ -202,8 +228,8 @@ function App() {
|
|
| 202 |
Resposta correta: {answer}
|
| 203 |
</div>
|
| 204 |
))
|
| 205 |
-
:
|
| 206 |
-
|
| 207 |
!promptMode && <div className="p-2.5 bg-slate-950 ring-2 ring-white rounded">Escolha os filtros para criar as questões</div>
|
| 208 |
}
|
| 209 |
</div>
|
|
|
|
| 15 |
|
| 16 |
function App() {
|
| 17 |
|
| 18 |
+
const [schoolSubject, setSchoolSubject] = useState("biologia");
|
| 19 |
const [subject, setSubject] = useState("");
|
| 20 |
const [difficultie, setDifficultie] = useState("");
|
| 21 |
|
|
|
|
| 26 |
|
| 27 |
const [promptValue, setPromptValue] = useState('');
|
| 28 |
|
| 29 |
+
const schoolSubjects = [
|
| 30 |
+
{ label: "História", value: "historia" },
|
| 31 |
+
{ label: "Biologia", value: "biologia" },
|
| 32 |
+
];
|
| 33 |
+
|
| 34 |
+
const historySubjects = [
|
| 35 |
+
{ label: "Revoluções", value: "revoluções" },
|
| 36 |
+
{ label: "Grécia", value: "grécia" },
|
| 37 |
+
{ label: "Roma", value: "roma" },
|
| 38 |
+
{ label: "Primeira Guerra Mundial", value: "primeira guerra mundial" },
|
| 39 |
+
{ label: "Guerra Fria", value: "guerra fria" },
|
| 40 |
+
{ label: "Feudalismo", value: "feudalismo" },
|
| 41 |
+
]
|
| 42 |
+
|
| 43 |
+
const biologySubjects = [
|
| 44 |
{ label: "Fisiologia", value: "fisiologia" },
|
| 45 |
{ label: "Embriologia", value: "embriologia" },
|
| 46 |
{ label: "Citologia", value: "citologia" },
|
|
|
|
| 62 |
setIsLoading(true);
|
| 63 |
try {
|
| 64 |
|
| 65 |
+
const body = promptMode ? { promptValue } : { subject, difficultie, school_subject: schoolSubject };
|
| 66 |
|
| 67 |
const res = await fetch("/generate_questions", {
|
| 68 |
method: "POST",
|
|
|
|
| 144 |
className="flex flex-col gap-2.5 top-0 h-full ">
|
| 145 |
<fieldset>
|
| 146 |
<h2>Selecione uma matéria:</h2>
|
| 147 |
+
<Select defaultValue="biologia" onValueChange={value => setSchoolSubject(value)}>
|
| 148 |
<SelectTrigger className="w-[180px]">
|
| 149 |
<SelectValue placeholder="Matéria" />
|
| 150 |
</SelectTrigger>
|
| 151 |
<SelectContent>
|
| 152 |
+
{
|
| 153 |
+
schoolSubjects.map(({ label, value }) => (
|
| 154 |
+
<SelectItem key={value} value={value}>{label}</SelectItem>
|
| 155 |
+
))
|
| 156 |
+
}
|
| 157 |
</SelectContent>
|
| 158 |
</Select>
|
| 159 |
<h2>Selecione um conteúdo:</h2>
|
|
|
|
| 161 |
<SelectTrigger className="w-[180px]">
|
| 162 |
<SelectValue placeholder="Conteúdo" />
|
| 163 |
</SelectTrigger>
|
| 164 |
+
<SelectContent>
|
| 165 |
+
{schoolSubjects &&
|
| 166 |
+
schoolSubject === "historia" ?
|
| 167 |
+
historySubjects.map(({ label, value }) => (
|
| 168 |
+
<SelectItem key={value} value={value}>{label}</SelectItem>
|
| 169 |
+
))
|
| 170 |
+
:
|
| 171 |
+
biologySubjects.map(({ label, value }) => (
|
| 172 |
+
<SelectItem key={value} value={value}>{label}</SelectItem>
|
| 173 |
+
))
|
| 174 |
+
}
|
| 175 |
</SelectContent>
|
| 176 |
</Select>
|
| 177 |
<h2>Selecione uma dificuldade:</h2>
|
|
|
|
| 228 |
Resposta correta: {answer}
|
| 229 |
</div>
|
| 230 |
))
|
| 231 |
+
:
|
| 232 |
+
|
| 233 |
!promptMode && <div className="p-2.5 bg-slate-950 ring-2 ring-white rounded">Escolha os filtros para criar as questões</div>
|
| 234 |
}
|
| 235 |
</div>
|