这是一个模型上下文协议(MCP)服务器,通过与知识来源(如Wikidata)进行对比来验证简单的事实声明。
{
"version": "1.0",
"context": {
"type": "fact_check",
"claim": "法国的首都是伦敦",
"correct_answer": "不正确。法国的首都是巴黎,而不是伦敦。",
"confidence": 0.95
}
}
pip install -r requirements.txt
python app.py
向/fact-check端点发送POST请求,并在JSON负载中包含声明:
curl -X POST http://localhost:5000/fact-check \
-H "Content-Type: application/json" \
-d '{"claim": "法国的首都是伦敦"}'
项目中包含一个演示如何与Ollama LLM集成的MCP客户端:
确保已安装并运行Ollama:
ollama serve
运行演示脚本:
bash run_demo.sh
或者直接运行客户端:
python mcp_client.py --model llama3
客户端将:
使用特定声明运行测试客户端:
python test_client.py "法国的首都是巴黎"
或者运行默认的多声明测试套件:
python test_client.py
运行包含正确和错误声明的综合测试套件:
python test_client.py --test-suite
运行单元测试以验证服务器的功能:
python -m unittest test_unit.py
目前,服务器可以验证:
未来更新将添加更多类型的声明支持。
要添加对新类型声明的支持:
check_fact()函数中添加一个新的模式匹配正则表达式check_capital_claim()的相应验证函数© Anthony Lim