Spaces:
Running
Running
Create Exames.py
Browse files- pages/Exames.py +37 -0
pages/Exames.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import openai
|
3 |
+
import json
|
4 |
+
|
5 |
+
# Configurar a chave da API da OpenAI
|
6 |
+
openai.api_key = 'YOUR_OPENAI_API_KEY'
|
7 |
+
|
8 |
+
def summarize_exam(exam_text):
|
9 |
+
response = openai.Completion.create(
|
10 |
+
engine="gpt-4",
|
11 |
+
prompt=f"Resumo dos resultados dos exames: {exam_text}",
|
12 |
+
max_tokens=300,
|
13 |
+
temperature=0
|
14 |
+
)
|
15 |
+
return response.choices[0].text.strip()
|
16 |
+
|
17 |
+
def main():
|
18 |
+
st.title("Labs Resume")
|
19 |
+
st.write("Carregue um arquivo de exames laboratoriais e obtenha um resumo.")
|
20 |
+
|
21 |
+
uploaded_file = st.file_uploader("Escolha um arquivo", type=["txt", "pdf"])
|
22 |
+
|
23 |
+
if uploaded_file is not None:
|
24 |
+
# Ler o conteúdo do arquivo
|
25 |
+
content = uploaded_file.read().decode('utf-8')
|
26 |
+
|
27 |
+
# Processar e resumir o exame
|
28 |
+
st.write("Conteúdo do arquivo:")
|
29 |
+
st.write(content)
|
30 |
+
|
31 |
+
if st.button("Resumir Exame"):
|
32 |
+
resumo = summarize_exam(content)
|
33 |
+
st.write("Resumo do Exame:")
|
34 |
+
st.code(resumo)
|
35 |
+
|
36 |
+
if __name__ == "__main__":
|
37 |
+
main()
|