diff --git a/semantic_router/encoders/bm25.py b/semantic_router/encoders/bm25.py index b5db6f8bc146195d50e99901b2b118faee6437ca..f42bf9c28937419b29ae4429151a1fe3120c0487 100644 --- a/semantic_router/encoders/bm25.py +++ b/semantic_router/encoders/bm25.py @@ -57,7 +57,6 @@ class BM25Encoder(TfidfEncoder): self.model.fit(corpus=utterances) def __call__(self, docs: List[str]) -> list[SparseEmbedding]: - print(f"JBTEMP: {docs}") if self.model is None: raise ValueError("Model or index mapping is not initialized.") if len(docs) == 1: diff --git a/semantic_router/index/base.py b/semantic_router/index/base.py index 9751ea097027004431edcd96c0bd3e18fb970804..0025a0bbc652b69bf2a13e3839703416569e6283 100644 --- a/semantic_router/index/base.py +++ b/semantic_router/index/base.py @@ -384,7 +384,6 @@ class BaseIndex(BaseModel): """Lock/unlock the index for a given scope (if applicable). If index already locked/unlocked, raises ValueError. """ - logger.warning(f"JBTEMP alock method called with {value=} {wait=} {scope=}") start_time = datetime.now() while True: if await self._ais_locked(scope=scope) != value: diff --git a/semantic_router/index/pinecone.py b/semantic_router/index/pinecone.py index c01769929c6d6cecbbac6781c9c63dc78fe8fc45..5e71da2a76b57fd59236d35469dcb9bfad77341f 100644 --- a/semantic_router/index/pinecone.py +++ b/semantic_router/index/pinecone.py @@ -292,7 +292,6 @@ class PineconeIndex(BaseIndex): :type batch: List[Dict] """ if self.index is not None: - print(f"JBTEMP upserting batch: {batch} to '{self.namespace}'") self.index.upsert(vectors=batch, namespace=self.namespace) else: raise ValueError("Index is None, could not upsert.") @@ -309,10 +308,6 @@ class PineconeIndex(BaseIndex): **kwargs, ): """Add vectors to Pinecone in batches.""" - print(f"{routes=}") - print(f"{utterances=}") - print(f"{function_schemas=}") - print(f"{metadata_list=}") if self.index is None: self.dimensions = self.dimensions or len(embeddings[0]) self.index = self._init_index(force_create=True) @@ -324,7 +319,6 @@ class PineconeIndex(BaseIndex): metadata_list=metadata_list, sparse_embeddings=sparse_embeddings, ) - print(f"{vectors_to_upsert=}") for i in range(0, len(vectors_to_upsert), batch_size): batch = vectors_to_upsert[i : i + batch_size] self._batch_upsert(batch) @@ -583,11 +577,9 @@ class PineconeIndex(BaseIndex): scope=scope, ) config_id = f"{field}#{scope}" - logger.warning(f"JBTEMP Pinecone config id: {config_id}") config_record = await self._async_fetch_metadata( vector_id=config_id, namespace="sr_config" ) - logger.warning(f"JBTEMP Pinecone config record: {config_record}") if config_record: try: return ConfigParameter( @@ -637,7 +629,6 @@ class PineconeIndex(BaseIndex): if self.dimensions is None: raise ValueError("Must set PineconeIndex.dimensions before writing config.") pinecone_config = config.to_pinecone(dimensions=self.dimensions) - logger.warning(f"JBTEMP Pinecone config to upsert: {pinecone_config}") await self._async_upsert( vectors=[pinecone_config], namespace="sr_config", @@ -750,13 +741,11 @@ class PineconeIndex(BaseIndex): "vectors": vectors, "namespace": namespace, } - logger.warning(f"JBTEMP Pinecone upsert params: {params}") async with self.async_client.post( f"https://{self.host}/vectors/upsert", json=params, ) as response: res = await response.json(content_type=None) - logger.warning(f"JBTEMP Pinecone upsert response: {res}") return res async def _async_create_index( @@ -878,7 +867,6 @@ class PineconeIndex(BaseIndex): params = { "ids": [vector_id], } - logger.warning(f"JBTEMP Pinecone fetch params: {params}") if namespace: params["namespace"] = [namespace] diff --git a/semantic_router/routers/base.py b/semantic_router/routers/base.py index fb14aa661bea0e651a210a844828fc511ffdcf1f..b5136f97750e55f25358707774cbd2abead5da30 100644 --- a/semantic_router/routers/base.py +++ b/semantic_router/routers/base.py @@ -391,7 +391,6 @@ class BaseRouter(BaseModel): def _init_index_state(self): """Initializes an index (where required) and runs auto_sync if active.""" - print("JBTEMP _init_index_state") # initialize index now, check if we need dimensions if self.index.dimensions is None: dims = len(self.encoder(["test"])[0]) @@ -684,7 +683,6 @@ class BaseRouter(BaseModel): :param strategy: The sync strategy to execute. :type strategy: Dict[str, Dict[str, List[Utterance]]] """ - print(f"strategy: {strategy}") if strategy["remote"]["delete"]: data_to_delete = {} # type: ignore for utt_obj in strategy["remote"]["delete"]: @@ -1233,7 +1231,6 @@ class BaseRouter(BaseModel): self, query_results: List[Dict] ) -> Dict[str, List[float]]: scores_by_class: Dict[str, List[float]] = {} - logger.warning(f"JBTEMP: {query_results=}") for result in query_results: score = result["score"] route = result["route"] diff --git a/semantic_router/routers/hybrid.py b/semantic_router/routers/hybrid.py index ecbe45d4121c4f91253aa15194e9ab0873ba181a..9a0eaf54075b7742f28dd38da678134563b58138 100644 --- a/semantic_router/routers/hybrid.py +++ b/semantic_router/routers/hybrid.py @@ -91,7 +91,6 @@ class HybridRouter(BaseRouter): if current_remote_hash.value == "": # if remote hash is empty, the index is to be initialized current_remote_hash = current_local_hash - logger.warning(f"JBTEMP: {routes}") if isinstance(routes, Route): routes = [routes] # create embeddings for all routes @@ -242,8 +241,6 @@ class HybridRouter(BaseRouter): route_filter=route_filter, sparse_vector=sparse_vector, ) - logger.warning(f"JBTEMP: {scores}") - logger.warning(f"JBTEMP: {route_names}") query_results = [ {"route": d, "score": s.item()} for d, s in zip(route_names, scores) ] @@ -252,8 +249,6 @@ class HybridRouter(BaseRouter): top_class, top_class_scores = self._semantic_classify( query_results=query_results ) - logger.warning(f"JBTEMP: {top_class}") - logger.warning(f"JBTEMP: {top_class_scores}") passed = self._pass_threshold(top_class_scores, self.score_threshold) if passed: return RouteChoice(name=top_class, similarity_score=max(top_class_scores)) @@ -312,8 +307,8 @@ class HybridRouter(BaseRouter): Xq_s: List[SparseEmbedding] = [] for i in tqdm(range(0, len(X), batch_size), desc="Generating embeddings"): emb_d = np.array(self.encoder(X[i : i + batch_size])) - # TODO JB: for some reason the sparse encoder is receiving a tuple like `("Hello",)` - print(f"JBTEMP: {X[i : i + batch_size]}") + # TODO JB: for some reason the sparse encoder is receiving a tuple + # like `("Hello",)` emb_s = self.sparse_encoder(X[i : i + batch_size]) Xq_d.extend(emb_d) Xq_s.extend(emb_s) diff --git a/tests/unit/test_sync.py b/tests/unit/test_sync.py index 204cb2a7a096a8b494c9cfefbbfd08ada6795663..feae4b5d103519bea2fe8687a8b6dd64e3e662f5 100644 --- a/tests/unit/test_sync.py +++ b/tests/unit/test_sync.py @@ -1133,14 +1133,12 @@ class TestAsyncSemanticRouter: index = init_index( index_cls, init_async_index=True, index_name=router_cls.__name__ ) - print(f"1. {index.namespace=}") route_layer = router_cls( encoder=openai_encoder, routes=routes_2, index=index, auto_sync="local", ) - print(f"2. {route_layer.index.namespace=}") route_layer = router_cls( encoder=openai_encoder, routes=routes, @@ -1153,14 +1151,12 @@ class TestAsyncSemanticRouter: await route_layer.async_sync("local") if index_cls is PineconeIndex: await asyncio.sleep(PINECONE_SLEEP) - print(f"3. {route_layer.index.namespace=}") # Lock should be released, allowing another sync await route_layer.async_sync("local") # Should not raise exception if index_cls is PineconeIndex: await asyncio.sleep(PINECONE_SLEEP) assert await route_layer.async_is_synced() - print(f"4. {route_layer.index.namespace=}") # clear index if pinecone if index_cls is PineconeIndex: