Spaces:
Sleeping
Sleeping
macbookpro
commited on
Commit
·
8c93fc6
1
Parent(s):
e60507c
backend e frontend adaptado para o promtMode
Browse files- server/app.py +6 -1
- web/src/App.jsx +3 -2
server/app.py
CHANGED
@@ -3,6 +3,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
|
3 |
from pydantic import BaseModel
|
4 |
from fastapi.staticfiles import StaticFiles
|
5 |
from services.generate_questions_service import GenerateQuestionsService
|
|
|
6 |
|
7 |
# from data.load_data import retriever_pre
|
8 |
|
@@ -13,6 +14,7 @@ class Body(BaseModel):
|
|
13 |
school_subject: str
|
14 |
subject: str
|
15 |
difficultie: str
|
|
|
16 |
|
17 |
|
18 |
app = FastAPI()
|
@@ -30,7 +32,10 @@ async def generate_questions(body: Body):
|
|
30 |
school_subject = body.school_subject
|
31 |
subject = body.subject
|
32 |
difficultie = body.difficultie
|
33 |
-
|
|
|
|
|
|
|
34 |
res = generate_questions_service.handle(f"""{query}""")
|
35 |
return res
|
36 |
|
|
|
3 |
from pydantic import BaseModel
|
4 |
from fastapi.staticfiles import StaticFiles
|
5 |
from services.generate_questions_service import GenerateQuestionsService
|
6 |
+
from typing import Optional
|
7 |
|
8 |
# from data.load_data import retriever_pre
|
9 |
|
|
|
14 |
school_subject: str
|
15 |
subject: str
|
16 |
difficultie: str
|
17 |
+
promptValue: Optional[str] = None
|
18 |
|
19 |
|
20 |
app = FastAPI()
|
|
|
32 |
school_subject = body.school_subject
|
33 |
subject = body.subject
|
34 |
difficultie = body.difficultie
|
35 |
+
if body.promptValue:
|
36 |
+
query = body.promptValue
|
37 |
+
else:
|
38 |
+
query = f"Quero que você gere questões de {school_subject}, sendo do assunto: {subject} e sendo da dificuldade: {difficultie}."
|
39 |
res = generate_questions_service.handle(f"""{query}""")
|
40 |
return res
|
41 |
|
web/src/App.jsx
CHANGED
@@ -13,7 +13,6 @@ import { Switch } from "@/components/ui/switch"
|
|
13 |
import { Label } from "@/components/ui/label"
|
14 |
import { Input } from "@/components/ui/input"
|
15 |
|
16 |
-
|
17 |
function App() {
|
18 |
|
19 |
const [subject, setSubject] = useState("");
|
@@ -24,6 +23,8 @@ function App() {
|
|
24 |
const [questions, setQuestions] = useState(null);
|
25 |
const [promptMode, setPromptMode] = useState(false);
|
26 |
|
|
|
|
|
27 |
const subjects = [
|
28 |
{ label: "Fisiologia", value: "fisiologia" },
|
29 |
{ label: "Embriologia", value: "embriologia" },
|
@@ -174,7 +175,7 @@ function App() {
|
|
174 |
{promptMode ? (
|
175 |
<>
|
176 |
<h2 className="text-2xl font-bold mb-5">Digite seu prompt para gerarmos as questões!</h2>
|
177 |
-
<Input placeholder="Digite seu prompt:" />
|
178 |
</>
|
179 |
) : (
|
180 |
<>
|
|
|
13 |
import { Label } from "@/components/ui/label"
|
14 |
import { Input } from "@/components/ui/input"
|
15 |
|
|
|
16 |
function App() {
|
17 |
|
18 |
const [subject, setSubject] = useState("");
|
|
|
23 |
const [questions, setQuestions] = useState(null);
|
24 |
const [promptMode, setPromptMode] = useState(false);
|
25 |
|
26 |
+
const [promptValue, setPromptValue] = useState('');
|
27 |
+
|
28 |
const subjects = [
|
29 |
{ label: "Fisiologia", value: "fisiologia" },
|
30 |
{ label: "Embriologia", value: "embriologia" },
|
|
|
175 |
{promptMode ? (
|
176 |
<>
|
177 |
<h2 className="text-2xl font-bold mb-5">Digite seu prompt para gerarmos as questões!</h2>
|
178 |
+
<Input placeholder="Digite seu prompt:" value={promptValue} onChange={(e) => setPromptValue(e.target.value)}/>
|
179 |
</>
|
180 |
) : (
|
181 |
<>
|