-
Notifications
You must be signed in to change notification settings - Fork 10
/
naive_rag_demo.py
33 lines (29 loc) · 956 Bytes
/
naive_rag_demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
"""
@author:XuMing(xuming624@qq.com)
@description: Basic example of using the assistant with a naive retrieval-based model.
"""
import sys
sys.path.append('..')
from agentica import Assistant, AzureOpenAILLM
from agentica.knowledge.knowledge_base import KnowledgeBase
from agentica.vectordb.lancedb import LanceDb
from agentica.emb.text2vec_emb import Text2VecEmb
knowledge_base = KnowledgeBase(
data_path="data/medical_corpus.txt",
vector_db=LanceDb(
table_name="medical",
embedder=Text2VecEmb(),
),
)
# Load the knowledge base
knowledge_base.load(recreate=True)
assistant = Assistant(
llm=AzureOpenAILLM(),
knowledge_base=knowledge_base,
# The add_references_to_prompt will update the prompt with references from the knowledge base.
add_references_to_prompt=True,
debug_mode=True
)
r = assistant.run("肛门病变可能是什么疾病的症状?", stream=True)
print("".join(r))