Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
OurBuilding Ambient Agents with LangGraph course is now available on LangChain Academy!
Open In ColabOpen on GitHub

AwaDB

AwaDB is an AI Native database for the search and storage of embedding vectors used by LLM Applications.

You'll need to installlangchain-community withpip install -qU langchain-community to use this integration

This notebook shows how to use functionality related to theAwaDB.

%pip install--upgrade--quiet  awadb
from langchain_community.document_loadersimport TextLoader
from langchain_community.vectorstoresimport AwaDB
from langchain_text_splittersimport CharacterTextSplitter
loader= TextLoader("../../how_to/state_of_the_union.txt")
documents= loader.load()
text_splitter= CharacterTextSplitter(chunk_size=100, chunk_overlap=0)
docs= text_splitter.split_documents(documents)
db= AwaDB.from_documents(docs)
query="What did the president say about Ketanji Brown Jackson"
docs= db.similarity_search(query)
print(docs[0].page_content)
And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence.

Similarity search with score

The returned distance score is between 0-1. 0 is dissimilar, 1 is the most similar

docs= db.similarity_search_with_score(query)
print(docs[0])
(Document(page_content='And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence.', metadata={'source': '../../how_to/state_of_the_union.txt'}), 0.561813814013747)

Restore the table created and added data before

AwaDB automatically persists added document data.

If you can restore the table you created and added before, you can just do this as below:

import awadb

awadb_client= awadb.Client()
ret= awadb_client.Load("langchain_awadb")
if ret:
print("awadb load table success")
else:
print("awadb load table failed")

awadb load table success

Related


[8]ページ先頭

©2009-2025 Movatter.jp