Skip to content
Snippets Groups Projects
Commit 954fc926 authored by Luca Mannini's avatar Luca Mannini
Browse files

Deleted main in layer.py

parent 809aa14e
No related branches found
No related tags found
No related merge requests found
...@@ -541,53 +541,3 @@ def threshold_random_search( ...@@ -541,53 +541,3 @@ def threshold_random_search(
for i, route in enumerate(route_names) for i, route in enumerate(route_names)
} }
return score_thresholds 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??"))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment