File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,38 @@ Combining Text and Images
97
97
client.close()
98
98
99
99
100
+ Loading Data from S3
101
+ --------------------
102
+
103
+ If you already have data stored in S3, you can use an ``s3:// `` url to load the image(s):
104
+
105
+ .. code-block :: python
106
+
107
+ import os
108
+ from pymongo_voyageai import PyMongoVoyageAI
109
+
110
+ client = PyMongoVoyageAI(
111
+ voyageai_api_key = os.environ[" VOYAGEAI_API_KEY" ],
112
+ s3_bucket_name = os.environ[" S3_BUCKET_NAME" ],
113
+ mongo_connection_string = os.environ[" MONGODB_URI" ],
114
+ collection_name = " test" ,
115
+ database_name = " test_db" ,
116
+ )
117
+
118
+ query = " The consequences of a dictator's peace"
119
+ url = " s3://my-bucket-name/readingcopy.pdf"
120
+ images = client.url_to_images(url)
121
+ resp = client.add_documents(images)
122
+ client.wait_for_indexing()
123
+ data = client.similarity_search(query, extract_images = True )
124
+
125
+ # We expect page 5 to be the best match.
126
+ assert data[0 ][" inputs" ][0 ].page_number == 5
127
+ assert len (client.get_by_ids([d[" _id" ] for d in resp])) == len (resp)
128
+ client.delete_by_ids([d[" _id" ] for d in resp])
129
+ client.close()
130
+
131
+
100
132
Using Async API
101
133
---------------
102
134
You can’t perform that action at this time.
0 commit comments