test_embedding.py 505 B

1234567891011121314151617181920
  1. import httpx
  2. import requests
  3. import json
  4. TEST_URL = "http://localhost:8501/api/embedding"
  5. TEST_HEADERS = {
  6. "Content-Type": "application/json; charset=utf-8"
  7. }
  8. TEST_DATA={"action":"embedding", "data": [{"text":"世界"}]}
  9. print(json.dumps(TEST_DATA))
  10. def test():
  11. try:
  12. response = requests.post(TEST_URL, headers=TEST_HEADERS, json=TEST_DATA)
  13. print(response.status_code)
  14. print(response.text)
  15. except Exception as e:
  16. print(f"Error: ",e)
  17. test()