provider_test.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. cd "$(dirname "$0")"
  4. if [ -f ".venv/bin/activate" ]; then
  5. # shellcheck disable=SC1091
  6. source .venv/bin/activate
  7. fi
  8. export PYTHONPATH="$(pwd):${PYTHONPATH:-}"
  9. python - <<'PY'
  10. import asyncio
  11. import json
  12. from news_mcp.config import NEWS_EXTRACT_PROVIDER, NEWS_EXTRACT_MODEL, NEWS_SUMMARY_PROVIDER, NEWS_SUMMARY_MODEL
  13. from news_mcp.llm import active_llm_config
  14. from news_mcp.enrichment.llm_enrich import classify_cluster_llm
  15. SAMPLE_CLUSTER = {
  16. "cluster_id": "provider-test",
  17. "headline": "Test headline for provider verification",
  18. "summary": "This is a tiny sample cluster used to verify provider, model, and key configuration.",
  19. "topic": "other",
  20. "entities": [],
  21. "sentiment": "neutral",
  22. "importance": 0.0,
  23. "sources": ["provider_test.sh"],
  24. "timestamp": "2026-05-22T00:00:00+00:00",
  25. "articles": [
  26. {
  27. "title": "Test headline for provider verification",
  28. "url": "https://example.com/provider-test",
  29. "source": "provider_test.sh",
  30. "timestamp": "2026-05-22T00:00:00+00:00",
  31. "summary": "This is a tiny sample cluster used to verify provider, model, and key configuration.",
  32. }
  33. ],
  34. }
  35. async def main() -> None:
  36. print(json.dumps(active_llm_config(), indent=2, sort_keys=True))
  37. print()
  38. print("extract_provider=", NEWS_EXTRACT_PROVIDER)
  39. print("extract_model=", NEWS_EXTRACT_MODEL)
  40. print("summary_provider=", NEWS_SUMMARY_PROVIDER)
  41. print("summary_model=", NEWS_SUMMARY_MODEL)
  42. print()
  43. result = await classify_cluster_llm(dict(SAMPLE_CLUSTER))
  44. print(json.dumps(result, indent=2, sort_keys=True, ensure_ascii=False))
  45. asyncio.run(main())
  46. PY