ScavioScavio
产品定价文档
登录开始使用
  1. 首页
  2. 教程
  3. 如何通过搜索验证人工智能生成的品牌提及
教程

如何通过搜索验证人工智能生成的品牌提及

根据实时搜索数据验证人工智能生成的品牌声明、定价和功能列表。在幻觉到达用户之前捕捉到它们。

获取免费API密钥API文档

人工智能模型经常伪造品牌细节:错误的定价、发明的功能、混乱的产品线和过时的信息。在发布人工智能生成的品牌内容之前,您需要一个验证层来根据实时数据检查声明。本教程构建了一个自动品牌提及验证器,可以搜索 Google 和 Amazon,以每张检查 0.005 美元的价格验证或标记 AI 生成的声明。

前置条件

  • 已安装 Python 3.9+
  • 请求已安装库
  • 来自 scavio.dev 的 Scavio API 密钥
  • AI 生成的内容进行验证

操作指南

步骤 1: 从人工智能生成的文本中提取品牌主张

解析人工智能生成的内容,以查找需要验证的品牌名称、定价声明、功能声明和比较声明。

Python
import os, re, requests

SCAVIO_KEY = os.environ['SCAVIO_API_KEY']
H = {'x-api-key': SCAVIO_KEY, 'Content-Type': 'application/json'}

def extract_claims(text: str) -> list:
    """Extract verifiable claims from AI-generated text."""
    claims = []
    # Pricing claims: "costs $X", "$X/month", "starts at $X"
    for m in re.finditer(r'(\w[\w\s]+?)\s+(?:costs?|priced? at|starts? at|for)\s+(\$[\d,.]+(?:/\w+)?)', text):
        claims.append({'type': 'pricing', 'brand': m.group(1).strip(), 'claim': m.group(2)})
    # Feature claims: "X offers Y", "X includes Y", "X supports Y"
    for m in re.finditer(r'(\w[\w\s]+?)\s+(?:offers?|includes?|supports?|provides?|features?)\s+(.+?)[\.!,]', text):
        claims.append({'type': 'feature', 'brand': m.group(1).strip(), 'claim': m.group(2).strip()})
    # Comparison claims: "X is better than Y", "X outperforms Y"
    for m in re.finditer(r'(\w+)\s+(?:is better than|outperforms|beats|surpasses)\s+(\w+)', text):
        claims.append({'type': 'comparison', 'brand': m.group(1), 'claim': f'better than {m.group(2)}'})
    return claims

# Example AI-generated text
ai_text = """Notion costs $10/month for the Pro plan and offers real-time collaboration.
Obsidian starts at $50/year for commercial use and supports plugin extensions.
Notion is better than Obsidian for team collaboration."""

claims = extract_claims(ai_text)
for c in claims:
    print(f'[{c["type"]}] {c["brand"]}: {c["claim"]}')

步骤 2: 根据实时搜索数据验证声明

搜索每个声明并检查搜索结果是否证实或矛盾它。由于确切的数字很重要,定价声明会得到特殊处理。

Python
import time

def verify_claim(claim: dict) -> dict:
    """Verify a single claim against search data."""
    brand = claim['brand']
    claim_text = claim['claim']
    # Build verification query
    if claim['type'] == 'pricing':
        query = f'{brand} pricing plans 2026'
    elif claim['type'] == 'feature':
        query = f'{brand} {claim_text}'
    else:
        query = f'{brand} vs {claim_text.replace("better than ", "")}'
    resp = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
        json={'query': query, 'country_code': 'us', 'num_results': 5})
    results = resp.json().get('organic_results', [])
    all_text = ' '.join(f"{r.get('title','')} {r.get('snippet','')}" for r in results).lower()
    # Check verification
    if claim['type'] == 'pricing':
        price_val = re.search(r'\$([\d,.]+)', claim_text)
        if price_val:
            found = price_val.group(1) in all_text or price_val.group(0) in all_text
            return {**claim, 'verified': found,
                    'status': 'VERIFIED' if found else 'UNVERIFIED',
                    'evidence': all_text[:200]}
    elif claim['type'] == 'feature':
        key_terms = [w for w in claim_text.lower().split() if len(w) > 3]
        matches = sum(1 for t in key_terms if t in all_text)
        coverage = matches / len(key_terms) if key_terms else 0
        return {**claim, 'verified': coverage > 0.5,
                'status': 'VERIFIED' if coverage > 0.5 else 'UNVERIFIED',
                'evidence': all_text[:200]}
    return {**claim, 'verified': False, 'status': 'CHECK MANUALLY', 'evidence': all_text[:200]}

