Closed tytung2020 closed 1 month ago
run without error, as the code below is from vertexai documentation: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/control-generated-output
returns the error : TypeError: GenerationConfig.init() got an unexpected keyword argument 'response_schema'
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)
@tytung2020 , were you able to overcome this?
have u tried to upgrade vertex AI version pip3 install --upgrade "google-cloud-aiplatform" pip install --upgrade "google-cloud-aiplatform"
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
Specifications