semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

.Net Add common finish reason to abstraction

Open Krzysztof318 opened this issue 1 year ago • 6 comments

Many models for example gemini/openai and others return at least 3 statuses: "FINISH SUCCESS", "CANCELLED DUE TO MODERATION", "OTHER REASON".

I think it's very important to kernel abstraction contains common for FunctionResult property FinishStatus. Property could be enum {SUCCESS, MODERATION, OTHER}. Currently to check finish status user have to check metadata which is another for each model.

I wonder how to do this without breaking change. I think good way is create nullable enum property FinishStatus in FunctionResult. Create something like IMetadaConverter and use its implementations from DI in KernelFunctionFactory classes.

Edit 25.01: Maybe connector should throw exception if due to moderation, model stops generating response, for example KernelException with special property i.e. finish reason? And what if model stops due to lenght or other finish reason? Should connectors throw exception or only return finisg status with content?

Krzysztof318 avatar Jan 16 '24 12:01 Krzysztof318

btw. for openai moderation violation status is stored in index PromptFilterResult in metadata? The ChangeTrackingList<PromptFilterResult> is always empty...

Krzysztof318 avatar Jan 24 '24 17:01 Krzysztof318

We need this change not to end up with something like this:

Image

Krzysztof318 avatar Jan 25 '24 10:01 Krzysztof318

+1. We need this change for open ai LLM results as well specially to observe stop reason = length, when we exceed max token limit to tune our token limits.

mit2nil avatar Feb 08 '24 00:02 mit2nil

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] avatar May 08 '24 01:05 github-actions[bot]

refresh

still see potential for that feature

Krzysztof318 avatar May 08 '24 11:05 Krzysztof318

Refresh from here too, I'm surprised this hasn't been implemented. We need this to detect that it has exceeded the max length such that we can ask it to continue.

roldengarm avatar Aug 09 '24 06:08 roldengarm

Added to the Sprint 34 to understand the scope of the changes required and potentially create an ADR

markwallace-microsoft avatar Sep 10 '24 08:09 markwallace-microsoft