36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
|
|
|
||
|
|
import requests
|
||
|
|
import json
|
||
|
|
|
||
|
|
def test_v2_search_api():
|
||
|
|
url = "http://127.0.0.1:8000/fs-ai-asistant/api/workflow/lawrisk/v2"
|
||
|
|
|
||
|
|
# Test 1: JSON POST
|
||
|
|
params = {
|
||
|
|
"query": "食品小作坊登记证",
|
||
|
|
"region": "市级"
|
||
|
|
}
|
||
|
|
|
||
|
|
print(f"Testing search for '食品小作坊登记证' in '市级'...")
|
||
|
|
try:
|
||
|
|
response = requests.post(url, json=params)
|
||
|
|
print(f"Status Code: {response.status_code}")
|
||
|
|
data = response.json()
|
||
|
|
|
||
|
|
if data.get("success"):
|
||
|
|
risk_subject = data.get("data", {}).get("risk_subject", [])
|
||
|
|
print(f"Success! Found {len(risk_subject)} risk subjects.")
|
||
|
|
if risk_subject:
|
||
|
|
print(f"First subject title: {risk_subject[0].get('title')}")
|
||
|
|
else:
|
||
|
|
print("Warning: success but risk_subject is empty.")
|
||
|
|
print(f"Full response: {json.dumps(data, indent=2, ensure_ascii=False)}")
|
||
|
|
else:
|
||
|
|
print(f"Error: {data.get('message')}")
|
||
|
|
|
||
|
|
except Exception as e:
|
||
|
|
print(f"API call failed: {e}")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
test_v2_search_api()
|