From 954fc926786583a3a95de8e8eca1fd123587b41b Mon Sep 17 00:00:00 2001 From: Luca Mannini <dev@lucamannini.com> Date: Thu, 1 Feb 2024 17:54:48 +0100 Subject: [PATCH] Deleted main in layer.py --- semantic_router/layer.py | 50 ---------------------------------------- 1 file changed, 50 deletions(-) diff --git a/semantic_router/layer.py b/semantic_router/layer.py index 6f1b6a46..895e90a9 100644 --- a/semantic_router/layer.py +++ b/semantic_router/layer.py @@ -541,53 +541,3 @@ def threshold_random_search( for i, route in enumerate(route_names) } return score_thresholds - - -if __name__ == "__main__": - from semantic_router import Route - from semantic_router.encoders import OpenAIEncoder - from semantic_router.layer import RouteLayer - - # Define routes with example phrases - 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", - ], - ) - - routes = [politics, chitchat] - - # Initialize the encoder - encoder = OpenAIEncoder() - - # Initialize the RouteLayer with the encoder and routes - rl = RouteLayer(encoder=encoder, routes=routes) - - # Test the RouteLayer with example queries - print( - rl.retrieve_multiple_routes("how's the weather today?") - ) # Expected to match the chitchat route - print( - rl.retrieve_multiple_routes("don't you love politics?") - ) # Expected to match the politics route - print( - rl.retrieve_multiple_routes("I'm interested in learning about llama 2") - ) # Expected to return None since it doesn't match any route - print(rl.retrieve_multiple_routes("Hi! How are you doing in politics??")) -- GitLab