.Net Add common finish reason to abstraction
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?
btw. for openai moderation violation status is stored in index PromptFilterResult in metadata? The ChangeTrackingList<PromptFilterResult> is always empty...
We need this change not to end up with something like this:
![]()
+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.
This issue is stale because it has been open for 90 days with no activity.
refresh
still see potential for that feature
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.
Added to the Sprint 34 to understand the scope of the changes required and potentially create an ADR