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

TypeError: GenerationConfig.__init__() got an unexpected keyword argument 'response_schema' #3322

Open
tytung2020 opened this issue Jul 25, 2024 · 2 comments

Comments

@tytung2020
Copy link

Expected Behavior

run without error, as the code below is from vertexai documentation: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/control-generated-output

Actual Behavior

returns the error :
TypeError: GenerationConfig.init() got an unexpected keyword argument 'response_schema'

Steps to Reproduce the Problem

just run this code with your credentials

import vertexai
from dotenv import load_dotenv
import os
from vertexai.generative_models import GenerationConfig, GenerativeModel

# Load environment variables
load_dotenv()

# Set Google Application Credentials
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = ...

# Initialize Vertex AI
project_id = "..."
vertexai.init(project=project_id, location="us-central1")

response_schema = {
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "recipe_name": {
                "type": "string",
            },
        },
        "required": ["recipe_name"],
    },
}

model = GenerativeModel("gemini-1.5-pro-001")

response = model.generate_content(
    "List a few popular cookie recipes",
    generation_config=GenerationConfig(
        response_mime_type="application/json", response_schema=response_schema
    ),
)

print(response.text)

Specifications

  • Version: vertexai: 1.49.0
  • Platform: vscode on windows
@rohitpk
Copy link

rohitpk commented Aug 5, 2024

@tytung2020 , were you able to overcome this?

@analyticsrepo01
Copy link

have u tried to upgrade vertex AI version
pip3 install --upgrade "google-cloud-aiplatform"
pip install --upgrade "google-cloud-aiplatform"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants