Skip to content

Instantly share code, notes, and snippets.

@hweller1
Last active October 23, 2024 20:45
Show Gist options
  • Select an option

  • Save hweller1/414561436db076beaeaef37f740caf4a to your computer and use it in GitHub Desktop.

Select an option

Save hweller1/414561436db076beaeaef37f740caf4a to your computer and use it in GitHub Desktop.
import os
import openai
embedding = openai.Embedding.create(input="test query", model="text-embedding-ada-002").data[0].embedding
pipeline = [
{
"$vectorSearch": {
"index":'bson_vector_index',
"path": "plot_embedding",
"queryVector": embedding,
"limit": 10,
"numCandidates": 100,
},
},
{
"$project": {"plot_embedding": 0}
}
]
docs = list(coll.aggregate(pipeline))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment