Spaces:
Sleeping
Sleeping
Commit
·
d07c44d
1
Parent(s):
57d2d03
Evoluções Gerais
Browse files
app.py
CHANGED
@@ -243,10 +243,11 @@ def process():
|
|
243 |
claude_atomic_llm = claude_llm.bind(max_tokens=20000)
|
244 |
models = {'grok': grok_llm, 'sonnet': claude_atomic_llm, 'gemini': gemini_llm}
|
245 |
|
246 |
-
#
|
247 |
updated_prompt_template = PROMPT_ATOMICO_INICIAL.replace(
|
248 |
-
"
|
249 |
-
|
|
|
250 |
)
|
251 |
|
252 |
prompt = PromptTemplate(template=updated_prompt_template, input_variables=["solicitacao_usuario", "rag_context"])
|
@@ -308,16 +309,21 @@ def process():
|
|
308 |
|
309 |
# Atualizar prompts hierárquicos com parâmetros de tamanho
|
310 |
updated_grok_template = PROMPT_HIERARQUICO_GROK.replace(
|
311 |
-
"
|
312 |
-
|
|
|
313 |
)
|
|
|
314 |
updated_sonnet_template = PROMPT_HIERARQUICO_SONNET.replace(
|
315 |
-
"
|
316 |
-
|
|
|
317 |
)
|
|
|
318 |
updated_gemini_template = PROMPT_HIERARQUICO_GEMINI.replace(
|
319 |
-
"
|
320 |
-
|
|
|
321 |
)
|
322 |
|
323 |
json_data = safe_json_dumps({'progress': 15, 'message': 'O GROK está processando sua solicitação...'})
|
@@ -440,7 +446,15 @@ def merge():
|
|
440 |
return
|
441 |
|
442 |
output_parser = StrOutputParser()
|
443 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
444 |
|
445 |
# MUDANÇA: Usar Claude Sonnet para o merge
|
446 |
claude_with_max_tokens = claude_llm.bind(max_tokens=100000)
|
|
|
243 |
claude_atomic_llm = claude_llm.bind(max_tokens=20000)
|
244 |
models = {'grok': grok_llm, 'sonnet': claude_atomic_llm, 'gemini': gemini_llm}
|
245 |
|
246 |
+
# Substituir os placeholders no template
|
247 |
updated_prompt_template = PROMPT_ATOMICO_INICIAL.replace(
|
248 |
+
"MIN_CHARS_PLACEHOLDER", str(min_chars)
|
249 |
+
).replace(
|
250 |
+
"MAX_CHARS_PLACEHOLDER", str(max_chars)
|
251 |
)
|
252 |
|
253 |
prompt = PromptTemplate(template=updated_prompt_template, input_variables=["solicitacao_usuario", "rag_context"])
|
|
|
309 |
|
310 |
# Atualizar prompts hierárquicos com parâmetros de tamanho
|
311 |
updated_grok_template = PROMPT_HIERARQUICO_GROK.replace(
|
312 |
+
"MIN_CHARS_PLACEHOLDER", str(min_chars)
|
313 |
+
).replace(
|
314 |
+
"MAX_CHARS_PLACEHOLDER", str(max_chars)
|
315 |
)
|
316 |
+
|
317 |
updated_sonnet_template = PROMPT_HIERARQUICO_SONNET.replace(
|
318 |
+
"MIN_CHARS_PLACEHOLDER", str(min_chars)
|
319 |
+
).replace(
|
320 |
+
"MAX_CHARS_PLACEHOLDER", str(max_chars)
|
321 |
)
|
322 |
+
|
323 |
updated_gemini_template = PROMPT_HIERARQUICO_GEMINI.replace(
|
324 |
+
"MIN_CHARS_PLACEHOLDER", str(min_chars)
|
325 |
+
).replace(
|
326 |
+
"MAX_CHARS_PLACEHOLDER", str(max_chars)
|
327 |
)
|
328 |
|
329 |
json_data = safe_json_dumps({'progress': 15, 'message': 'O GROK está processando sua solicitação...'})
|
|
|
446 |
return
|
447 |
|
448 |
output_parser = StrOutputParser()
|
449 |
+
|
450 |
+
# Atualizar o template de merge com os parâmetros de tamanho padrão
|
451 |
+
updated_merge_template = PROMPT_ATOMICO_MERGE.replace(
|
452 |
+
"MIN_CHARS_PLACEHOLDER", "24000"
|
453 |
+
).replace(
|
454 |
+
"MAX_CHARS_PLACEHOLDER", "30000"
|
455 |
+
)
|
456 |
+
|
457 |
+
prompt_merge = PromptTemplate(template=updated_merge_template, input_variables=["solicitacao_usuario", "texto_para_analise_grok", "texto_para_analise_sonnet", "texto_para_analise_gemini"])
|
458 |
|
459 |
# MUDANÇA: Usar Claude Sonnet para o merge
|
460 |
claude_with_max_tokens = claude_llm.bind(max_tokens=100000)
|
config.py
CHANGED
@@ -10,8 +10,8 @@ PROMPT_HIERARQUICO_GROK = """
|
|
10 |
|
11 |
<requirements>
|
12 |
<caracters_count>
|
13 |
-
<minimum>
|
14 |
-
<maximum>
|
15 |
</caracters_count>
|
16 |
<language>Português do Brasil</language>
|
17 |
<paragraph_structure>Parágrafos curtos para facilitar a leitura</paragraph_structure>
|
@@ -47,8 +47,8 @@ PROMPT_HIERARQUICO_GROK = """
|
|
47 |
7. Evite usar um estilo de escrita muito característico de textos gerados com IA, como por exemplo: "Não é mera..., mas é...". Coisas assim. Seja mais direto.
|
48 |
8. Todo o texto, incluindo citações, devem estar na lingua Português do Brasil.
|
49 |
|
50 |
-
<forbidden>Que o texto tenha menos de
|
51 |
-
<forbidden>Que o texto tenha mais de
|
52 |
</instructions>
|
53 |
</prompt>
|
54 |
"""
|
@@ -64,8 +64,8 @@ PROMPT_HIERARQUICO_SONNET = """
|
|
64 |
|
65 |
<tamanhoDoTexto>
|
66 |
<caracteres>
|
67 |
-
<minimo>
|
68 |
-
<maximo>
|
69 |
</caracteres>
|
70 |
</tamanhoDoTexto>
|
71 |
|
@@ -89,8 +89,8 @@ PROMPT_HIERARQUICO_SONNET = """
|
|
89 |
<acao>corrigir problemas argumentativos</acao>
|
90 |
</correcoes>
|
91 |
|
92 |
-
<forbidden>Que o texto tenha menos de
|
93 |
-
<forbidden>Que o texto tenha mais de
|
94 |
|
95 |
</instrucoes>
|
96 |
|
@@ -127,8 +127,8 @@ PROMPT_HIERARQUICO_GEMINI = """
|
|
127 |
|
128 |
<tamanhoDoTexto>
|
129 |
<caracteres>
|
130 |
-
<minimo>
|
131 |
-
<maximo>
|
132 |
</caracteres>
|
133 |
</tamanhoDoTexto>
|
134 |
|
@@ -155,8 +155,8 @@ PROMPT_HIERARQUICO_GEMINI = """
|
|
155 |
<acao>corrigir problemas argumentativos</acao>
|
156 |
</correcoes>
|
157 |
|
158 |
-
<forbidden>Que o texto tenha menos de
|
159 |
-
<forbidden>Que o texto tenha mais de
|
160 |
|
161 |
</instrucoes>
|
162 |
|
@@ -192,8 +192,8 @@ PROMPT_ATOMICO_INICIAL = """
|
|
192 |
</role>
|
193 |
<requirements>
|
194 |
<caracters_count>
|
195 |
-
<minimum>
|
196 |
-
<maximum>
|
197 |
</caracters_count>
|
198 |
<language>Português do Brasil</language>
|
199 |
<paragraph_structure>Parágrafos curtos para facilitar a leitura</paragraph_structure>
|
@@ -226,8 +226,8 @@ PROMPT_ATOMICO_INICIAL = """
|
|
226 |
7. Evite usar um estilo de escrita muito característico de textos gerados com IA, como por exemplo: "Não é mera..., mas é...". Coisas assim. Seja mais direto.
|
227 |
8. Todo o texto, incluindo citações, devem estar na lingua Português do Brasil.
|
228 |
|
229 |
-
<forbidden>Que o texto tenha menos de
|
230 |
-
<forbidden>Que o texto tenha mais de
|
231 |
</instructions>
|
232 |
</prompt>
|
233 |
"""
|
@@ -266,8 +266,8 @@ PROMPT_ATOMICO_MERGE = """
|
|
266 |
</structure>
|
267 |
|
268 |
<caracters_count>
|
269 |
-
<minimum>
|
270 |
-
<maximum>
|
271 |
</caracters_count>
|
272 |
|
273 |
<analysis>
|
@@ -299,8 +299,8 @@ PROMPT_ATOMICO_MERGE = """
|
|
299 |
Verificar se todo o texto, incluindo citações, estão na lingua Português do Brasil. Traduza as que não estiverem.
|
300 |
</language>
|
301 |
|
302 |
-
<forbidden>Que o texto tenha menos de
|
303 |
-
<forbidden>Que o texto tenha mais de
|
304 |
</instructions>
|
305 |
|
306 |
<output>
|
|
|
10 |
|
11 |
<requirements>
|
12 |
<caracters_count>
|
13 |
+
<minimum>MIN_CHARS_PLACEHOLDER</minimum>
|
14 |
+
<maximum>MAX_CHARS_PLACEHOLDER</maximum>
|
15 |
</caracters_count>
|
16 |
<language>Português do Brasil</language>
|
17 |
<paragraph_structure>Parágrafos curtos para facilitar a leitura</paragraph_structure>
|
|
|
47 |
7. Evite usar um estilo de escrita muito característico de textos gerados com IA, como por exemplo: "Não é mera..., mas é...". Coisas assim. Seja mais direto.
|
48 |
8. Todo o texto, incluindo citações, devem estar na lingua Português do Brasil.
|
49 |
|
50 |
+
<forbidden>Que o texto tenha menos de MIN_CHARS_PLACEHOLDER caracteres.</forbidden>
|
51 |
+
<forbidden>Que o texto tenha mais de MAX_CHARS_PLACEHOLDER caracteres.</forbidden>
|
52 |
</instructions>
|
53 |
</prompt>
|
54 |
"""
|
|
|
64 |
|
65 |
<tamanhoDoTexto>
|
66 |
<caracteres>
|
67 |
+
<minimo>MIN_CHARS_PLACEHOLDER</minimo>
|
68 |
+
<maximo>MAX_CHARS_PLACEHOLDER</maximo>
|
69 |
</caracteres>
|
70 |
</tamanhoDoTexto>
|
71 |
|
|
|
89 |
<acao>corrigir problemas argumentativos</acao>
|
90 |
</correcoes>
|
91 |
|
92 |
+
<forbidden>Que o texto tenha menos de MIN_CHARS_PLACEHOLDER caracteres.</forbidden>
|
93 |
+
<forbidden>Que o texto tenha mais de MAX_CHARS_PLACEHOLDER caracteres.</forbidden>
|
94 |
|
95 |
</instrucoes>
|
96 |
|
|
|
127 |
|
128 |
<tamanhoDoTexto>
|
129 |
<caracteres>
|
130 |
+
<minimo>MIN_CHARS_PLACEHOLDER</minimo>
|
131 |
+
<maximo>MAX_CHARS_PLACEHOLDER</maximo>
|
132 |
</caracteres>
|
133 |
</tamanhoDoTexto>
|
134 |
|
|
|
155 |
<acao>corrigir problemas argumentativos</acao>
|
156 |
</correcoes>
|
157 |
|
158 |
+
<forbidden>Que o texto tenha menos de MIN_CHARS_PLACEHOLDER caracteres.</forbidden>
|
159 |
+
<forbidden>Que o texto tenha mais de MAX_CHARS_PLACEHOLDER caracteres.</forbidden>
|
160 |
|
161 |
</instrucoes>
|
162 |
|
|
|
192 |
</role>
|
193 |
<requirements>
|
194 |
<caracters_count>
|
195 |
+
<minimum>MIN_CHARS_PLACEHOLDER</minimum>
|
196 |
+
<maximum>MAX_CHARS_PLACEHOLDER</maximum>
|
197 |
</caracters_count>
|
198 |
<language>Português do Brasil</language>
|
199 |
<paragraph_structure>Parágrafos curtos para facilitar a leitura</paragraph_structure>
|
|
|
226 |
7. Evite usar um estilo de escrita muito característico de textos gerados com IA, como por exemplo: "Não é mera..., mas é...". Coisas assim. Seja mais direto.
|
227 |
8. Todo o texto, incluindo citações, devem estar na lingua Português do Brasil.
|
228 |
|
229 |
+
<forbidden>Que o texto tenha menos de MIN_CHARS_PLACEHOLDER caracteres.</forbidden>
|
230 |
+
<forbidden>Que o texto tenha mais de MAX_CHARS_PLACEHOLDER caracteres.</forbidden>
|
231 |
</instructions>
|
232 |
</prompt>
|
233 |
"""
|
|
|
266 |
</structure>
|
267 |
|
268 |
<caracters_count>
|
269 |
+
<minimum>MIN_CHARS_PLACEHOLDER</minimum>
|
270 |
+
<maximum>MAX_CHARS_PLACEHOLDER</maximum>
|
271 |
</caracters_count>
|
272 |
|
273 |
<analysis>
|
|
|
299 |
Verificar se todo o texto, incluindo citações, estão na lingua Português do Brasil. Traduza as que não estiverem.
|
300 |
</language>
|
301 |
|
302 |
+
<forbidden>Que o texto tenha menos de MIN_CHARS_PLACEHOLDER caracteres.</forbidden>
|
303 |
+
<forbidden>Que o texto tenha mais de MAX_CHARS_PLACEHOLDER caracteres.</forbidden>
|
304 |
</instructions>
|
305 |
|
306 |
<output>
|