diff --git a/.gitignore b/.gitignore index f571c929c0d2ee5508fbe603d2d11bd8d7de76dd..094c61f44a8c7dbc513b20a7b486e6f7d1c48dcc 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ node_modules package-lock.json package.json test.ipynb +test_sync.ipynb ``` # docs diff --git a/semantic_router/index/base.py b/semantic_router/index/base.py index 7346788734adc3f287e0dc2434ee3ec706cfe159..9d8246611e7bd891cba28c2edc44f8616550e6c6 100644 --- a/semantic_router/index/base.py +++ b/semantic_router/index/base.py @@ -122,9 +122,9 @@ class BaseIndex(BaseModel): - "error": Raise an error if local and remote are not synchronized. - "remote": Take remote as the source of truth and update local to align. - "local": Take local as the source of truth and update remote to align. - - "merge-force-remote": Merge both local and remote taking only remote routes utterances when a route with same route name is present both locally and remotely. - - "merge-force-local": Merge both local and remote taking only local routes utterances when a route with same route name is present both locally and remotely. - - "merge": Merge both local and remote, merging also local and remote utterances when a route with same route name is present both locally and remotely. + - "merge-force-remote": Merge both local and remote taking only remote routes features when a route with same route name is present both locally and remotely. + - "merge-force-local": Merge both local and remote taking only local routes features when a route with same route name is present both locally and remotely. + - "merge": Merge both local and remote, merging also local and remote features when a route with same route name is present both locally and remotely. This method should be implemented by subclasses. """ diff --git a/semantic_router/index/pinecone.py b/semantic_router/index/pinecone.py index 1016a7b5041cd7645906258d4bf60a1b5701a5a9..cb2f58caf6f2548efe4401ab95605446588e6e58 100644 --- a/semantic_router/index/pinecone.py +++ b/semantic_router/index/pinecone.py @@ -292,7 +292,6 @@ class PineconeIndex(BaseIndex): layer_routes[route][ "function_schemas" ] = remote_function_schemas_dict - elif self.sync == "local": utterances_to_include = local_utterances_set - remote_utterances_set routes_to_delete.extend( @@ -304,7 +303,7 @@ class PineconeIndex(BaseIndex): ) layer_routes[route] = {} if local_utterances_set: - layer_routes[route]["utterances"] = list(local_utterances_set) + layer_routes[route] = {"utterances": list(local_utterances_set)} if local_function_schemas_dict: layer_routes[route][ "function_schemas" @@ -340,12 +339,19 @@ class PineconeIndex(BaseIndex): ) if local_utterances_set: layer_routes[route] = {"utterances": list(local_utterances_set)} + if local_function_schemas_dict: + layer_routes[route][ + "function_schemas" + ] = local_function_schemas_dict else: if remote_utterances_set: layer_routes[route] = { "utterances": list(remote_utterances_set) } - + if remote_function_schemas_dict: + layer_routes[route][ + "function_schemas" + ] = remote_function_schemas_dict elif self.sync == "merge": utterances_to_include = local_utterances_set - remote_utterances_set if local_utterances_set or remote_utterances_set: