google / generative-ai-go

Go SDK for Google Generative AI
Apache License 2.0
592 stars 59 forks source link

GenerateContent doesn't accept Content objects #193

Closed rakyll closed 4 months ago

rakyll commented 4 months ago

Description of the feature request:

Consider the following code:

model := client.GenerativeModel("gemini1.5-pro")
resp, err := model.GenerateContent(r.Context(), parts...)
...

What problem are you trying to solve with this feature?

GenerateContent should be accepting contents rather than parts per proto, see https://ai.google.dev/api/generate-content#method:-models.generatecontent.

Not being able to provide a slice of content objects is making it impossible to provide roles or the conversation history, and making the client unusable for chat applications.

Please fix the GenerateContent method to work with Content objects as arguments.

Any other information you'd like to share?

We should consider breaking GenerateContent to land this fix. Content role and history is a very critical part of the chat exchanges and all the foundational model providers seem to be primary converging into a chat-focused API and client libraries.

jba commented 4 months ago

Can't you do all that with a ChatSession?

rakyll commented 4 months ago

ChatSession is what I was looking for. I realized we created similar new concepts and semantics on other language libraries that looks distinct from the proto.

I believe it is too late right now to have a conversation for breaking changes at a massive scale to remove these utilities and semantics. I'm going to close this issue for now.