55import aiohttp
66from azure .search .documents .aio import SearchClient
77from azure .search .documents .models import (
8- CaptionResult ,
8+ QueryCaptionResult ,
99 QueryType ,
10- RawVectorQuery ,
10+ VectorizedQuery ,
1111 VectorQuery ,
1212)
1313from openai import AsyncOpenAI
@@ -27,7 +27,7 @@ class Document:
2727 sourcefile : Optional [str ]
2828 oids : Optional [List [str ]]
2929 groups : Optional [List [str ]]
30- captions : List [CaptionResult ]
30+ captions : List [QueryCaptionResult ]
3131
3232 def serialize_for_results (self ) -> dict [str , Any ]:
3333 return {
@@ -146,7 +146,7 @@ async def search(
146146 sourcefile = document .get ("sourcefile" ),
147147 oids = document .get ("oids" ),
148148 groups = document .get ("groups" ),
149- captions = cast (List [CaptionResult ], document .get ("@search.captions" )),
149+ captions = cast (List [QueryCaptionResult ], document .get ("@search.captions" )),
150150 )
151151 )
152152 return documents
@@ -186,7 +186,7 @@ async def compute_text_embedding(self, q: str):
186186 input = q ,
187187 )
188188 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" )
190190
191191 async def compute_image_embedding (self , q : str , vision_endpoint : str , vision_key : str ):
192192 endpoint = f"{ vision_endpoint } computervision/retrieval:vectorizeText"
@@ -200,7 +200,7 @@ async def compute_image_embedding(self, q: str, vision_endpoint: str, vision_key
200200 ) as response :
201201 json = await response .json ()
202202 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" )
204204
205205 async def run (
206206 self , messages : list [dict ], stream : bool = False , session_state : Any = None , context : dict [str , Any ] = {}
0 commit comments