-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(New e2e tests, fix retreival with return_source_documents=True):
- Loading branch information
Showing
6 changed files
with
1,185 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from langchain.chains import RetrievalQA | ||
from langchain.document_loaders import TextLoader | ||
from langchain.embeddings.fake import FakeEmbeddings | ||
from langchain.llms import OpenAI | ||
from langchain.text_splitter import CharacterTextSplitter | ||
from langchain.vectorstores import Chroma | ||
|
||
loader = TextLoader("Readme.md") | ||
documents = loader.load() | ||
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) | ||
texts = text_splitter.split_documents(documents) | ||
|
||
embeddings = FakeEmbeddings(size=1504) | ||
docsearch = Chroma.from_documents(texts, embeddings) | ||
|
||
|
||
qa = RetrievalQA.from_chain_type( | ||
llm=OpenAI(), | ||
chain_type="stuff", | ||
retriever=docsearch.as_retriever(), | ||
return_source_documents=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.