Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pikalaw committed Mar 3, 2024
1 parent d8491a6 commit ed6db7b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion libs/genai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,33 @@ from langchain_google_genai import GoogleGenerativeAIEmbeddings
embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
embeddings.embed_query("hello, world!")
```
```

## Semantic Retrieval

Enables retrieval augmented generation (RAG) in your application.

```
# Create a new store for housing your documents.
corpus_store = GoogleVectorStore.create_corpus(display_name="My Corpus")
# Create a new document under the above corpus.
document_store = GoogleVectorStore.create_document(
corpus_id=corpus_store.corpus_id, display_name="My Document"
)
# Upload some texts to the document.
text_splitter = CharacterTextSplitter(chunk_size=500, chunk_overlap=0)
for file in DirectoryLoader(path="data/").load():
documents = text_splitter.split_documents([file])
document_store.add_documents(documents)
# Talk to your entire corpus with possibly many documents.
aqa = corpus_store.as_aqa()
answer = aqa.invoke("What is the meaning of life?")
# Read the response along with the attributed passages and answerability.
print(response.answer)
print(response.attributed_passages)
print(response.answerable_probability)
```

0 comments on commit ed6db7b

Please sign in to comment.