diff --git a/README.md b/README.md index 16d7e3f14..bfa2df756 100644 --- a/README.md +++ b/README.md @@ -177,15 +177,22 @@ creds.refresh(auth_req) # Pass the Vertex endpoint and authentication to the OpenAI SDK PROJECT = 'PROJECT_ID' -LOCATION = 'LOCATION' # https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations +LOCATION = ( + 'LOCATION' # https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations +) base_url = f'https://{LOCATION}-aiplatform.googleapis.com/v1beta1/projects/{PROJECT}/locations/{LOCATION}/endpoints/openapi' -client = instructor.from_openai(OpenAI(base_url=base_url, api_key=creds.token), mode=instructor.Mode.JSON) +client = instructor.from_openai( + OpenAI(base_url=base_url, api_key=creds.token), mode=instructor.Mode.JSON +) + + # JSON mode is req'd class User(BaseModel): name: str age: int + resp = client.chat.completions.create( model="google/gemini-1.5-flash-001", max_tokens=1024, diff --git a/docs/concepts/patching.md b/docs/concepts/patching.md index e8ee46139..73821bb41 100644 --- a/docs/concepts/patching.md +++ b/docs/concepts/patching.md @@ -93,7 +93,9 @@ PROJECT = 'PROJECT_ID' LOCATION = 'LOCATION' base_url = f'https://{LOCATION}-aiplatform.googleapis.com/v1beta1/projects/{PROJECT}/locations/{LOCATION}/endpoints/openapi' -client = instructor.from_openai(OpenAI(base_url=base_url, api_key=creds.token),mode=instructor.Mode.JSON) +client = instructor.from_openai( + OpenAI(base_url=base_url, api_key=creds.token), mode=instructor.Mode.JSON +) ``` ### Gemini JSON Mode