File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 1+ from langchain .vectorstores import Spellbook , VectorStore
2+ from langchain .embeddings .openai import OpenAIEmbeddings
3+ import requests
4+
5+ # create a vector store via REST api
6+ res = requests .post ('https://api.spellbook.scale.com/create_vector_store' , json = {
7+ "name" : "cat facts" ,
8+ }, headers = {
9+ "authorization" : "..." ,
10+ })
11+ assert res .status_code == 200
12+
13+ # add documents to vectorstores
14+ spellbook : VectorStore = Spellbook (api_key = "..." , name = "cat facts" )
15+ embeddings = OpenAIEmbeddings ()
16+ spellbook .add_texts (texts = [
17+ "cats are fun" ,
18+ ], embeddings = embeddings )
19+
20+ # query
21+ query = "what's up?"
22+ query_embedding = embeddings .embed_query (query )
23+
24+ docs = spellbook .similarity_search_by_vector (query_embedding )
You can’t perform that action at this time.
0 commit comments