Skip to content

Commit 532de67

Browse files
committed
Added lab 8 instructions
1 parent d2f961b commit 532de67

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

labs/08-qdrant-cloud.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Lab 8: Qdrant Cloud (Homework)
2+
3+
Now, let us configure the application to run on the deployment environment. To do this, we need to sign up for qdrant cloud and configure our application to connect to the cloud version.
4+
5+
Here are the steps for this lab:
6+
7+
1. Sign up for a free account at qdrant - https://qdrant.tech/
8+
1. Start a free cluster - https://qdrant.tech/documentation/cloud/create-cluster/
9+
1. Get the QDRANT_API_KEY and QDRANT_URL for the cluster. Update both in the `.env` file
10+
1. Update `config.py` and add these two settings:
11+
12+
```
13+
QDRANT_API_KEY: str
14+
QDRANT_URL: AnyUrl
15+
```
16+
1. Create the collection `resumes` on qdrant cloud. Put this code in a script and run it
17+
18+
```python
19+
from langchain_openai import OpenAIEmbeddings
20+
from langchain_qdrant import QdrantVectorStore
21+
from qdrant_client import QdrantClient
22+
from qdrant_client.http.models import Distance, VectorParams
23+
from config import settings
24+
25+
embeddings = OpenAIEmbeddings(model="text-embedding-3-large", api_key=settings.OPENAI_API_KEY)
26+
client = QdrantClient(url=str(settings.QDRANT_URL), api_key=settings.QDRANT_API_KEY)
27+
client.create_collection(collection_name="resumes", vectors_config=VectorParams(size=3072, distance=Distance.COSINE))
28+
client.close()
29+
```
30+
31+
1. Update `get_vector_store` function so that it connects to cloud server in production environment
32+
1. Go to render.com and add these two environment variables to your instance - https://render.com/docs/configure-environment-variables
33+
1. Commit the code, push and do a deploy on render
34+
35+
## Hints
36+
37+
### How do I connect to qdrant cloud in langchain?
38+
39+
<details>
40+
<summary>Answer</summary>
41+
42+
```python
43+
vector_store = QdrantVectorStore.from_existing_collection(
44+
embedding=embeddings,
45+
collection_name="resumes",
46+
url=str(settings.QDRANT_URL),
47+
api_key=settings.QDRANT_API_KEY)
48+
```
49+
50+
### How do I update get_vector_store?
51+
52+
<details>
53+
<summary>Answer</summary>
54+
55+
We want to use the cloud vector store in production and the file path in laptop
56+
57+
```python
58+
def get_vector_store():
59+
embeddings = OpenAIEmbeddings(model="text-embedding-3-large", api_key=settings.OPENAI_API_KEY)
60+
if settings.PRODUCTION:
61+
vector_store = QdrantVectorStore.from_existing_collection(
62+
embedding=embeddings,
63+
collection_name="resumes",
64+
url=str(settings.QDRANT_URL),
65+
api_key=settings.QDRANT_API_KEY)
66+
else:
67+
vector_store = QdrantVectorStore.from_existing_collection(
68+
embedding=embeddings,
69+
collection_name="resumes",
70+
path="qdrant_store")
71+
return vector_store
72+
```

0 commit comments

Comments
 (0)