test_bm25.py 740 B

1234567891011121314151617181920
  1. from agent.api_outter import vector_similarity_search,execute_reg
  2. import agent.core.dao as dao
  3. async def test_bm25():
  4. phrase = "职业:民宿服务; 投向:民宿服务; 用途:经营民宿"
  5. result = await execute_reg(None,None,phrase)
  6. print('to here 1')
  7. print(result)
  8. # step2: 向量检索
  9. if not result or len(result) == 0:
  10. result = vector_similarity_search(phrase)
  11. print('to here 2')
  12. print(result)
  13. # step3: LLM 打标
  14. if result:
  15. tags = dao.query_dict(""" select id,tag_nm as tag_name,tag_code, tag_path,category_id,tag_prompt from aitag_tag_info where id in %s """, (tuple(result),))
  16. print('to here 3')
  17. print(tags)
  18. import asyncio
  19. asyncio.run(test_bm25())