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>
2023-10-30 15:08:53 -07:00
..
api_reference Merge pull request #12433 2023-10-29 21:22:36 -04:00
docs Async support for FAISS (#11333) 2023-10-30 15:08:53 -07:00
docs_skeleton/docs/guides/langsmith mv old integration docs (#12217) 2023-10-24 12:38:16 -07:00
extras/guides/langsmith Bagatur/mv singlestore doc (#12053) 2023-10-19 15:06:26 -07:00
scripts notebook fmt (#12498) 2023-10-29 15:50:09 -07:00
src add cookbook table (#12043) 2023-10-19 14:05:24 -07:00
static Docs: QA Privacy Nit (#12025) 2023-10-19 09:43:47 -04:00
.local_build.sh langserve doc (#12357) 2023-10-26 11:40:57 -07:00
babel.config.js Restructure docs (#11620) 2023-10-10 12:55:19 -07:00
code-block-loader.js Restructure docs (#11620) 2023-10-10 12:55:19 -07:00
docusaurus.config.js Add dev guide to docs(#12291) 2023-10-25 12:28:43 -07:00
package-lock.json Bump @babel/traverse from 7.22.8 to 7.23.2 in /docs (#12453) 2023-10-27 14:13:58 -07:00
package.json Restructure docs (#11620) 2023-10-10 12:55:19 -07:00
README.md Fix typos (#11663) 2023-10-12 11:44:03 -04:00
settings.ini Restructure docs (#11620) 2023-10-10 12:55:19 -07:00
sidebars.js Docs: consolidate top nav (#12219) 2023-10-24 12:28:08 -07:00
vercel_build.sh langserve doc (#12357) 2023-10-26 11:40:57 -07:00
vercel_requirements.txt Add api cross ref linking (#8275) 2023-07-26 12:38:58 -07:00
vercel.json docs: Google Cloud Documentation Cleanup (#12224) 2023-10-24 14:54:43 -07:00

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