GabrielGD commited on
Commit
ff2e19e
·
verified ·
1 Parent(s): 61e7777

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -22
app.py CHANGED
@@ -2,7 +2,6 @@ import os
2
  import io
3
  import re
4
  import json
5
- import random
6
  import streamlit as st
7
  from docx import Document
8
  from docx.shared import Cm, Pt, RGBColor
@@ -102,25 +101,11 @@ class RelatorioDiagnostico(BaseModel):
102
  # =====================================================
103
  class RevisorIA:
104
  def __init__(self):
105
- # Tenta buscar a lista de chaves (plural) no secrets
106
- api_keys = st.secrets.get("GEMINI_API_KEYS")
107
-
108
- # Fallback de segurança caso só exista uma chave configurada (singular)
109
- if not api_keys:
110
- single_key = st.secrets.get("GEMINI_API_KEY") or os.environ.get("GEMINI_API_KEY")
111
- if single_key:
112
- api_keys = [single_key]
113
- elif isinstance(api_keys, str):
114
- # Caso o usuário tenha salvo as chaves como uma única string separada por vírgulas
115
- api_keys = [k.strip() for k in api_keys.split(",")]
116
-
117
- if not api_keys:
118
- st.error("❌ ERRO: Nenhuma chave GEMINI configurada nos secrets.")
119
  st.stop()
120
-
121
- # O Load Balancer: Escolhe uma chave aleatória da lista a cada execução/clique
122
- chave_escolhida = random.choice(api_keys)
123
- self.client = genai.Client(api_key=chave_escolhida)
124
 
125
  def auditar_tcc(self, texto_projeto: str, texto_tcc: str, fase_tcc: str) -> Optional[AuditoriaTCC]:
126
  regra_fase = (
@@ -159,7 +144,7 @@ class RevisorIA:
159
  )
160
  try:
161
  res = self.client.models.generate_content(
162
- model="gemini-3.1-flash",
163
  contents=prompt,
164
  config=types.GenerateContentConfig(
165
  temperature=0.1,
@@ -184,7 +169,7 @@ class RevisorIA:
184
  )
185
  try:
186
  res = self.client.models.generate_content(
187
- model="gemini-3.1-flash",
188
  contents=prompt,
189
  config=types.GenerateContentConfig(
190
  temperature=0.0,
@@ -1394,7 +1379,7 @@ with aba_feedback:
1394
  )
1395
  try:
1396
  res = revisor_ia.client.models.generate_content(
1397
- model="gemini-3.1-flash",
1398
  contents=prompt_fb,
1399
  config=types.GenerateContentConfig(temperature=0.2)
1400
  )
 
2
  import io
3
  import re
4
  import json
 
5
  import streamlit as st
6
  from docx import Document
7
  from docx.shared import Cm, Pt, RGBColor
 
101
  # =====================================================
102
  class RevisorIA:
103
  def __init__(self):
104
+ api_key = st.secrets.get("GEMINI_API_KEY") or os.environ.get("GEMINI_API_KEY")
105
+ if not api_key:
106
+ st.error("❌ ERRO: Chave GEMINI_API_KEY não configurada nos secrets.")
 
 
 
 
 
 
 
 
 
 
 
107
  st.stop()
108
+ self.client = genai.Client(api_key=api_key)
 
 
 
109
 
110
  def auditar_tcc(self, texto_projeto: str, texto_tcc: str, fase_tcc: str) -> Optional[AuditoriaTCC]:
111
  regra_fase = (
 
144
  )
145
  try:
146
  res = self.client.models.generate_content(
147
+ model="gemini-3.5-flash",
148
  contents=prompt,
149
  config=types.GenerateContentConfig(
150
  temperature=0.1,
 
169
  )
170
  try:
171
  res = self.client.models.generate_content(
172
+ model="gemini-3.5-flash",
173
  contents=prompt,
174
  config=types.GenerateContentConfig(
175
  temperature=0.0,
 
1379
  )
1380
  try:
1381
  res = revisor_ia.client.models.generate_content(
1382
+ model="gemini-3.5-flash",
1383
  contents=prompt_fb,
1384
  config=types.GenerateContentConfig(temperature=0.2)
1385
  )