aurelio-labs / semantic-router

Superfast AI decision making and intelligent processing of multi-modal data.
https://www.aurelio.ai/semantic-router
MIT License
1.66k stars 168 forks source link

Results information #294

Open OmriBenShoham opened 1 month ago

OmriBenShoham commented 1 month ago

I am using the semantic route and I am missing the results explanation. If the threshold is passed/not-passed I expect that it will return the utterances score results, so I could understand how the Route utterances effected the results.

Currently as a result I get the RouteChoice object, but I can't find any relevant information except the name of the Route which does not help me understand the utterances scores.

Code example(I used your example):

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",
        "they're going to destroy this country!",
        "they will save the country!",
    ],
)

# this could be used as an indicator to our chatbot to switch to a more
# conversational prompt
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 place both of our decisions together into single list
routes = [politics, chitchat]

from semantic_router.layer import RouteLayer

rl = RouteLayer(encoder=encoder, routes=routes)
result = rl("don't you love politics?")

In this case the result will show politics, and I expect it to explain based on which of the utterances the decision done.

Is there any way I can retrieve this information?and if not is there any planning to implement this?

GalDayan commented 1 month ago

👍 Same here