Spaces:
Sleeping
Sleeping
D Ф m i И i q ц e L Ф y e r commited on
Commit ·
3f5e84d
1
Parent(s): fdaeab5
Fix: API URL detection & add missing NER/EEAT data
Browse filesFiles changed (2)
926 unmodified lines9279289299309319329319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609613 unmodified lines9659669679429689699709714 unmodified lines976977978953979980981982926 unmodified lines
<script> // Backend URLs // Empty string means relative path (same domain), which works for HF Space const REMOTE_API_URL = ''; const LOCAL_API_URL = 'http://localhost:5001'; const REMOTE_API_URL = 'https://domloyer-syscred.hf.space'; let API_URL = ''; // Detect if we are already on localhost const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'; let API_URL = isLocalhost ? LOCAL_API_URL : REMOTE_API_URL; // Set initial toggle state based on environment document.addEventListener('DOMContentLoaded', () => { const toggle = document.getElementById('backendToggle'); const status = document.getElementById('backendStatus'); const labelLocal = document.getElementById('labelLocal'); const labelRemote = document.getElementById('labelRemote'); if (isLocalhost) { toggle.checked = false; status.textContent = 'Backend: localhost:5001 (léger, sans ML)'; status.className = 'backend-status local'; labelLocal.classList.add('active'); labelRemote.classList.remove('active'); } else { toggle.checked = true; status.textContent = 'Backend: HF Space (ML complet)'; status.className = 'backend-status remote'; labelLocal.classList.remove('active'); labelRemote.classList.add('active'); } }); function toggleBackend() { const toggle = document.getElementById('backendToggle');3 unmodified lines if (toggle.checked) { API_URL = REMOTE_API_URL; status.textContent = 'Backend: HF Space (ML complet, plus lent)'; status.textContent = 'Backend: HF Space (ML complet)'; status.className = 'backend-status remote'; labelLocal.classList.remove('active'); labelRemote.classList.add('active');4 unmodified lines labelLocal.classList.add('active'); labelRemote.classList.remove('active'); } console.log('[SysCRED] Backend switched to:', API_URL); console.log('[SysCRED] Backend switched to:', API_URL || 'Relative Path (HF Space)'); }
async function analyzeUrl() {337 unmodified lines338339340341342343344345346347348349350351352353354355356357358399 unmodified lines7587597607467617627637643 unmodified lines768769770771772773774775776777778779780781782783337 unmodified lines # 4. Semantic Coherence results['coherence_score'] = self._calculate_coherence(text)
# 5. [NEW] E-E-A-T Score Calculation if HAS_EEAT: try: # Initialize calc if needed (lazy load) if not hasattr(self, 'eeat_calculator') or self.eeat_calculator is None: self.eeat_calculator = EEATCalculator() # Calculate score eeat = self.eeat_calculator.calculate_eeat(text, results.get('named_entities', [])) # Store in results as dict results['eeat_score'] = eeat.to_dict() print(f"[NLP] EEAT Score calculated: {eeat.overall_score:.2f}") except Exception as e: print(f"[NLP] EEAT error: {e}") return results
399 unmodified lines }) report['sourcesUtilisees'].append({ 'type': 'Fact Check API', 'results_count': len(external_data.fact_checks) 'results_count': len(external_data.fact_checks) if external_data.fact_checks else 0 }) # [NEW] Add TREC evidence source if evidences:3 unmodified lines 'corpus': 'AP88-90', 'results_count': len(evidences) }) # [FIX] Add explicit fields for frontend if nlp_results.get('named_entities'): report['ner_entities'] = nlp_results.get('named_entities') # Add EEAT score if available (from rule_results or nlp_results) if 'eeat_score' in rule_results: report['eeat_score'] = rule_results['eeat_score'] elif 'eeat_score' in nlp_results: report['eeat_score'] = nlp_results['eeat_score'] return report syscred/static/index.html+30-4
syscred/verification_system.py+26-1