Spaces:
Runtime error
Runtime error
Commit
·
cc9a981
1
Parent(s):
e8eca0c
Atualiza app para medgema google
Browse files- Dockerfile +9 -0
- app.py +10 -8
Dockerfile
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9-slim
|
2 |
+
|
3 |
+
WORKDIR /app
|
4 |
+
|
5 |
+
COPY . /app
|
6 |
+
|
7 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
8 |
+
|
9 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
CHANGED
@@ -3,15 +3,17 @@ from transformers import pipeline
|
|
3 |
import json
|
4 |
|
5 |
app = FastAPI()
|
6 |
-
medgemma = pipeline("text-generation", model="/app/fine_tuned_medgemma", tokenizer="/app/fine_tuned_medgemma")
|
7 |
|
8 |
-
#
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
11 |
|
12 |
@app.get("/generate")
|
13 |
async def generate_question(theme: str, difficulty: str):
|
14 |
-
prompt = f"
|
15 |
response = medgemma(prompt, max_new_tokens=300, temperature=0.7, top_p=0.95)[0]['generated_text']
|
16 |
return {"question": response}
|
17 |
|
@@ -19,7 +21,7 @@ async def generate_question(theme: str, difficulty: str):
|
|
19 |
async def get_simulado(num_questions: int = 5):
|
20 |
simulado = []
|
21 |
for _ in range(num_questions):
|
22 |
-
prompt = "Gere uma questão
|
23 |
question = medgemma(prompt, max_new_tokens=300)[0]['generated_text']
|
24 |
-
simulado.append({"question": question
|
25 |
-
return {"simulado": simulado}
|
|
|
3 |
import json
|
4 |
|
5 |
app = FastAPI()
|
|
|
6 |
|
7 |
+
# Carregando o MedGemma direto do Hugging Face
|
8 |
+
medgemma = pipeline(
|
9 |
+
"text-generation",
|
10 |
+
model="google/medgemma-4b-it",
|
11 |
+
tokenizer="google/medgemma-4b-it"
|
12 |
+
)
|
13 |
|
14 |
@app.get("/generate")
|
15 |
async def generate_question(theme: str, difficulty: str):
|
16 |
+
prompt = f"Gere uma questão sobre {theme}, nível {difficulty}, com 4 alternativas (A, B, C, D), no estilo da USP."
|
17 |
response = medgemma(prompt, max_new_tokens=300, temperature=0.7, top_p=0.95)[0]['generated_text']
|
18 |
return {"question": response}
|
19 |
|
|
|
21 |
async def get_simulado(num_questions: int = 5):
|
22 |
simulado = []
|
23 |
for _ in range(num_questions):
|
24 |
+
prompt = "Gere uma questão médica estilo USP com 4 alternativas (A, B, C, D), nível médio."
|
25 |
question = medgemma(prompt, max_new_tokens=300)[0]['generated_text']
|
26 |
+
simulado.append({"question": question})
|
27 |
+
return {"simulado": simulado}
|