Spaces:
Runtime error
Runtime error
Commit ·
f3597fc
1
Parent(s): f0b6306
Versão Estável 13082025
Browse filesFiles changed (3)
- app.py+29-1
- static/style.css+13
- templates/index.html+43
295 unmodified lines296297298299300301302252 unmodified lines55555655755855956018 unmodified lines579580581582583584295 unmodified linesclaude_atomic_llm = claude_llm.bind(max_tokens=60000)#models = {'grok': grok_llm, 'sonnet': claude_atomic_llm, 'gemini': gemini_llm, 'openai': openai_llm}models = {'sonnet': claude_atomic_llm, 'gemini': gemini_llm, 'openai': openai_llm}# Substituir os placeholders no templateupdated_prompt_template = PROMPT_ATOMICO_INICIAL.replace(252 unmodified linesyield f"data: {json_data}\n\n"returnoutput_parser = StrOutputParser()# Atualizar o template de merge com os parâmetros de tamanho padrão18 unmodified linesclaude_with_max_tokens = claude_llm.bind(max_tokens=64000)chain_merge = prompt_merge | claude_with_max_tokens | output_parserjson_data = safe_json_dumps({'progress': 50, 'message': 'Enviando textos para o Claude Sonnet para consolidação...'})yield f"data: {json_data}\n\n"log_print("=== INVOCANDO CLAUDE SONNET PARA MERGE ===")295 unmodified lines296297298299300301302303304305306307308309310311312313314315252 unmodified lines56856957057157257357457557657757857958058158258358458558618 unmodified lines605606607608609610611612295 unmodified linesclaude_atomic_llm = claude_llm.bind(max_tokens=60000)#models = {'grok': grok_llm, 'sonnet': claude_atomic_llm, 'gemini': gemini_llm, 'openai': openai_llm}# Melhoria 05/08/2025 - Multi-modelomodels = {}if form_data.get('modelo-openai') == 'on':models['openai'] = openai_llmif form_data.get('modelo-sonnet') == 'on':models['sonnet'] = claude_atomic_llmif form_data.get('modelo-gemini') == 'on':models['gemini'] = gemini_llm# Verificação se pelo menos um modelo foi selecionadoif not models:json_data = safe_json_dumps({'error': 'Você deve selecionar pelo menos um modelo para processamento.'})yield f"data: {json_data}\n\n"return# Substituir os placeholders no templateupdated_prompt_template = PROMPT_ATOMICO_INICIAL.replace(252 unmodified linesyield f"data: {json_data}\n\n"return# Monta lista só com os textos que vieram no payloadavailable = []for campo in ('openai_text', 'sonnet_text', 'gemini_text'):txt = data.get(campo)if txt and txt.strip():available.append(txt)if len(available) < 2:json_data = safe_json_dumps({'error': 'Para processar o merge, deve haver pelo menos dois textos gerados.'})yield f"data: {json_data}\n\n"returnoutput_parser = StrOutputParser()# Atualizar o template de merge com os parâmetros de tamanho padrão18 unmodified linesclaude_with_max_tokens = claude_llm.bind(max_tokens=64000)chain_merge = prompt_merge | claude_with_max_tokens | output_parserjson_data = safe_json_dumps({'progress': 50, 'message': 'Enviando textos para o Claude Sonnet para consolidação...'})yield f"data: {json_data}\n\n"log_print("=== INVOCANDO CLAUDE SONNET PARA MERGE ===")
431 unmodified lines432433434435431 unmodified lines.text-contexto_usuario {color: #000;font-size: 14px;}431 unmodified lines432433434435436437438439440441442443444445446447448431 unmodified lines.text-contexto_usuario {color: #000;font-size: 14px;}/* Melhoria 05/08/2025 - Multi-modelo */#modelo-container {margin-top: 15px;padding: 10px;border: 1px solid #e0e0e0;border-radius: 5px;background-color: #f9f9f9;}#modelo-container label {margin-right: 10px;}
510 unmodified lines51151251351451551662 unmodified lines57958058158258358425 unmodified lines61061161261361461561661782 unmodified lines70070170270370470526 unmodified lines73273373473573673777 unmodified lines815816817818819820510 unmodified lines</div></div><button type="submit">Processar com IA</button></form></div>62 unmodified lines<script>// --- Variáveis Globais ---const processingModeSwitch = document.getElementById('processing-mode-switch');const modeSwitch = document.getElementById('mode-switch');const realContainer = document.getElementById('real-form-container');const mockContainer = document.getElementById('mock-form-container');25 unmodified linesmockContainer.style.display = this.checked ? 'block' : 'none';});processingModeSwitch.addEventListener('change', function() {const isAtomic = this.checked;document.getElementById('flow-description').textContent = isAtomic ?"OPEN AI | Claude Sonnet | Gemini (Paralelo)" :"OPEN AI ➔ Claude Sonnet ➔ Gemini";82 unmodified linesdocument.getElementById('request-form-mock').addEventListener('submit', handleFormSubmit);async function handleFormSubmit(event) {event.preventDefault();debugLog("=== FORM SUBMIT INICIADO ===");currentProcessingType = 'main';26 unmodified lines// Adicionar parâmetros de tamanhoformData.append('min_chars', document.getElementById('min_chars').value);formData.append('max_chars', document.getElementById('max_chars').value);if (modeSwitch.checked) {formData.append('mode', 'test');77 unmodified linesmergeBtn.addEventListener('click', async function() {debugLog("=== MERGE BUTTON CLICADO ===");currentProcessingType = 'merge';loaderMessage.textContent = 'Processando o merge dos textos...';progressBar.style.width = '0%';510 unmodified lines51151251351451551651751851952052152252352452552652752852962 unmodified lines59259359459559659759859960025 unmodified lines62662762862963063163263363463563663763863982 unmodified lines72272372472572672772826 unmodified lines75575675775875976076176276376476576676776876977077 unmodified lines848849850851852853854855856857858859860861862863510 unmodified lines</div></div><!-- Melhoria 05/08/2025 - Multi-modelo --><div id="modelo-container" style="display:none;"><label>Escolha os modelos:</label><div><input type="checkbox" id="modelo-openai" name="modelo-openai" checked><label for="modelo-openai">OpenAI</label><input type="checkbox" id="modelo-sonnet" name="modelo-sonnet" checked><label for="modelo-sonnet">Sonnet</label><input type="checkbox" id="modelo-gemini" name="modelo-gemini" checked><label for="modelo-gemini">Gemini</label></div></div><button type="submit">Processar com IA</button></form></div>62 unmodified lines<script>// --- Variáveis Globais ---const processingModeSwitch = document.getElementById('processing-mode-switch');// Melhoria 05/08/2025 - Multi-modeloconst modeloContainer = document.getElementById('modelo-container');modeloContainer.style.display = this.checked ? 'block' : 'none';const modeSwitch = document.getElementById('mode-switch');const realContainer = document.getElementById('real-form-container');const mockContainer = document.getElementById('mock-form-container');25 unmodified linesmockContainer.style.display = this.checked ? 'block' : 'none';});// Melhoria 05/08/2025 - Multi-modeloprocessingModeSwitch.addEventListener('change', function() {const isAtomic = this.checked;// Melhoria 05/08/2025 - Multi-modelo (Corrigido)const modeloContainer = document.getElementById('modelo-container');modeloContainer.style.display = isAtomic ? 'block' : 'none';document.getElementById('flow-description').textContent = isAtomic ?"OPEN AI | Claude Sonnet | Gemini (Paralelo)" :"OPEN AI ➔ Claude Sonnet ➔ Gemini";82 unmodified linesdocument.getElementById('request-form-mock').addEventListener('submit', handleFormSubmit);async function handleFormSubmit(event) {console.clear();event.preventDefault();debugLog("=== FORM SUBMIT INICIADO ===");currentProcessingType = 'main';26 unmodified lines// Adicionar parâmetros de tamanhoformData.append('min_chars', document.getElementById('min_chars').value);formData.append('max_chars', document.getElementById('max_chars').value);// Melhoria 05/08/2025 - Multi-modelo: envia os check-boxes ao servidorif (processingModeSwitch.checked) {['openai','sonnet','gemini'].forEach(m => {const id = `modelo-${m}`;if (document.getElementById(id).checked) {formData.append(id, 'on');}});}if (modeSwitch.checked) {formData.append('mode', 'test');77 unmodified linesmergeBtn.addEventListener('click', async function() {debugLog("=== MERGE BUTTON CLICADO ===");currentProcessingType = 'merge';// Melhoria 05/08/2025 - validação antes de chamar o servidorconst filled = ['openai-output','sonnet-output','gemini-output'].map(id => rawTexts[id]).filter(text => text && text.trim().length > 0).length;if (filled < 2) {showError('Para processar o merge, deve haver pelo menos dois textos gerados.');return;}loaderMessage.textContent = 'Processando o merge dos textos...';progressBar.style.width = '0%';
app.py+29-1
static/style.css+13
templates/index.html+43