Spaces:
Sleeping
Sleeping
Create quantum_analyzer_example.py
Browse files
examples/quantum_analyzer_example.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# coding: utf-8
|
| 3 |
+
"""
|
| 4 |
+
量子分析器示例 - 展示QuantumAnalyzer的基本用法
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import sys
|
| 8 |
+
import os
|
| 9 |
+
import time
|
| 10 |
+
|
| 11 |
+
# 將项目根目錄添加到路徑中,方便導入模組
|
| 12 |
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 13 |
+
|
| 14 |
+
# 修正: 移除 psi_runtime_sdk 前綴
|
| 15 |
+
from quantum_engine import QuantumAnalyzer, Config
|
| 16 |
+
|
| 17 |
+
def main():
|
| 18 |
+
print("="*60)
|
| 19 |
+
print("QuantumAnalyzer 量子分析示例")
|
| 20 |
+
print("="*60)
|
| 21 |
+
|
| 22 |
+
# 初始化配置
|
| 23 |
+
config = Config(log_level=10) # DEBUG 級別
|
| 24 |
+
|
| 25 |
+
# 初始化量子分析器
|
| 26 |
+
engine = QuantumAnalyzer(config)
|
| 27 |
+
|
| 28 |
+
# 測試輸入
|
| 29 |
+
test_inputs = [
|
| 30 |
+
"探索人工智能與量子計算的結合點",
|
| 31 |
+
"分析長期技術趨勢的方法論",
|
| 32 |
+
"未來十年的技術發展方向預測"
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
for input_text in test_inputs:
|
| 36 |
+
print(f"\n{'='*60}\n處理輸入: {input_text}\n{'='*60}")
|
| 37 |
+
|
| 38 |
+
# 執行量子分析
|
| 39 |
+
quantum_result = engine.run_inference(input_text, use_basic_logic=False)
|
| 40 |
+
print(f"量子分析結果: {quantum_result}")
|
| 41 |
+
|
| 42 |
+
# 執行基礎邏輯分析
|
| 43 |
+
basic_result = engine.run_inference(input_text, use_basic_logic=True)
|
| 44 |
+
print(f"基礎邏輯分析結果: {basic_result.get('final_result', 'N/A')}")
|
| 45 |
+
|
| 46 |
+
# 執行綜合分析
|
| 47 |
+
comprehensive_result = engine.comprehensive_analysis(input_text)
|
| 48 |
+
print(f"綜合分析結果: {comprehensive_result.get('integrated_score', 'N/A')}")
|
| 49 |
+
|
| 50 |
+
# 暫停一下,避免輸出太快
|
| 51 |
+
time.sleep(1)
|
| 52 |
+
|
| 53 |
+
if __name__ == "__main__":
|
| 54 |
+
main()
|