403Webshell
Server IP : 3.147.158.171  /  Your IP : 216.73.216.88
Web Server : Apache/2.4.67 (Amazon Linux) OpenSSL/3.5.5
System : Linux ip-172-31-2-178.us-east-2.compute.internal 6.1.172-216.329.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Wed May 20 06:31:34 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.21
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /tsai/www/html/api.turmansolutions.ai/app/utilities/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /tsai/www/html/api.turmansolutions.ai/app/utilities/fact_check.py
"""The fact-check / corrections comment contract.

Fact-check and corrections comments are posted to WordPress as guest comments
whose *author name* encodes which model produced them, e.g.
``Fact-Check (via OpenAI gpt-5.5)``. That name is the only marker identifying
them: corrections look up their parent fact-check by matching the author-name
prefix, and comment scoring excludes them the same way.

The format therefore has to agree in every place that writes or reads it. It
previously lived as separate literals in the article-creation service, the
comment agent, and improve_article.py; this module is the single definition.
"""

from typing import Any, Dict, Iterable, Optional

# Author-name prefixes, lowercased for case-insensitive matching.
FACT_CHECK_AUTHOR_PREFIX = 'fact-check (via '
CORRECTIONS_AUTHOR_PREFIX = 'corrections (via '


def fact_check_author_name(provider_name: str, model_name: str) -> str:
    """The author name to post a fact-check comment under."""
    return f"Fact-Check (via {provider_name} {model_name})"


def corrections_author_name(provider_name: str, model_name: str) -> str:
    """The author name to post a corrections comment under."""
    return f"Corrections (via {provider_name} {model_name})"


def is_fact_check_comment(comment: Dict[str, Any]) -> bool:
    """True when a WordPress comment dict is a fact-check comment."""
    return (comment.get('author_name') or '').lower().startswith(FACT_CHECK_AUTHOR_PREFIX)


def find_fact_check_comment(comments: Optional[Iterable[Dict[str, Any]]]) -> Optional[Dict[str, Any]]:
    """Return the first fact-check comment in a list of WP comments, or None."""
    for comment in comments or []:
        if is_fact_check_comment(comment):
            return comment
    return None

Youez - 2016 - github.com/yon3zu
LinuXploit