diff --git a/docs/source/_autosummary/semantic_router.encoders.AutoEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.AutoEncoder.rst index 74cf9bec1cf79be0b2c517940e47899cfab58a6e..bd6e51bc4e9af1663ed6acd04b4d7b1e1fb43fef 100644 --- a/docs/source/_autosummary/semantic_router.encoders.AutoEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.AutoEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.AutoEncoder +semantic\_router.encoders.AutoEncoder ===================================== .. currentmodule:: semantic_router.encoders diff --git a/docs/source/_autosummary/semantic_router.encoders.base.BaseEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.base.BaseEncoder.rst index 2eab803d61f0366df287f1ffb7f71cccb51cd6c8..8d9e0e7a9db2e40abe11a14c6ef1f85ea09249b2 100644 --- a/docs/source/_autosummary/semantic_router.encoders.base.BaseEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.base.BaseEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.base.BaseEncoder +semantic\_router.encoders.base.BaseEncoder ========================================== .. currentmodule:: semantic_router.encoders.base diff --git a/docs/source/_autosummary/semantic_router.encoders.bedrock.BedrockEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.bedrock.BedrockEncoder.rst index cc8f7e33b62ebccf8067bc050921e7db2cc7ed3e..ccc1a0ee577b479d02fbd117a2d275956a2ff010 100644 --- a/docs/source/_autosummary/semantic_router.encoders.bedrock.BedrockEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.bedrock.BedrockEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.bedrock.BedrockEncoder +semantic\_router.encoders.bedrock.BedrockEncoder ================================================ .. currentmodule:: semantic_router.encoders.bedrock diff --git a/docs/source/_autosummary/semantic_router.encoders.bm25.BM25Encoder.rst b/docs/source/_autosummary/semantic_router.encoders.bm25.BM25Encoder.rst index 2eea51494ffc24fc23b865e5465f7bcf53fdef98..7b73d95536a64cb8ef1141d0752ec57447842cb4 100644 --- a/docs/source/_autosummary/semantic_router.encoders.bm25.BM25Encoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.bm25.BM25Encoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.bm25.BM25Encoder +semantic\_router.encoders.bm25.BM25Encoder ========================================== .. currentmodule:: semantic_router.encoders.bm25 diff --git a/docs/source/_autosummary/semantic_router.encoders.clip.CLIPEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.clip.CLIPEncoder.rst index 59df55cafa262656f9031b2593a9a2b20825b2c8..dbc8b5fa6d6b0dc6b581d6057b4d11d450bfbc5c 100644 --- a/docs/source/_autosummary/semantic_router.encoders.clip.CLIPEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.clip.CLIPEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.clip.CLIPEncoder +semantic\_router.encoders.clip.CLIPEncoder ========================================== .. currentmodule:: semantic_router.encoders.clip diff --git a/docs/source/_autosummary/semantic_router.encoders.cohere.CohereEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.cohere.CohereEncoder.rst index b37412df066278c5f535763d33e9ab6edbda0831..b8da4ed76dbb99546dbdb2661a9552bf9c22d6f7 100644 --- a/docs/source/_autosummary/semantic_router.encoders.cohere.CohereEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.cohere.CohereEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.cohere.CohereEncoder +semantic\_router.encoders.cohere.CohereEncoder ============================================== .. currentmodule:: semantic_router.encoders.cohere diff --git a/docs/source/_autosummary/semantic_router.encoders.fastembed.FastEmbedEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.fastembed.FastEmbedEncoder.rst index bee72bcf46c5b0dfc7bae8b609ad330f432dff5b..38b220aa2fcde6d1f269b3c79d574de1b50f53bf 100644 --- a/docs/source/_autosummary/semantic_router.encoders.fastembed.FastEmbedEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.fastembed.FastEmbedEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.fastembed.FastEmbedEncoder +semantic\_router.encoders.fastembed.FastEmbedEncoder ==================================================== .. currentmodule:: semantic_router.encoders.fastembed diff --git a/docs/source/_autosummary/semantic_router.encoders.google.GoogleEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.google.GoogleEncoder.rst index 81b4787397bdf9eb8db1a9a0da3475a3589e9f2a..e7f2c4354606fa3a9e368716ddc1818d0b2e6106 100644 --- a/docs/source/_autosummary/semantic_router.encoders.google.GoogleEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.google.GoogleEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.google.GoogleEncoder +semantic\_router.encoders.google.GoogleEncoder ============================================== .. currentmodule:: semantic_router.encoders.google diff --git a/docs/source/_autosummary/semantic_router.encoders.huggingface.HFEndpointEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.huggingface.HFEndpointEncoder.rst index fcef2410b7ffdc7b744fa214108af665f57a8311..be9a4bca50b23c4d513e8fa5d5c6251efbc1c606 100644 --- a/docs/source/_autosummary/semantic_router.encoders.huggingface.HFEndpointEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.huggingface.HFEndpointEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.huggingface.HFEndpointEncoder +semantic\_router.encoders.huggingface.HFEndpointEncoder ======================================================= .. currentmodule:: semantic_router.encoders.huggingface diff --git a/docs/source/_autosummary/semantic_router.encoders.huggingface.HuggingFaceEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.huggingface.HuggingFaceEncoder.rst index e78399abeea9cdfb89376eba41f7b0ca506fe89f..6a569fc434b890c8d0bcc26b46f673ef32ca6e8f 100644 --- a/docs/source/_autosummary/semantic_router.encoders.huggingface.HuggingFaceEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.huggingface.HuggingFaceEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.huggingface.HuggingFaceEncoder +semantic\_router.encoders.huggingface.HuggingFaceEncoder ======================================================== .. currentmodule:: semantic_router.encoders.huggingface diff --git a/docs/source/_autosummary/semantic_router.encoders.mistral.MistralEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.mistral.MistralEncoder.rst index e5e8e30a13aa5e97888eaa9fc0fd2ba4286bac5c..2b992fb27e5596ac2ea7dcde24b3ed2f90a5e418 100644 --- a/docs/source/_autosummary/semantic_router.encoders.mistral.MistralEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.mistral.MistralEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.mistral.MistralEncoder +semantic\_router.encoders.mistral.MistralEncoder ================================================ .. currentmodule:: semantic_router.encoders.mistral diff --git a/docs/source/_autosummary/semantic_router.encoders.openai.OpenAIEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.openai.OpenAIEncoder.rst index 3a388a84223c1f3eb160e97f6350838a7bf7c4ee..e5a2f710c5f3a20adafe6f9fa1221983245e4201 100644 --- a/docs/source/_autosummary/semantic_router.encoders.openai.OpenAIEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.openai.OpenAIEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.openai.OpenAIEncoder +semantic\_router.encoders.openai.OpenAIEncoder ============================================== .. currentmodule:: semantic_router.encoders.openai @@ -45,6 +45,7 @@ semantic\_router.encoders.openai.OpenAIEncoder ~OpenAIEncoder.dimensions ~OpenAIEncoder.token_limit ~OpenAIEncoder.type + ~OpenAIEncoder.max_retries ~OpenAIEncoder.name ~OpenAIEncoder.score_threshold diff --git a/docs/source/_autosummary/semantic_router.encoders.tfidf.TfidfEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.tfidf.TfidfEncoder.rst index 2bed919c89a8049140e71e57e7492a7a0a5ab247..c5e456ba74b03a7a17daeed3044f855286556b50 100644 --- a/docs/source/_autosummary/semantic_router.encoders.tfidf.TfidfEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.tfidf.TfidfEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.tfidf.TfidfEncoder +semantic\_router.encoders.tfidf.TfidfEncoder ============================================ .. currentmodule:: semantic_router.encoders.tfidf diff --git a/docs/source/_autosummary/semantic_router.encoders.vit.VitEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.vit.VitEncoder.rst index 3fe1db29a2ac5b008176f085ec149ecc5e296d72..d32b9207ff9444194b880c318e8f4fcc0e216fa2 100644 --- a/docs/source/_autosummary/semantic_router.encoders.vit.VitEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.vit.VitEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.vit.VitEncoder +semantic\_router.encoders.vit.VitEncoder ======================================== .. currentmodule:: semantic_router.encoders.vit diff --git a/docs/source/_autosummary/semantic_router.encoders.zure.AzureOpenAIEncoder.rst b/docs/source/_autosummary/semantic_router.encoders.zure.AzureOpenAIEncoder.rst index d19d59367096caf03286f6f19dad99a63bc66e68..da09f956496adce094db283c45dd7c908ed8eef7 100644 --- a/docs/source/_autosummary/semantic_router.encoders.zure.AzureOpenAIEncoder.rst +++ b/docs/source/_autosummary/semantic_router.encoders.zure.AzureOpenAIEncoder.rst @@ -1,4 +1,4 @@ -semantic\_router.encoders.zure.AzureOpenAIEncoder +semantic\_router.encoders.zure.AzureOpenAIEncoder ================================================= .. currentmodule:: semantic_router.encoders.zure @@ -49,6 +49,7 @@ semantic\_router.encoders.zure.AzureOpenAIEncoder ~AzureOpenAIEncoder.azure_endpoint ~AzureOpenAIEncoder.api_version ~AzureOpenAIEncoder.model + ~AzureOpenAIEncoder.max_retries ~AzureOpenAIEncoder.name ~AzureOpenAIEncoder.score_threshold diff --git a/docs/source/_autosummary/semantic_router.hybrid_layer.HybridRouteLayer.rst b/docs/source/_autosummary/semantic_router.hybrid_layer.HybridRouteLayer.rst index f29381efd18a5d02f29d0430de3a4ec2cd19a86b..3976499090e60e6aa0a95e62da43f6291d67e0b1 100644 --- a/docs/source/_autosummary/semantic_router.hybrid_layer.HybridRouteLayer.rst +++ b/docs/source/_autosummary/semantic_router.hybrid_layer.HybridRouteLayer.rst @@ -1,4 +1,4 @@ -semantic\_router.hybrid\_layer.HybridRouteLayer +semantic\_router.hybrid\_layer.HybridRouteLayer =============================================== .. currentmodule:: semantic_router.hybrid_layer diff --git a/docs/source/_autosummary/semantic_router.index.base.BaseIndex.rst b/docs/source/_autosummary/semantic_router.index.base.BaseIndex.rst index b0b423ea9a63d7cd4ae43fa3d8ade3a4df408ea4..f99b4b128bab2059b7671aa21e64d7d5584ef4a8 100644 --- a/docs/source/_autosummary/semantic_router.index.base.BaseIndex.rst +++ b/docs/source/_autosummary/semantic_router.index.base.BaseIndex.rst @@ -1,4 +1,4 @@ -semantic\_router.index.base.BaseIndex +semantic\_router.index.base.BaseIndex ===================================== .. currentmodule:: semantic_router.index.base @@ -18,6 +18,7 @@ semantic\_router.index.base.BaseIndex ~BaseIndex.__init__ ~BaseIndex.add + ~BaseIndex.aget_routes ~BaseIndex.aquery ~BaseIndex.construct ~BaseIndex.copy @@ -26,6 +27,7 @@ semantic\_router.index.base.BaseIndex ~BaseIndex.describe ~BaseIndex.dict ~BaseIndex.from_orm + ~BaseIndex.get_routes ~BaseIndex.json ~BaseIndex.parse_file ~BaseIndex.parse_obj diff --git a/docs/source/_autosummary/semantic_router.index.local.LocalIndex.rst b/docs/source/_autosummary/semantic_router.index.local.LocalIndex.rst index c6d000266e1abde873a2b087ef2110a73fc52417..c38c48e1aa23e9275b7bd9b4fff87f18e462806c 100644 --- a/docs/source/_autosummary/semantic_router.index.local.LocalIndex.rst +++ b/docs/source/_autosummary/semantic_router.index.local.LocalIndex.rst @@ -1,4 +1,4 @@ -semantic\_router.index.local.LocalIndex +semantic\_router.index.local.LocalIndex ======================================= .. currentmodule:: semantic_router.index.local @@ -18,6 +18,7 @@ semantic\_router.index.local.LocalIndex ~LocalIndex.__init__ ~LocalIndex.add + ~LocalIndex.aget_routes ~LocalIndex.aquery ~LocalIndex.construct ~LocalIndex.copy diff --git a/docs/source/_autosummary/semantic_router.index.pinecone.PineconeIndex.rst b/docs/source/_autosummary/semantic_router.index.pinecone.PineconeIndex.rst index 6e8007381de79f78f29d0d988eb420e708e2fd1f..8cef27267e0544a1f985e9e9195b836fcba75ef1 100644 --- a/docs/source/_autosummary/semantic_router.index.pinecone.PineconeIndex.rst +++ b/docs/source/_autosummary/semantic_router.index.pinecone.PineconeIndex.rst @@ -1,4 +1,4 @@ -semantic\_router.index.pinecone.PineconeIndex +semantic\_router.index.pinecone.PineconeIndex ============================================= .. currentmodule:: semantic_router.index.pinecone @@ -18,6 +18,7 @@ semantic\_router.index.pinecone.PineconeIndex ~PineconeIndex.__init__ ~PineconeIndex.add + ~PineconeIndex.aget_routes ~PineconeIndex.aquery ~PineconeIndex.construct ~PineconeIndex.copy diff --git a/docs/source/_autosummary/semantic_router.index.pinecone.PineconeRecord.rst b/docs/source/_autosummary/semantic_router.index.pinecone.PineconeRecord.rst index cc88ffe4fa6c5f609d0303d7f071cc59a1a6b27d..5c5f8d9a1314ee50629aba8a57d28d390486b7c8 100644 --- a/docs/source/_autosummary/semantic_router.index.pinecone.PineconeRecord.rst +++ b/docs/source/_autosummary/semantic_router.index.pinecone.PineconeRecord.rst @@ -1,4 +1,4 @@ -semantic\_router.index.pinecone.PineconeRecord +semantic\_router.index.pinecone.PineconeRecord ============================================== .. currentmodule:: semantic_router.index.pinecone diff --git a/docs/source/_autosummary/semantic_router.index.postgres.MetricPgVecOperatorMap.rst b/docs/source/_autosummary/semantic_router.index.postgres.MetricPgVecOperatorMap.rst new file mode 100644 index 0000000000000000000000000000000000000000..99ab2ce29bfe4ac7daab7f8abd063800055123e4 --- /dev/null +++ b/docs/source/_autosummary/semantic_router.index.postgres.MetricPgVecOperatorMap.rst @@ -0,0 +1,28 @@ +semantic\_router.index.postgres.MetricPgVecOperatorMap +====================================================== + +.. currentmodule:: semantic_router.index.postgres + +.. autoclass:: MetricPgVecOperatorMap + :members: + :show-inheritance: + :inherited-members: + + + .. automethod:: __init__ + + + + + + + .. rubric:: Attributes + + .. autosummary:: + + ~MetricPgVecOperatorMap.cosine + ~MetricPgVecOperatorMap.dotproduct + ~MetricPgVecOperatorMap.euclidean + ~MetricPgVecOperatorMap.manhattan + + \ No newline at end of file diff --git a/docs/source/_autosummary/semantic_router.index.postgres.PostgresIndex.rst b/docs/source/_autosummary/semantic_router.index.postgres.PostgresIndex.rst new file mode 100644 index 0000000000000000000000000000000000000000..3e435938f8cb4712f7ce85704f395976cd431d63 --- /dev/null +++ b/docs/source/_autosummary/semantic_router.index.postgres.PostgresIndex.rst @@ -0,0 +1,65 @@ +semantic\_router.index.postgres.PostgresIndex +============================================= + +.. currentmodule:: semantic_router.index.postgres + +.. autoclass:: PostgresIndex + :members: + :show-inheritance: + :inherited-members: + + + .. automethod:: __init__ + + + .. rubric:: Methods + + .. autosummary:: + + ~PostgresIndex.__init__ + ~PostgresIndex.add + ~PostgresIndex.aget_routes + ~PostgresIndex.aquery + ~PostgresIndex.construct + ~PostgresIndex.copy + ~PostgresIndex.delete + ~PostgresIndex.delete_all + ~PostgresIndex.delete_index + ~PostgresIndex.describe + ~PostgresIndex.dict + ~PostgresIndex.from_orm + ~PostgresIndex.get_routes + ~PostgresIndex.json + ~PostgresIndex.parse_file + ~PostgresIndex.parse_obj + ~PostgresIndex.parse_raw + ~PostgresIndex.query + ~PostgresIndex.schema + ~PostgresIndex.schema_json + ~PostgresIndex.setup_index + ~PostgresIndex.update_forward_refs + ~PostgresIndex.validate + + + + + + .. rubric:: Attributes + + .. autosummary:: + + ~PostgresIndex.connection_string + ~PostgresIndex.index_prefix + ~PostgresIndex.index_name + ~PostgresIndex.dimensions + ~PostgresIndex.metric + ~PostgresIndex.namespace + ~PostgresIndex.conn + ~PostgresIndex.type + ~PostgresIndex.index + ~PostgresIndex.routes + ~PostgresIndex.utterances + ~PostgresIndex.init_async_index + ~PostgresIndex.sync + + \ No newline at end of file diff --git a/docs/source/_autosummary/semantic_router.index.postgres.PostgresIndexRecord.rst b/docs/source/_autosummary/semantic_router.index.postgres.PostgresIndexRecord.rst new file mode 100644 index 0000000000000000000000000000000000000000..85408f389338ebd42642a5b2b4382540d867f49c --- /dev/null +++ b/docs/source/_autosummary/semantic_router.index.postgres.PostgresIndexRecord.rst @@ -0,0 +1,63 @@ +semantic\_router.index.postgres.PostgresIndexRecord +=================================================== + +.. currentmodule:: semantic_router.index.postgres + +.. autoclass:: PostgresIndexRecord + :members: + :show-inheritance: + :inherited-members: + + + .. automethod:: __init__ + + + .. rubric:: Methods + + .. autosummary:: + + ~PostgresIndexRecord.__init__ + ~PostgresIndexRecord.construct + ~PostgresIndexRecord.copy + ~PostgresIndexRecord.dict + ~PostgresIndexRecord.from_orm + ~PostgresIndexRecord.json + ~PostgresIndexRecord.model_construct + ~PostgresIndexRecord.model_copy + ~PostgresIndexRecord.model_dump + ~PostgresIndexRecord.model_dump_json + ~PostgresIndexRecord.model_json_schema + ~PostgresIndexRecord.model_parametrized_name + ~PostgresIndexRecord.model_post_init + ~PostgresIndexRecord.model_rebuild + ~PostgresIndexRecord.model_validate + ~PostgresIndexRecord.model_validate_json + ~PostgresIndexRecord.model_validate_strings + ~PostgresIndexRecord.parse_file + ~PostgresIndexRecord.parse_obj + ~PostgresIndexRecord.parse_raw + ~PostgresIndexRecord.schema + ~PostgresIndexRecord.schema_json + ~PostgresIndexRecord.to_dict + ~PostgresIndexRecord.update_forward_refs + ~PostgresIndexRecord.validate + + + + + + .. rubric:: Attributes + + .. autosummary:: + + ~PostgresIndexRecord.model_computed_fields + ~PostgresIndexRecord.model_config + ~PostgresIndexRecord.model_extra + ~PostgresIndexRecord.model_fields + ~PostgresIndexRecord.model_fields_set + ~PostgresIndexRecord.id + ~PostgresIndexRecord.route + ~PostgresIndexRecord.utterance + ~PostgresIndexRecord.vector + + \ No newline at end of file diff --git a/docs/source/_autosummary/semantic_router.index.postgres.clean_route_name.rst b/docs/source/_autosummary/semantic_router.index.postgres.clean_route_name.rst new file mode 100644 index 0000000000000000000000000000000000000000..326bac5a7a8ded983bd0701f414ded7faa8e03dd --- /dev/null +++ b/docs/source/_autosummary/semantic_router.index.postgres.clean_route_name.rst @@ -0,0 +1,6 @@ +semantic\_router.index.postgres.clean\_route\_name +================================================== + +.. currentmodule:: semantic_router.index.postgres + +.. autofunction:: clean_route_name \ No newline at end of file diff --git a/docs/source/_autosummary/semantic_router.index.postgres.parse_vector.rst b/docs/source/_autosummary/semantic_router.index.postgres.parse_vector.rst new file mode 100644 index 0000000000000000000000000000000000000000..ba1b2b2a50c7f663941bc3cdff4fd0f04726fe03 --- /dev/null +++ b/docs/source/_autosummary/semantic_router.index.postgres.parse_vector.rst @@ -0,0 +1,6 @@ +semantic\_router.index.postgres.parse\_vector +============================================= + +.. currentmodule:: semantic_router.index.postgres + +.. autofunction:: parse_vector \ No newline at end of file diff --git a/docs/source/_autosummary/semantic_router.index.postgres.rst b/docs/source/_autosummary/semantic_router.index.postgres.rst new file mode 100644 index 0000000000000000000000000000000000000000..3bfef78aeb8a69cd2c3dd230925d1591e105aefe --- /dev/null +++ b/docs/source/_autosummary/semantic_router.index.postgres.rst @@ -0,0 +1,41 @@ +semantic\_router.index.postgres +=============================== + +.. automodule:: semantic_router.index.postgres + + + + + + + + .. rubric:: Functions + + .. autosummary:: + :toctree: + + clean_route_name + parse_vector + + + + + + .. rubric:: Classes + + .. autosummary:: + :toctree: + :template: custom-class-template.rst + + MetricPgVecOperatorMap + PostgresIndex + PostgresIndexRecord + + + + + + + + + diff --git a/docs/source/_autosummary/semantic_router.index.qdrant.QdrantIndex.rst b/docs/source/_autosummary/semantic_router.index.qdrant.QdrantIndex.rst index 87379adec92bfd0f1de31ede10d29a19587ec2de..bc1dd7829437e52c5202ecd343299bfb81a140d8 100644 --- a/docs/source/_autosummary/semantic_router.index.qdrant.QdrantIndex.rst +++ b/docs/source/_autosummary/semantic_router.index.qdrant.QdrantIndex.rst @@ -1,4 +1,4 @@ -semantic\_router.index.qdrant.QdrantIndex +semantic\_router.index.qdrant.QdrantIndex ========================================= .. currentmodule:: semantic_router.index.qdrant @@ -18,6 +18,7 @@ semantic\_router.index.qdrant.QdrantIndex ~QdrantIndex.__init__ ~QdrantIndex.add + ~QdrantIndex.aget_routes ~QdrantIndex.aquery ~QdrantIndex.construct ~QdrantIndex.convert_metric diff --git a/docs/source/_autosummary/semantic_router.index.rst b/docs/source/_autosummary/semantic_router.index.rst index 7925fbddb0823d31c46ada9c5ea0693d74a99865..e48fb3838aec87a5a186ffc9e2ff26b2fe9b9d0f 100644 --- a/docs/source/_autosummary/semantic_router.index.rst +++ b/docs/source/_autosummary/semantic_router.index.rst @@ -1,4 +1,4 @@ -semantic\_router.index +semantic\_router.index ====================== .. automodule:: semantic_router.index @@ -31,5 +31,6 @@ semantic\_router.index semantic_router.index.base semantic_router.index.local semantic_router.index.pinecone + semantic_router.index.postgres semantic_router.index.qdrant diff --git a/docs/source/_autosummary/semantic_router.layer.LayerConfig.rst b/docs/source/_autosummary/semantic_router.layer.LayerConfig.rst index e477eea55c497a9524b6536b7ec0c2c007c44656..b49febe2fd9a54cc891b6c65f237c72d9e88b531 100644 --- a/docs/source/_autosummary/semantic_router.layer.LayerConfig.rst +++ b/docs/source/_autosummary/semantic_router.layer.LayerConfig.rst @@ -1,4 +1,4 @@ -semantic\_router.layer.LayerConfig +semantic\_router.layer.LayerConfig ================================== .. currentmodule:: semantic_router.layer diff --git a/docs/source/_autosummary/semantic_router.layer.RouteLayer.rst b/docs/source/_autosummary/semantic_router.layer.RouteLayer.rst index 11c02875d54fc76d12b90caa914dd52cbb948522..4acccc8900e642439acd09565a874eddb6fdb712 100644 --- a/docs/source/_autosummary/semantic_router.layer.RouteLayer.rst +++ b/docs/source/_autosummary/semantic_router.layer.RouteLayer.rst @@ -1,4 +1,4 @@ -semantic\_router.layer.RouteLayer +semantic\_router.layer.RouteLayer ================================= .. currentmodule:: semantic_router.layer diff --git a/docs/source/_autosummary/semantic_router.llms.base.BaseLLM.rst b/docs/source/_autosummary/semantic_router.llms.base.BaseLLM.rst index b53d0116de11956360c60414f73a809a9209e76b..cac8beaee6a221899d86785f81aa96018a5f97c2 100644 --- a/docs/source/_autosummary/semantic_router.llms.base.BaseLLM.rst +++ b/docs/source/_autosummary/semantic_router.llms.base.BaseLLM.rst @@ -1,4 +1,4 @@ -semantic\_router.llms.base.BaseLLM +semantic\_router.llms.base.BaseLLM ================================== .. currentmodule:: semantic_router.llms.base diff --git a/docs/source/_autosummary/semantic_router.llms.cohere.CohereLLM.rst b/docs/source/_autosummary/semantic_router.llms.cohere.CohereLLM.rst index a7422525a56dfa979432950548c52c7adda04789..3281652cf1c7933a38140561d1e00d9abc9fdf8c 100644 --- a/docs/source/_autosummary/semantic_router.llms.cohere.CohereLLM.rst +++ b/docs/source/_autosummary/semantic_router.llms.cohere.CohereLLM.rst @@ -1,4 +1,4 @@ -semantic\_router.llms.cohere.CohereLLM +semantic\_router.llms.cohere.CohereLLM ====================================== .. currentmodule:: semantic_router.llms.cohere diff --git a/docs/source/_autosummary/semantic_router.llms.llamacpp.LlamaCppLLM.rst b/docs/source/_autosummary/semantic_router.llms.llamacpp.LlamaCppLLM.rst index 055a6536e0cf27fc8e26fd142d36d39c7713c2ec..d7c86b28b61173850f0406fe06a575629e39be2e 100644 --- a/docs/source/_autosummary/semantic_router.llms.llamacpp.LlamaCppLLM.rst +++ b/docs/source/_autosummary/semantic_router.llms.llamacpp.LlamaCppLLM.rst @@ -1,4 +1,4 @@ -semantic\_router.llms.llamacpp.LlamaCppLLM +semantic\_router.llms.llamacpp.LlamaCppLLM ========================================== .. currentmodule:: semantic_router.llms.llamacpp diff --git a/docs/source/_autosummary/semantic_router.llms.mistral.MistralAILLM.rst b/docs/source/_autosummary/semantic_router.llms.mistral.MistralAILLM.rst index a865730b2514064eb53624e2321a39741413031b..1f8db49d5f9930b1c577834c019a2da6e1b65a8a 100644 --- a/docs/source/_autosummary/semantic_router.llms.mistral.MistralAILLM.rst +++ b/docs/source/_autosummary/semantic_router.llms.mistral.MistralAILLM.rst @@ -1,4 +1,4 @@ -semantic\_router.llms.mistral.MistralAILLM +semantic\_router.llms.mistral.MistralAILLM ========================================== .. currentmodule:: semantic_router.llms.mistral diff --git a/docs/source/_autosummary/semantic_router.llms.ollama.OllamaLLM.rst b/docs/source/_autosummary/semantic_router.llms.ollama.OllamaLLM.rst index 0538d2e7fbf6df5dd2f73cdfe5f154c3a2689f15..0dcaa469bc7a8fe335a1886c9e389c0897c497cf 100644 --- a/docs/source/_autosummary/semantic_router.llms.ollama.OllamaLLM.rst +++ b/docs/source/_autosummary/semantic_router.llms.ollama.OllamaLLM.rst @@ -1,4 +1,4 @@ -semantic\_router.llms.ollama.OllamaLLM +semantic\_router.llms.ollama.OllamaLLM ====================================== .. currentmodule:: semantic_router.llms.ollama diff --git a/docs/source/_autosummary/semantic_router.llms.openai.OpenAILLM.rst b/docs/source/_autosummary/semantic_router.llms.openai.OpenAILLM.rst index c203c2b256fe4ea3dfc6c7025bda484cafe2657a..42e834e47a1006ad2d55b03a176613c736962c20 100644 --- a/docs/source/_autosummary/semantic_router.llms.openai.OpenAILLM.rst +++ b/docs/source/_autosummary/semantic_router.llms.openai.OpenAILLM.rst @@ -1,4 +1,4 @@ -semantic\_router.llms.openai.OpenAILLM +semantic\_router.llms.openai.OpenAILLM ====================================== .. currentmodule:: semantic_router.llms.openai diff --git a/docs/source/_autosummary/semantic_router.llms.openrouter.OpenRouterLLM.rst b/docs/source/_autosummary/semantic_router.llms.openrouter.OpenRouterLLM.rst index 710603949c6bc801036ce97c65d8cbede9762b8d..8024ce200cbcf01379d38d550effbcd16e8a326e 100644 --- a/docs/source/_autosummary/semantic_router.llms.openrouter.OpenRouterLLM.rst +++ b/docs/source/_autosummary/semantic_router.llms.openrouter.OpenRouterLLM.rst @@ -1,4 +1,4 @@ -semantic\_router.llms.openrouter.OpenRouterLLM +semantic\_router.llms.openrouter.OpenRouterLLM ============================================== .. currentmodule:: semantic_router.llms.openrouter diff --git a/docs/source/_autosummary/semantic_router.llms.zure.AzureOpenAILLM.rst b/docs/source/_autosummary/semantic_router.llms.zure.AzureOpenAILLM.rst index c94ac8e02b26ec5a4a125521948ecae9cae38d80..f3d341e8a5d2f1a4314bf0bdebbf4f0ee5e50a7f 100644 --- a/docs/source/_autosummary/semantic_router.llms.zure.AzureOpenAILLM.rst +++ b/docs/source/_autosummary/semantic_router.llms.zure.AzureOpenAILLM.rst @@ -1,4 +1,4 @@ -semantic\_router.llms.zure.AzureOpenAILLM +semantic\_router.llms.zure.AzureOpenAILLM ========================================= .. currentmodule:: semantic_router.llms.zure diff --git a/docs/source/_autosummary/semantic_router.route.Route.rst b/docs/source/_autosummary/semantic_router.route.Route.rst index 4a5f3449ca40420afcf22017fca88e39e4a21a9e..24b326001f70bdff252171b6d7b6cfb4b5198b61 100644 --- a/docs/source/_autosummary/semantic_router.route.Route.rst +++ b/docs/source/_autosummary/semantic_router.route.Route.rst @@ -1,4 +1,4 @@ -semantic\_router.route.Route +semantic\_router.route.Route ============================ .. currentmodule:: semantic_router.route diff --git a/docs/source/_autosummary/semantic_router.schema.DocumentSplit.rst b/docs/source/_autosummary/semantic_router.schema.DocumentSplit.rst index f2e556fa2a34d0a30ec6fc15453acf5df8b859f1..2a25758dabbc21116a3045fb2a9c8d85af1f8a04 100644 --- a/docs/source/_autosummary/semantic_router.schema.DocumentSplit.rst +++ b/docs/source/_autosummary/semantic_router.schema.DocumentSplit.rst @@ -1,4 +1,4 @@ -semantic\_router.schema.DocumentSplit +semantic\_router.schema.DocumentSplit ===================================== .. currentmodule:: semantic_router.schema diff --git a/docs/source/_autosummary/semantic_router.schema.EncoderInfo.rst b/docs/source/_autosummary/semantic_router.schema.EncoderInfo.rst index bff52290b38107b396b18aac9109933ccb30fb85..cedf408817882bcba8949fe66e758210254b4cf8 100644 --- a/docs/source/_autosummary/semantic_router.schema.EncoderInfo.rst +++ b/docs/source/_autosummary/semantic_router.schema.EncoderInfo.rst @@ -1,4 +1,4 @@ -semantic\_router.schema.EncoderInfo +semantic\_router.schema.EncoderInfo =================================== .. currentmodule:: semantic_router.schema diff --git a/docs/source/_autosummary/semantic_router.schema.EncoderType.rst b/docs/source/_autosummary/semantic_router.schema.EncoderType.rst index 3f69d02673ec1348d00d276647a2275ab492bb67..64fdb55814a353f019138ab54adb8441502eba08 100644 --- a/docs/source/_autosummary/semantic_router.schema.EncoderType.rst +++ b/docs/source/_autosummary/semantic_router.schema.EncoderType.rst @@ -1,4 +1,4 @@ -semantic\_router.schema.EncoderType +semantic\_router.schema.EncoderType =================================== .. currentmodule:: semantic_router.schema diff --git a/docs/source/_autosummary/semantic_router.schema.Message.rst b/docs/source/_autosummary/semantic_router.schema.Message.rst index 184c7e85bc83eae5a7c53eb739cc576a6325fe9f..2f8a893a5893ff5e14eba67700140aa19feebd30 100644 --- a/docs/source/_autosummary/semantic_router.schema.Message.rst +++ b/docs/source/_autosummary/semantic_router.schema.Message.rst @@ -1,4 +1,4 @@ -semantic\_router.schema.Message +semantic\_router.schema.Message =============================== .. currentmodule:: semantic_router.schema diff --git a/docs/source/_autosummary/semantic_router.schema.Metric.rst b/docs/source/_autosummary/semantic_router.schema.Metric.rst index d7904b2b4cb40eb8ea95b0fb5203e99bf3c8810b..f7fd0535e938ec5cf4e13e0cfef017efc29474c2 100644 --- a/docs/source/_autosummary/semantic_router.schema.Metric.rst +++ b/docs/source/_autosummary/semantic_router.schema.Metric.rst @@ -1,4 +1,4 @@ -semantic\_router.schema.Metric +semantic\_router.schema.Metric ============================== .. currentmodule:: semantic_router.schema diff --git a/docs/source/_autosummary/semantic_router.schema.RouteChoice.rst b/docs/source/_autosummary/semantic_router.schema.RouteChoice.rst index 79c627d2277b85560b10485aa0c91b3f4576995f..f9249dfaad9f87ee0a780dc201a615ff20803f22 100644 --- a/docs/source/_autosummary/semantic_router.schema.RouteChoice.rst +++ b/docs/source/_autosummary/semantic_router.schema.RouteChoice.rst @@ -1,4 +1,4 @@ -semantic\_router.schema.RouteChoice +semantic\_router.schema.RouteChoice =================================== .. currentmodule:: semantic_router.schema diff --git a/docs/source/_autosummary/semantic_router.splitters.base.BaseSplitter.rst b/docs/source/_autosummary/semantic_router.splitters.base.BaseSplitter.rst index 4e8f3f11b2097e494d28233f37bc5092b08557fc..274f88f99e02f190bfb1dc6b3cd791b11be181b3 100644 --- a/docs/source/_autosummary/semantic_router.splitters.base.BaseSplitter.rst +++ b/docs/source/_autosummary/semantic_router.splitters.base.BaseSplitter.rst @@ -1,4 +1,4 @@ -semantic\_router.splitters.base.BaseSplitter +semantic\_router.splitters.base.BaseSplitter ============================================ .. currentmodule:: semantic_router.splitters.base diff --git a/docs/source/_autosummary/semantic_router.splitters.consecutive_sim.ConsecutiveSimSplitter.rst b/docs/source/_autosummary/semantic_router.splitters.consecutive_sim.ConsecutiveSimSplitter.rst index 5a4649517ee1dd520c80865a2119826467358af9..b955aefbc998b690ef2c380754f037800188ad80 100644 --- a/docs/source/_autosummary/semantic_router.splitters.consecutive_sim.ConsecutiveSimSplitter.rst +++ b/docs/source/_autosummary/semantic_router.splitters.consecutive_sim.ConsecutiveSimSplitter.rst @@ -1,4 +1,4 @@ -semantic\_router.splitters.consecutive\_sim.ConsecutiveSimSplitter +semantic\_router.splitters.consecutive\_sim.ConsecutiveSimSplitter ================================================================== .. currentmodule:: semantic_router.splitters.consecutive_sim diff --git a/docs/source/_autosummary/semantic_router.splitters.cumulative_sim.CumulativeSimSplitter.rst b/docs/source/_autosummary/semantic_router.splitters.cumulative_sim.CumulativeSimSplitter.rst index 7b99020983d5460531d045d724d32ce1dcbe1aec..f3f5217b2d4a29599183e306c8c1faf408c84570 100644 --- a/docs/source/_autosummary/semantic_router.splitters.cumulative_sim.CumulativeSimSplitter.rst +++ b/docs/source/_autosummary/semantic_router.splitters.cumulative_sim.CumulativeSimSplitter.rst @@ -1,4 +1,4 @@ -semantic\_router.splitters.cumulative\_sim.CumulativeSimSplitter +semantic\_router.splitters.cumulative\_sim.CumulativeSimSplitter ================================================================ .. currentmodule:: semantic_router.splitters.cumulative_sim diff --git a/docs/source/_autosummary/semantic_router.splitters.rolling_window.RollingWindowSplitter.rst b/docs/source/_autosummary/semantic_router.splitters.rolling_window.RollingWindowSplitter.rst index 48e6d57f65c2b52b047777cf1e68be254daca788..8be63f50ac990d47d4e62d3f82ec529c1f45acf9 100644 --- a/docs/source/_autosummary/semantic_router.splitters.rolling_window.RollingWindowSplitter.rst +++ b/docs/source/_autosummary/semantic_router.splitters.rolling_window.RollingWindowSplitter.rst @@ -1,4 +1,4 @@ -semantic\_router.splitters.rolling\_window.RollingWindowSplitter +semantic\_router.splitters.rolling\_window.RollingWindowSplitter ================================================================ .. currentmodule:: semantic_router.splitters.rolling_window diff --git a/docs/source/_autosummary/semantic_router.splitters.rolling_window.SplitStatistics.rst b/docs/source/_autosummary/semantic_router.splitters.rolling_window.SplitStatistics.rst index be102ef7a848dc621b2ff26c281aca904c7ae406..f2dd88774142bee49e2f57efa64fbd4415b49286 100644 --- a/docs/source/_autosummary/semantic_router.splitters.rolling_window.SplitStatistics.rst +++ b/docs/source/_autosummary/semantic_router.splitters.rolling_window.SplitStatistics.rst @@ -1,4 +1,4 @@ -semantic\_router.splitters.rolling\_window.SplitStatistics +semantic\_router.splitters.rolling\_window.SplitStatistics ========================================================== .. currentmodule:: semantic_router.splitters.rolling_window diff --git a/docs/source/_autosummary/semantic_router.text.Conversation.rst b/docs/source/_autosummary/semantic_router.text.Conversation.rst index 07921466ee986e032e78fc80cfa5ebe5d244a738..adfaf88bd24b9254f151f39ba0976c563b409385 100644 --- a/docs/source/_autosummary/semantic_router.text.Conversation.rst +++ b/docs/source/_autosummary/semantic_router.text.Conversation.rst @@ -1,4 +1,4 @@ -semantic\_router.text.Conversation +semantic\_router.text.Conversation ================================== .. currentmodule:: semantic_router.text diff --git a/docs/source/_autosummary/semantic_router.utils.defaults.EncoderDefault.rst b/docs/source/_autosummary/semantic_router.utils.defaults.EncoderDefault.rst index 47d8b21f117c7d9785d3df2e678ff31bf6465ede..a1babfa0a66f98e3c76ff2fee2e476c1f7f2bbb2 100644 --- a/docs/source/_autosummary/semantic_router.utils.defaults.EncoderDefault.rst +++ b/docs/source/_autosummary/semantic_router.utils.defaults.EncoderDefault.rst @@ -1,4 +1,4 @@ -semantic\_router.utils.defaults.EncoderDefault +semantic\_router.utils.defaults.EncoderDefault ============================================== .. currentmodule:: semantic_router.utils.defaults diff --git a/docs/source/_autosummary/semantic_router.utils.function_call.FunctionSchema.rst b/docs/source/_autosummary/semantic_router.utils.function_call.FunctionSchema.rst new file mode 100644 index 0000000000000000000000000000000000000000..32cbf6b55e9559337e4725958009cc6d7f0d3753 --- /dev/null +++ b/docs/source/_autosummary/semantic_router.utils.function_call.FunctionSchema.rst @@ -0,0 +1,36 @@ +semantic\_router.utils.function\_call.FunctionSchema +==================================================== + +.. currentmodule:: semantic_router.utils.function_call + +.. autoclass:: FunctionSchema + :members: + :show-inheritance: + :inherited-members: + + + .. automethod:: __init__ + + + .. rubric:: Methods + + .. autosummary:: + + ~FunctionSchema.__init__ + ~FunctionSchema.to_ollama + + + + + + .. rubric:: Attributes + + .. autosummary:: + + ~FunctionSchema.description + ~FunctionSchema.name + ~FunctionSchema.output + ~FunctionSchema.parameters + ~FunctionSchema.signature + + \ No newline at end of file diff --git a/docs/source/_autosummary/semantic_router.utils.function_call.Parameter.rst b/docs/source/_autosummary/semantic_router.utils.function_call.Parameter.rst new file mode 100644 index 0000000000000000000000000000000000000000..60c5a24360c5d28a519fa134046f684854e0e434 --- /dev/null +++ b/docs/source/_autosummary/semantic_router.utils.function_call.Parameter.rst @@ -0,0 +1,48 @@ +semantic\_router.utils.function\_call.Parameter +=============================================== + +.. currentmodule:: semantic_router.utils.function_call + +.. autoclass:: Parameter + :members: + :show-inheritance: + :inherited-members: + + + .. automethod:: __init__ + + + .. rubric:: Methods + + .. autosummary:: + + ~Parameter.__init__ + ~Parameter.construct + ~Parameter.copy + ~Parameter.dict + ~Parameter.from_orm + ~Parameter.json + ~Parameter.parse_file + ~Parameter.parse_obj + ~Parameter.parse_raw + ~Parameter.schema + ~Parameter.schema_json + ~Parameter.to_ollama + ~Parameter.update_forward_refs + ~Parameter.validate + + + + + + .. rubric:: Attributes + + .. autosummary:: + + ~Parameter.name + ~Parameter.description + ~Parameter.type + ~Parameter.default + ~Parameter.required + + \ No newline at end of file diff --git a/docs/source/_autosummary/semantic_router.utils.function_call.rst b/docs/source/_autosummary/semantic_router.utils.function_call.rst index 7df22f9a8fbbf6a9891d53cc66142a73642ce04d..5c2a69619abe3582fa43ab24fff90aa9a81ed41c 100644 --- a/docs/source/_autosummary/semantic_router.utils.function_call.rst +++ b/docs/source/_autosummary/semantic_router.utils.function_call.rst @@ -1,4 +1,4 @@ -semantic\_router.utils.function\_call +semantic\_router.utils.function\_call ===================================== .. automodule:: semantic_router.utils.function_call @@ -23,6 +23,15 @@ semantic\_router.utils.function\_call + .. rubric:: Classes + + .. autosummary:: + :toctree: + :template: custom-class-template.rst + + FunctionSchema + Parameter + diff --git a/docs/source/_autosummary/semantic_router.utils.logger.CustomFormatter.rst b/docs/source/_autosummary/semantic_router.utils.logger.CustomFormatter.rst index cf6971d81830630144fa2ab3f270d30d10c51599..3ad99855693c2439b660f86d825db7a6d9642f29 100644 --- a/docs/source/_autosummary/semantic_router.utils.logger.CustomFormatter.rst +++ b/docs/source/_autosummary/semantic_router.utils.logger.CustomFormatter.rst @@ -1,4 +1,4 @@ -semantic\_router.utils.logger.CustomFormatter +semantic\_router.utils.logger.CustomFormatter ============================================= .. currentmodule:: semantic_router.utils.logger diff --git a/docs/source/api.rst b/docs/source/api.rst deleted file mode 100644 index 7ddaf33c8ffdfe823a9d3d5fad985b7c8188ec01..0000000000000000000000000000000000000000 --- a/docs/source/api.rst +++ /dev/null @@ -1,9 +0,0 @@ -API -=== - -.. autosummary:: - :toctree: _autosummary - :template: custom-module-template.rst - :recursive: - - semantic_router \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index 7978059288617ec677b4e2754cc47bca4a5ccdcb..2f233085feb109e20cde1ac9c10a6c8044ed8f30 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,6 +1,15 @@ Semantic Router documentation ============================= +.. toctree:: + :hidden: + :maxdepth: 2 + + Home page <self> + Quickstart <quickstart> + Route Layer <route_layer> + API reference <_autosummary/semantic_router> + Semantic Router is a superfast decision-making layer for your LLMs and agents. Rather than waiting for slow LLM generations to make tool-use decisions, we use the magic of semantic vector space to make those decisions — *routing* our requests using *semantic* meaning. Integrations @@ -10,10 +19,3 @@ The *encoders* of semantic router include easy-to-use integrations with `Cohere Our utterance vector space also integrates with `Pinecone <https://github.com/aurelio-labs/semantic-router/blob/main/docs/indexes/pinecone.ipynb>`_ and `Qdrant <https://github.com/aurelio-labs/semantic-router/blob/main/docs/indexes/qdrant.ipynb>`_! -.. toctree:: - :hidden: - - Home page <self> - Quickstart <quickstart> - Jupyter tutorials <tutorials> - API reference <_autosummary/semantic_router> diff --git a/docs/source/route_layer.rst b/docs/source/route_layer.rst new file mode 100644 index 0000000000000000000000000000000000000000..04d23af52ebbf52ddb472de6c510b63e915f0643 --- /dev/null +++ b/docs/source/route_layer.rst @@ -0,0 +1,130 @@ +Route Layer +=========== + +The `RouteLayer` is the main class of the semantic router. It is responsible +for making decisions about which route to take based on an input utterance. +A `RouteLayer` consists of an `encoder`, an `index`, and a list of `routes`. +Route layers that include dynamic routes (i.e. routes that can generate dynamic +decision outputs) also include an `llm`. + +.. toctree:: + :hidden: + :maxdepth: 2 + :glob: + + route_layer/* + +To use a `RouteLayer` we first need some `routes`. We can initialize them like +so: + +.. code-block:: python + + from semantic_router import Route + + politics = Route( + name="politics", + utterances=[ + "isn't politics the best thing ever", + "why don't you tell me about your political opinions", + "don't you just love the president", + "don't you just hate the president", + "they're going to destroy this country!", + "they will save the country!", + ], + ) + + chitchat = Route( + name="chitchat", + utterances=[ + "how's the weather today?", + "how are things going?", + "lovely weather today", + "the weather is horrendous", + "let's go to the chippy", + ], + ) + +We initialize an encoder — there are many options available here, from local +to API-based. For now we'll use the `OpenAIEncoder`. + +.. code-block:: python + + import os + from semantic_router.encoders import OpenAIEncoder + + os.environ["OPENAI_API_KEY"] = "<YOUR_API_KEY>" + + encoder = OpenAIEncoder() + +Now we define the `RouteLayer`. When called, the route layer will consume text +(a query) and output the category (`Route`) it belongs to — to initialize a +`RouteLayer` we need our `encoder` model and a list of `routes`. + +.. code-block:: python + + from semantic_router.layer import RouteLayer + + rl = RouteLayer(encoder=encoder, routes=routes) + +Now we can call the `RouteLayer` with an input query: + +.. code-block:: python + + rl("don't you love politics?") + +.. code-block:: none + + [Out]: RouteChoice(name='politics', function_call=None, similarity_score=None) + +The output is a `RouteChoice` object, which contains the name of the route, +the function call (if any), and the similarity score that triggered the route +choice. + +We can try another query: + +.. code-block:: python + + rl("how's the weather today?") + +.. code-block:: none + + [Out]: RouteChoice(name='chitchat', function_call=None, similarity_score=None) + +Both are classified accurately, what if we send a query that is unrelated to +our existing Route objects? + +.. code-block:: python + + rl("I'm interested in learning about llama 3") + +.. code-block:: none + + [Out]: RouteChoice(name=None, function_call=None, similarity_score=None) + +In this case, the `RouteLayer` is unable to find a route that matches the +input query and so returns a `RouteChoice` with `name=None`. + +We can also retrieve multiple routes with their associated score using +`retrieve_multiple_routes`: + +.. code-block:: python + + rl.retrieve_multiple_routes("Hi! How are you doing in politics??") + +.. code-block:: none + + [Out]: [RouteChoice(name='politics', function_call=None, similarity_score=0.859), + RouteChoice(name='chitchat', function_call=None, similarity_score=0.835)] + +If `retrieve_multiple_routes` is called with a query that does not match any +routes, it will return an empty list: + +.. code-block:: python + + rl.retrieve_multiple_routes("I'm interested in learning about llama 3") + +.. code-block:: none + + [Out]: [] + +You can find an introductory notebook for the [route layer here](https://github.com/aurelio-labs/semantic-router/blob/main/docs/00-introduction.ipynb). diff --git a/docs/source/route_layer/route_filter.rst b/docs/source/route_layer/route_filter.rst new file mode 100644 index 0000000000000000000000000000000000000000..e4e43c2b04abd74540dc01dea5802d4a7e2ac0bb --- /dev/null +++ b/docs/source/route_layer/route_filter.rst @@ -0,0 +1,5 @@ +Calling the Route Layer +======================= + +You can use the `route_filter` parameter with a list of route names to filter +the routes that will be considered. \ No newline at end of file diff --git a/docs/source/route_layer/sync.rst b/docs/source/route_layer/sync.rst new file mode 100644 index 0000000000000000000000000000000000000000..ee471dc2b76af62f6db30325d714099380caf2cb --- /dev/null +++ b/docs/source/route_layer/sync.rst @@ -0,0 +1,68 @@ +Synchronizing with Remote Instances +=================================== + +Semantic router supports several *remote instances* that store our routes and +utterances, such as Pinecone or Qdrant, supported via the `PineconeIndex` and +`QdrantIndex` respectively. + +Using these remote instances is optional, but it allows us to scale our +semantic router to a larger number of routes and utterances. However, we must +decide how to synchronize between our local metadata and the remote instance — +particularly when reinitializing a local instance that should connect to an +existing remote instance. + +Semantic router supports several synchronization strategies that can be passed +to the `sync` parameter of the various `BaseIndex` objects. Those strategies +are: + +* `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. + +You can try this yourself by running the following: + +.. code-block:: python + + from semantic_router import Route + from semantic_router.encoders import OpenAIEncoder + from semantic_router.index.pinecone import PineconeIndex + from semantic_router.layer import RouteLayer + + + politics = Route( + name="politics", + utterances=[ + "isn't politics the best thing ever", + "why don't you tell me about your political opinions", + "don't you just love the president", + ], + ) + + chitchat = Route( + name="chitchat", + utterances=[ + "how's the weather today?", + "how are things going?", + ], + ) + + routes = [politics, chitchat] + + encoder = OpenAIEncoder(openai_api_key=openai_api_key) + + pc_index = PineconeIndex( + api_key=pinecone_api_key, + region="us-east-1", + index_name="sync-example", + sync="local", # here we specify the synchronization strategy + ) + + rl = RouteLayer(encoder=encoder, routes=routes, index=pc_index)