Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
DavidLuong98 opened this issue Apr 6, 2023 · 5 comments
Assignees

Comments

@DavidLuong98
Copy link
Member

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.

@evchaki
Copy link
Contributor

evchaki commented Apr 6, 2023

Thanks for the feedback the team is looking into this.

@tynguyen
Copy link

tynguyen commented Apr 7, 2023

@DavidLuong98: one more upvote this this request.

@shawncal shawncal self-assigned this Apr 11, 2023
lemillermicrosoft pushed a commit that referenced this issue Jun 7, 2023
… etc) (#1181)

### Motivation and Context

Common feature request and missing capability to acquire the actual
details from the models we are integrating.

Resolves #802
Resolves #618  
Resolves Partially #351 
Getting the results alternative to #693 

### Description

This change introduces a new Property in `object?
SKContext.LastPromptResults` which will contain a list of each result
detail for a given prompt.

The Connector namespace will also provide a Extension methods that
converts this object in the actual class that you will be using to
serialize or get the detailed information about the Model result.

Normal suggested usage 
```
var textResult = await excuseFunction.InvokeAsync("I missed the F1 final race");
```

Getting model result as json:
```
var modelResultJson = JsonSerializer.Serialize(textResult.LastPromptResults);
```

Getting model result as a traversable object (using a connector
extension):
```
var modelResultJson = textResult.GetOpenAILastPromptResult()?.Usage.TotalTokens;
```
@RogerBarreto
Copy link
Member

@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

@matthewbolanos
Copy link
Member

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

@DavidLuong98
Copy link
Member Author

@RogerBarreto @matthewbolanos Looks good, thank you both.

shawncal pushed a commit to shawncal/semantic-kernel that referenced this issue Jul 6, 2023
… etc) (microsoft#1181)

### Motivation and Context

Common feature request and missing capability to acquire the actual
details from the models we are integrating.

Resolves microsoft#802
Resolves microsoft#618  
Resolves Partially microsoft#351 
Getting the results alternative to microsoft#693 

### Description

This change introduces a new Property in `object?
SKContext.LastPromptResults` which will contain a list of each result
detail for a given prompt.

The Connector namespace will also provide a Extension methods that
converts this object in the actual class that you will be using to
serialize or get the detailed information about the Model result.

Normal suggested usage 
```
var textResult = await excuseFunction.InvokeAsync("I missed the F1 final race");
```

Getting model result as json:
```
var modelResultJson = JsonSerializer.Serialize(textResult.LastPromptResults);
```

Getting model result as a traversable object (using a connector
extension):
```
var modelResultJson = textResult.GetOpenAILastPromptResult()?.Usage.TotalTokens;
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

6 participants