check_dify_config.py 872 B

12345678910111213141516171819
  1. """Verify Dify KB configuration"""
  2. import requests, json
  3. api_key = 'dataset-xsT85hlYqhXcudorohrokWGo'
  4. base_url = 'http://dify.bianwoyou.cn'
  5. dataset_id = '3ff939b3-8686-44f6-8ef5-65b1e53b55d3'
  6. headers = {'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json'}
  7. resp = requests.get(f'{base_url}/v1/datasets/{dataset_id}', headers=headers, timeout=15)
  8. info = resp.json()
  9. rm = info.get('retrieval_model_dict', {})
  10. print(f'KB Name: {info.get("name")}')
  11. print(f'Documents: {info.get("document_count")}')
  12. print(f'Words: {info.get("word_count", "?")}')
  13. print(f'Search: {rm.get("search_method")}')
  14. print(f'Top-K: {rm.get("top_k")}')
  15. print(f'Rerank: enabled={rm.get("reranking_enable")} model={rm.get("reranking_model", {}).get("reranking_model_name", "null")}')
  16. print(f'Threshold: enabled={rm.get("score_threshold_enabled")} value={rm.get("score_threshold")}')