for claim in claims:
    result = verify_claim(claim)
    print(f'[{result["status"]}] {result["brand"]}: {result["claim"]}')
    time.sleep(0.3)

步骤 3: 构建验证报告

生成一份报告,显示哪些声明已验证、未验证或需要手动审核。标记包含太多未经验证的声明的内容。

Python
def validate_content(text: str) -> dict:
    claims = extract_claims(text)
    if not claims:
        return {'status': 'NO_CLAIMS', 'message': 'No verifiable claims found'}
    results = []
    for claim in claims:
        result = verify_claim(claim)
        results.append(result)
        time.sleep(0.3)
    verified = sum(1 for r in results if r['status'] == 'VERIFIED')
    unverified = sum(1 for r in results if r['status'] == 'UNVERIFIED')
    manual = sum(1 for r in results if r['status'] == 'CHECK MANUALLY')
    total = len(results)
    accuracy = verified / total if total else 0
    if accuracy >= 0.8:
        overall = 'PASS'
    elif accuracy >= 0.5:
        overall = 'REVIEW'
    else:
        overall = 'FAIL'
    report = {
        'overall': overall,
        'accuracy': accuracy,
        'verified': verified,
        'unverified': unverified,
        'manual_check': manual,
        'total_claims': total,
        'results': results,
        'cost': total * 0.005,
    }
    print(f'Content Validation: {overall}')
    print(f'Claims: {verified} verified, {unverified} unverified, {manual} manual check')
    print(f'Accuracy: {accuracy:.0%}')
    print(f'Cost: ${report["cost"]:.3f}')
    for r in results:
        icon = 'v' if r['status'] == 'VERIFIED' else 'x' if r['status'] == 'UNVERIFIED' else '?'
        print(f'  [{icon}] {r["brand"]}: {r["claim"]}')
    return report

validate_content(ai_text)

步骤 4: 集成到内容发布管道中

添加验证器作为发布前检查。包含太多未经验证的声明的内容在上线之前会被标记为需要人工审核。

Python
def pre_publish_check(content: str, min_accuracy: float = 0.7) -> dict:
    """Run before publishing AI-generated content."""
    report = validate_content(content)
    if report.get('status') == 'NO_CLAIMS':
        return {'action': 'PUBLISH', 'reason': 'No brand claims to verify'}
    if report['accuracy'] >= min_accuracy:
        return {
            'action': 'PUBLISH',
            'reason': f'{report["accuracy"]:.0%} accuracy meets threshold',
            'warnings': [r for r in report['results'] if r['status'] != 'VERIFIED']
        }
    return {
        'action': 'HOLD',
        'reason': f'{report["accuracy"]:.0%} accuracy below {min_accuracy:.0%} threshold',
        'unverified_claims': [r for r in report['results'] if r['status'] != 'VERIFIED'],
        'suggestion': 'Review and correct unverified claims before publishing'
    }

# Test the pipeline
result = pre_publish_check(ai_text)
print(f'\nAction: {result["action"]}')
print(f'Reason: {result["reason"]}')
if result.get('warnings'):
    print('Warnings:')
    for w in result['warnings']:
        print(f'  - {w["brand"]}: {w["claim"]} ({w["status"]})')

Python 示例

Python
import os, re, requests, time

SCAVIO_KEY = os.environ['SCAVIO_API_KEY']
H = {'x-api-key': SCAVIO_KEY, 'Content-Type': 'application/json'}

