diff --git a/samples/test_text_rerank.py b/samples/test_text_rerank.py index d8ee9e9..f8d5068 100644 --- a/samples/test_text_rerank.py +++ b/samples/test_text_rerank.py @@ -1,14 +1,9 @@ # Copyright (c) Alibaba, Inc. and its affiliates. import os -import sys - -# Add the project root to Python path -sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from dashscope import TextReRank - def test_text_rerank(): """Test text rerank API with instruct parameter.""" query = "哈尔滨在哪?" @@ -27,26 +22,10 @@ def test_text_rerank(): instruct="Retrieval document that can answer users query." ) - print(f'response: {response}') - - print("\n✅ Test passed! All assertions successful.") + print(f'response:\n{response}') except Exception as e: - print(f"❌ Test failed with error: {str(e)}") raise if __name__ == "__main__": - # Load environment variables if .env file exists - try: - with open(os.path.expanduser('~/.env'), 'r') as f: - for line in f: - if line.strip() and not line.startswith('#'): - key, value = line.strip().split('=', 1) - os.environ[key] = value - except FileNotFoundError: - print("No .env file found, using system environment variables") - - # Run tests - test_text_rerank() - - print("\n🎉 All tests completed successfully!") + test_text_rerank() \ No newline at end of file