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 lines9279289299309319329339349353 unmodified lines9399409419429439449454 unmodified lines950951952953954955956926 unmodified lines<script>// Backend URLsconst LOCAL_API_URL = 'http://localhost:5001';const REMOTE_API_URL = 'https://domloyer-syscred.hf.space';let API_URL = '';function toggleBackend() {const toggle = document.getElementById('backendToggle');3 unmodified linesif (toggle.checked) {API_URL = REMOTE_API_URL;status.textContent = 'Backend: HF Space (ML complet, plus lent)';status.className = 'backend-status remote';labelLocal.classList.remove('active');labelRemote.classList.add('active');4 unmodified lineslabelLocal.classList.add('active');labelRemote.classList.remove('active');}console.log('[SysCRED] Backend switched to:', API_URL);}async function analyzeUrl() {926 unmodified lines9279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609613 unmodified lines9659669679689699709714 unmodified lines976977978979980981982926 unmodified lines<script>// Backend URLs// Empty string means relative path (same domain), which works for HF Spaceconst REMOTE_API_URL = '';const LOCAL_API_URL = 'http://localhost:5001';// Detect if we are already on localhostconst 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 environmentdocument.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 linesif (toggle.checked) {API_URL = REMOTE_API_URL;status.textContent = 'Backend: HF Space (ML complet)';status.className = 'backend-status remote';labelLocal.classList.remove('active');labelRemote.classList.add('active');4 unmodified lineslabelLocal.classList.add('active');labelRemote.classList.remove('active');}console.log('[SysCRED] Backend switched to:', API_URL || 'Relative Path (HF Space)');}async function analyzeUrl() {
337 unmodified lines338339340341342343399 unmodified lines7437447457467477487493 unmodified lines753754755756757758337 unmodified lines# 4. Semantic Coherenceresults['coherence_score'] = self._calculate_coherence(text)return results399 unmodified lines})report['sourcesUtilisees'].append({'type': 'Fact Check API','results_count': len(external_data.fact_checks)})# [NEW] Add TREC evidence sourceif evidences:3 unmodified lines'corpus': 'AP88-90','results_count': len(evidences)})return report337 unmodified lines338339340341342343344345346347348349350351352353354355356357358399 unmodified lines7587597607617627637643 unmodified lines768769770771772773774775776777778779780781782783337 unmodified lines# 4. Semantic Coherenceresults['coherence_score'] = self._calculate_coherence(text)# 5. [NEW] E-E-A-T Score Calculationif 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 scoreeeat = self.eeat_calculator.calculate_eeat(text, results.get('named_entities', []))# Store in results as dictresults['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 results399 unmodified lines})report['sourcesUtilisees'].append({'type': 'Fact Check API','results_count': len(external_data.fact_checks) if external_data.fact_checks else 0})# [NEW] Add TREC evidence sourceif evidences:3 unmodified lines'corpus': 'AP88-90','results_count': len(evidences)})# [FIX] Add explicit fields for frontendif 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