1from kern.agent import Agent
2from kern.db.postgres import PostgresDb
3from kern.knowledge.knowledge import Knowledge
4from kern.vectordb.qdrant import Qdrant
5
6COLLECTION_NAME = "thai-recipes"
7
8vector_db = Qdrant(collection=COLLECTION_NAME, url="http://localhost:6333")
9
10contents_db = PostgresDb(
11 db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
12 knowledge_table="knowledge_contents",
13)
14
15knowledge = Knowledge(
16 name="My Qdrant Vector Knowledge Base",
17 description="This is a knowledge base that uses a Qdrant Vector DB",
18 vector_db=vector_db,
19 contents_db=contents_db,
20)
21
22knowledge.insert(
23 name="Recipes",
24 url="https://kern-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
25 metadata={"doc_type": "recipe_book"},
26)
27
28agent = Agent(knowledge=knowledge)
29agent.print_response("List down the ingredients to make Massaman Gai", markdown=True)
30
31vector_db.delete_by_name("Recipes")
32
33vector_db.delete_by_metadata({"doc_type": "recipe_book"})