You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/docs
Pham Vu Thai Minh 33e77a1007
Async support for FAISS (#11333)
Following this tutoral about using OpenAI Embeddings with FAISS

https://python.langchain.com/docs/integrations/vectorstores/faiss

```python
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores import FAISS
from langchain.document_loaders import TextLoader
from langchain.document_loaders import TextLoader

loader = TextLoader("../../../extras/modules/state_of_the_union.txt")
documents = loader.load()
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
docs = text_splitter.split_documents(documents)

embeddings = OpenAIEmbeddings()
```

This works fine

```python
db = FAISS.from_documents(docs, embeddings)
query = "What did the president say about Ketanji Brown Jackson"
docs = db.similarity_search(query)
```

But the async version is not

```python
db = await FAISS.afrom_documents(docs, embeddings)  # NotImplementedError
query = "What did the president say about Ketanji Brown Jackson"

docs = await db.asimilarity_search(query) # this will use await asyncio.get_event_loop().run_in_executor under the hood and will not call OpenAIEmbeddings.aembed_query but call OpenAIEmbeddings.embed_query
```

So this PR add async/await supports for FAISS

---------

Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
12 months ago
..
api_reference Merge pull request #12433 12 months ago
docs Async support for FAISS (#11333) 12 months ago
docs_skeleton/docs/guides/langsmith mv old integration docs (#12217) 1 year ago
extras/guides/langsmith Bagatur/mv singlestore doc (#12053) 1 year ago
scripts notebook fmt (#12498) 12 months ago
src add cookbook table (#12043) 1 year ago
static Docs: QA Privacy Nit (#12025) 1 year ago
.local_build.sh langserve doc (#12357) 1 year ago
README.md Fix typos (#11663) 1 year ago
babel.config.js Restructure docs (#11620) 1 year ago
code-block-loader.js Restructure docs (#11620) 1 year ago
docusaurus.config.js Add dev guide to docs(#12291) 1 year ago
package-lock.json Bump @babel/traverse from 7.22.8 to 7.23.2 in /docs (#12453) 12 months ago
package.json Restructure docs (#11620) 1 year ago
settings.ini Restructure docs (#11620) 1 year ago
sidebars.js Docs: consolidate top nav (#12219) 1 year ago
vercel.json docs: Google Cloud Documentation Cleanup (#12224) 1 year ago
vercel_build.sh langserve doc (#12357) 1 year ago
vercel_requirements.txt Add api cross ref linking (#8275) 1 year ago

README.md

Website

This website is built using Docusaurus 2, a modern static website generator.

Installation

$ yarn

Local Development

$ yarn start

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

Build

$ yarn build

This command generates static content into the build directory and can be served using any static contents hosting service.

Deployment

Using SSH:

$ USE_SSH=true yarn deploy

Not using SSH:

$ GIT_USER=<Your GitHub username> yarn deploy

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the gh-pages branch.

Continuous Integration

Some common defaults for linting/formatting have been set for you. If you integrate your project with an open-source Continuous Integration system (e.g. Travis CI, CircleCI), you may check for issues using the following command.

$ yarn ci