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

google.generativeai.chat does not support max_output_tokens #48

Closed
chrbsg opened this issue Jul 6, 2023 · 4 comments
Closed

google.generativeai.chat does not support max_output_tokens #48

chrbsg opened this issue Jul 6, 2023 · 4 comments
Labels
component:python sdk Issue/PR related to Python SDK type:feature request New feature request/enhancement

Comments

@chrbsg
Copy link

chrbsg commented Jul 6, 2023

We want to limit the reply length of chat responses, but google.generativeai.chat does not appear to support the max_output_tokens parameter. I'm not sure whether this is just not implemented yet, or an API limitation, or something else, but the vertexai Python SDK Chat model appears to support it (see Vertex AI Chat model parameters) and so does the google.generativeai.generate_text function.

I had thought that perhaps max_output_tokens wasn't supported in chat, just text generation, but this doc clearly shows it being used in a chat:

chat = chat_model.start_chat(
    context="My name is Ned. You are my personal assistant. My favorite movies are Lord of the Rings and Hobbit.",
    examples=[
        InputOutputTextPair(
            input_text="Who do you work for?",
            output_text="I work for Ned.",
        ),
        InputOutputTextPair(
            input_text="What do I like?",
            output_text="Ned likes watching movies.",
        ),
    ],
    temperature=0.3,
    max_output_tokens=200,
    top_p=0.8,
    top_k=40,
)
print(chat.send_message("Are my favorite movies based on a book series?"))

(It's a bit confusing that Google seems to have two different Python SDKs, this google-generativeai one and google-cloud-aiplatform. Is there any difference if all a developer wants to do is send chat to a model and get responses back?)

@markmcd
Copy link
Member

markmcd commented Jul 24, 2023

Ack - thanks for the report. It's not strictly the Python library, as the API itself is missing the functionality, but I'll bring it up with the team nonetheless. (Googlers: b/292466007)

@markmcd markmcd added the type:feature request New feature request/enhancement label Jul 24, 2023
@keertk keertk added status:triaged Issue/PR triaged to the corresponding sub-team component:python sdk Issue/PR related to Python SDK subcategory:general labels Aug 23, 2023
@liamdugan
Copy link

+1 to this, also having this issue

@ryuryukke
Copy link

I found that a PaLM Chat model in Vertex AI SDK supports max_output_tokens.: https://cloud.google.com/vertex-ai/docs/generative-ai/model-reference/text-chat

@MarkDaoust
Copy link
Collaborator

MarkDaoust commented May 17, 2024

The palm based interface has stopped develoipment. Closing.

@github-actions github-actions bot removed the status:triaged Issue/PR triaged to the corresponding sub-team label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:python sdk Issue/PR related to Python SDK type:feature request New feature request/enhancement
Projects
None yet
Development

No branches or pull requests

6 participants