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

GenerateContentResponse.text may not return all the response info #99

Closed
devoncarew opened this issue Mar 13, 2024 · 4 comments · Fixed by #170
Closed

GenerateContentResponse.text may not return all the response info #99

devoncarew opened this issue Mar 13, 2024 · 4 comments · Fixed by #170
Assignees
Labels
component:dart sdk Issue/PR related to Dart SDK status:triaged Issue/PR triaged to the corresponding sub-team type:bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@devoncarew
Copy link
Collaborator

It looks like GenerateContentResponse.text just returns the text from the first Candidate in the candidates list, and from that candidate, the first TextPart in the parts list. I don't know about the guarantees wrt what the server returns, but it would probably be good to concatenate the returned candidates and parts (or, not offer a simplified API?).

@singhniraj08 singhniraj08 added type:bug Incorrect behavior (everything from a crash to more subtle misbehavior) component:dart sdk Issue/PR related to Dart SDK status:triaged Issue/PR triaged to the corresponding sub-team labels Mar 19, 2024
@natebosch
Copy link
Collaborator

When I looked at the implementations in the other languages this was the behavior I saw.

Looking back through the design docs I think the intention may have been to throw if there are multiple candidates, but I don't recall if that was the behavior I saw in the other implementations.

@devoncarew
Copy link
Collaborator Author

I have been printing the responses I'm getting back for a local tool I'm running, and (anecdotally) haven't seen more than one candidate.

@natebosch
Copy link
Collaborator

You can also enforce a single candidate by setting the GenerationConfig.candidateCount when constructing the model or making a request. https://pub.dev/documentation/google_generative_ai/latest/google_generative_ai/GenerationConfig/candidateCount.html

I think the main thing we can do is expand the docs to mention this.

@devoncarew devoncarew added component:documentation Improvements or additions to documentation and removed component:documentation Improvements or additions to documentation labels Mar 26, 2024
@natebosch
Copy link
Collaborator

We now concatenate parts #160

We don't concatenate candidates, and it wouldn't make sense to. I think we can add a text getter on Candidate though, which would make it easer to work with those subsequent candidates.

natebosch added a commit that referenced this issue May 23, 2024
Closes #99

Call out that candidates may be ignored in the doc for
`GenerateContentResponse.text`.

Add a `text` getter on `Candidate`. This is the same logic that was in
the response text getter, applied to an individual candidate.

Refactor the response text implementation to use the candidate field.
natebosch added a commit that referenced this issue May 23, 2024
Closes #99

Call out that candidates may be ignored in the doc for
`GenerateContentResponse.text`.

Add a `text` getter on `Candidate`. This is the same logic that was in
the response text getter, applied to an individual candidate.

Refactor the response text implementation to use the candidate field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:dart sdk Issue/PR related to Dart SDK status:triaged Issue/PR triaged to the corresponding sub-team type:bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants