30 lines
887 B
Python
30 lines
887 B
Python
|
|
import asyncio
|
||
|
|
import sys
|
||
|
|
sys.path.insert(0, '/app')
|
||
|
|
|
||
|
|
async def test():
|
||
|
|
from app.services.graph_query_service import get_graph_query_service
|
||
|
|
from app.services.neo4j_client import get_neo4j_client
|
||
|
|
|
||
|
|
neo4j_client = await get_neo4j_client()
|
||
|
|
print(f'Neo4j client: {neo4j_client}')
|
||
|
|
|
||
|
|
if neo4j_client:
|
||
|
|
graph_service = await get_graph_query_service(neo4j_client)
|
||
|
|
print(f'Graph service: {graph_service}')
|
||
|
|
|
||
|
|
# 测试查询
|
||
|
|
question = "打印机驱动安装"
|
||
|
|
print(f'Querying: {question}')
|
||
|
|
result = await graph_service.find_solution_by_question(question)
|
||
|
|
print(f'Result: {result}')
|
||
|
|
|
||
|
|
if result:
|
||
|
|
print(f"图谱命中! action_name={result.action_name}, solution={result.solution[:50]}")
|
||
|
|
else:
|
||
|
|
print("图谱未命中")
|
||
|
|
else:
|
||
|
|
print('Neo4j client is None')
|
||
|
|
|
||
|
|
asyncio.run(test())
|