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

Request to Return Additional Information in CompleteAsync Method and Store it in ContextVariables

Open DavidLuong98 opened this issue 1 year ago • 2 comments

Currently, the CompleteAsync method only returns a response string. I would like to request that additional information such as status codes be returned as well.

I suggest that the CompleteAsync method in ITextCompletion should return some type T instead of a string to allow for this. This would enable us to gather more information about the response and make it easier to handle different scenarios.

Furthermore, I would like to propose that the ContextVariables class be updated to use a ConcurrentDictionary<string, object> instead of ConcurrentDictionary<string, string>. This would allow for the storage of variables of different types and make the class more flexible.

Please let me know if these changes are feasible and if there are any concerns or suggestions for improvement. Thank you for your time and consideration.

DavidLuong98 avatar Apr 06 '23 19:04 DavidLuong98

Thanks for the feedback the team is looking into this.

evchaki avatar Apr 06 '23 21:04 evchaki

@DavidLuong98: one more upvote this this request.

tynguyen avatar Apr 07 '23 05:04 tynguyen

@DavidLuong98 this PR #952 and #1117 addresses the first and second requests on this Issue.

Now you can get more detailed information about your requests using the ModelResults property of SKContext variable when calling RunAsync or InvokeAsync.

On the ITextCompletion interfaces we now have a method to return a ITextCompletionResult (being renamed to ITextResult on #1391)

This IResult interface exposes also the ModelResult property which you can use a extension method to get more info of it in this example: Example43_GetModelResult

RogerBarreto avatar Jun 13 '23 15:06 RogerBarreto

@DavidLuong98, can you confirm if the PRs that @RogerBarreto mentioned address the challenges you faced? :)

matthewbolanos avatar Jun 27 '23 16:06 matthewbolanos

@RogerBarreto @matthewbolanos Looks good, thank you both.

DavidLuong98 avatar Jun 30 '23 16:06 DavidLuong98