5
5
import aiohttp
6
6
from azure .search .documents .aio import SearchClient
7
7
from azure .search .documents .models import (
8
- CaptionResult ,
8
+ QueryCaptionResult ,
9
9
QueryType ,
10
- RawVectorQuery ,
10
+ VectorizedQuery ,
11
11
VectorQuery ,
12
12
)
13
13
from openai import AsyncOpenAI
@@ -27,7 +27,7 @@ class Document:
27
27
sourcefile : Optional [str ]
28
28
oids : Optional [List [str ]]
29
29
groups : Optional [List [str ]]
30
- captions : List [CaptionResult ]
30
+ captions : List [QueryCaptionResult ]
31
31
32
32
def serialize_for_results (self ) -> dict [str , Any ]:
33
33
return {
@@ -146,7 +146,7 @@ async def search(
146
146
sourcefile = document .get ("sourcefile" ),
147
147
oids = document .get ("oids" ),
148
148
groups = document .get ("groups" ),
149
- captions = cast (List [CaptionResult ], document .get ("@search.captions" )),
149
+ captions = cast (List [QueryCaptionResult ], document .get ("@search.captions" )),
150
150
)
151
151
)
152
152
return documents
@@ -186,7 +186,7 @@ async def compute_text_embedding(self, q: str):
186
186
input = q ,
187
187
)
188
188
query_vector = embedding .data [0 ].embedding
189
- return RawVectorQuery (vector = query_vector , k = 50 , fields = "embedding" )
189
+ return VectorizedQuery (vector = query_vector , k_nearest_neighbors = 50 , fields = "embedding" )
190
190
191
191
async def compute_image_embedding (self , q : str , vision_endpoint : str , vision_key : str ):
192
192
endpoint = f"{ vision_endpoint } computervision/retrieval:vectorizeText"
@@ -200,7 +200,7 @@ async def compute_image_embedding(self, q: str, vision_endpoint: str, vision_key
200
200
) as response :
201
201
json = await response .json ()
202
202
image_query_vector = json ["vector" ]
203
- return RawVectorQuery (vector = image_query_vector , k = 50 , fields = "imageEmbedding" )
203
+ return VectorizedQuery (vector = image_query_vector , k_nearest_neighbors = 50 , fields = "imageEmbedding" )
204
204
205
205
async def run (
206
206
self , messages : list [dict ], stream : bool = False , session_state : Any = None , context : dict [str , Any ] = {}
0 commit comments