41
41
class Document :
42
42
id : Optional [str ]
43
43
content : Optional [str ]
44
- embedding : Optional [List [float ]]
45
- image_embedding : Optional [List [float ]]
46
44
category : Optional [str ]
47
45
sourcepage : Optional [str ]
48
46
sourcefile : Optional [str ]
@@ -56,9 +54,6 @@ def serialize_for_results(self) -> dict[str, Any]:
56
54
result_dict = {
57
55
"id" : self .id ,
58
56
"content" : self .content ,
59
- # Should we rename to its actual field name in the index?
60
- "embedding" : Document .trim_embedding (self .embedding ),
61
- "imageEmbedding" : Document .trim_embedding (self .image_embedding ),
62
57
"category" : self .category ,
63
58
"sourcepage" : self .sourcepage ,
64
59
"sourcefile" : self .sourcefile ,
@@ -81,18 +76,6 @@ def serialize_for_results(self) -> dict[str, Any]:
81
76
}
82
77
return result_dict
83
78
84
- @classmethod
85
- def trim_embedding (cls , embedding : Optional [List [float ]]) -> Optional [str ]:
86
- """Returns a trimmed list of floats from the vector embedding."""
87
- if embedding :
88
- if len (embedding ) > 2 :
89
- # Format the embedding list to show the first 2 items followed by the count of the remaining items."""
90
- return f"[{ embedding [0 ]} , { embedding [1 ]} ...+{ len (embedding ) - 2 } more]"
91
- else :
92
- return str (embedding )
93
-
94
- return None
95
-
96
79
97
80
@dataclass
98
81
class ThoughtStep :
@@ -245,8 +228,6 @@ async def search(
245
228
Document (
246
229
id = document .get ("id" ),
247
230
content = document .get ("content" ),
248
- embedding = document .get (self .embedding_field ),
249
- image_embedding = document .get ("imageEmbedding" ),
250
231
category = document .get ("category" ),
251
232
sourcepage = document .get ("sourcepage" ),
252
233
sourcefile = document .get ("sourcefile" ),
@@ -321,13 +302,14 @@ class ExtraArgs(TypedDict, total=False):
321
302
** dimensions_args ,
322
303
)
323
304
query_vector = embedding .data [0 ].embedding
324
- # TODO: use optimizations from rag time journey 3
305
+ # This performs an oversampling due to how the search index was setup,
306
+ # so we do not need to explicitly pass in an oversampling parameter here
325
307
return VectorizedQuery (vector = query_vector , k_nearest_neighbors = 50 , fields = self .embedding_field )
326
308
327
309
async def compute_image_embedding (self , q : str ):
328
310
endpoint = urljoin (self .vision_endpoint , "computervision/retrieval:vectorizeText" )
329
311
headers = {"Content-Type" : "application/json" }
330
- params = {"api-version" : "2023 -02-01-preview " , "modelVersion " : "latest " }
312
+ params = {"api-version" : "2024 -02-01" , "model-version " : "2023-04-15 " }
331
313
data = {"text" : q }
332
314
333
315
headers ["Authorization" ] = "Bearer " + await self .vision_token_provider ()
0 commit comments