def verify_brand_claim(brand, claim):
    resp = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
        json={'query': f'{brand} {claim}', 'country_code': 'us', 'num_results': 5})
    text = ' '.join(r.get('snippet','') for r in resp.json().get('organic_results', [])).lower()
    terms = [w for w in claim.lower().split() if len(w) > 3]
    matches = sum(1 for t in terms if t in text)
    verified = matches / len(terms) > 0.5 if terms else False
    return {'brand': brand, 'claim': claim, 'verified': verified}

claims = [('Notion', 'real-time collaboration'), ('Obsidian', 'plugin extensions')]
for brand, claim in claims:
    r = verify_brand_claim(brand, claim)
    print(f"{'VERIFIED' if r['verified'] else 'UNVERIFIED'}: {r['brand']} - {r['claim']}")
    time.sleep(0.3)

JavaScript 示例

JavaScript
const SCAVIO_KEY = process.env.SCAVIO_API_KEY;

async function verifyBrandClaim(brand, claim) {
  const resp = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST',
    headers: { 'x-api-key': SCAVIO_KEY, 'Content-Type': 'application/json' },
    body: JSON.stringify({ query: `${brand} ${claim}`, country_code: 'us', num_results: 5 })
  });
  const text = ((await resp.json()).organic_results || []).map(r => r.snippet || '').join(' ').toLowerCase();
  const terms = claim.toLowerCase().split(' ').filter(w => w.length > 3);
  const matches = terms.filter(t => text.includes(t)).length;
  const verified = terms.length > 0 && matches / terms.length > 0.5;
  console.log(`${verified ? 'VERIFIED' : 'UNVERIFIED'}: ${brand} - ${claim}`);
}

verifyBrandClaim('Notion', 'real-time collaboration');

预期输出

JSON
Content Validation: REVIEW
Claims: 2 verified, 1 unverified, 0 manual check
Accuracy: 67%
Cost: $0.015
  [v] Notion: real-time collaboration
  [x] Obsidian: $50/year (pricing may have changed)
  [v] Notion: better than Obsidian for team collaboration

Action: HOLD
Reason: 67% accuracy below 70% threshold

相关教程

  • 如何利用实时数据进行法学硕士品牌研究
  • 如何监控 Google 和 YouTube 上的品牌提及
  • 如何以编程方式验证 AI 搜索结果
  • 如何对搜索 API 进行 RAG 质量基准测试

常见问题

大多数开发者在15到30分钟内完成本教程。您需要一个Scavio API密钥(免费套餐即可)和可用的Python或JavaScript环境。

已安装 Python 3.9+. 请求已安装库. 来自 scavio.dev 的 Scavio API 密钥. AI 生成的内容进行验证. Scavio API密钥注册即送50个免费积分。

可以。免费套餐注册即送50个积分,完全足够完成本教程并构建一个可运行的原型解决方案。

Scavio提供原生LangChain包(langchain-scavio)、MCP服务器以及适用于任何HTTP客户端的REST API。本教程使用 the raw REST API, 但您可以根据需要适配您选择的框架。

相关资源

Best Of

Google I/O 2026 AI模式变化后最佳搜索API

Read more
Glossary

搜索 API 供应商格局(2026)

Read more
Best Of

2026年最佳单API大模型Wiki构建工具

Read more
Glossary

免费搜索API层级对比

Read more
Comparison

Search APIs (Scavio, Tavily, SerpAPI) vs Headless Browser (Playwright, Puppeteer, Browserbase)

Read more
Comparison

Google Places API vs SERP Local Pack API

Read more

开始构建

根据实时搜索数据验证人工智能生成的品牌声明、定价和功能列表。在幻觉到达用户之前捕捉到它们。

获取免费API密钥阅读文档
ScavioScavio

面向AI智能体的实时搜索API。搜索所有平台,不仅仅是Google。

产品

  • 功能
  • 定价
  • 控制台
  • 联盟计划

开发者

  • 文档
  • API参考
  • 快速开始
  • MCP集成
  • Python SDK

替代方案

  • Tavily替代方案
  • SerpAPI替代方案
  • Firecrawl替代方案
  • Exa替代方案

工具

  • JSON格式化
  • cURL转代码
  • Token计数器
  • 全部工具

© 2026 Scavio. 保留所有权利。

Featured on TAAFT
服务条款隐私政策