From 25045ab358f6bbaa9a4c54219aafa726da2f3569 Mon Sep 17 00:00:00 2001 From: Dylan Castillo Date: Fri, 27 Dec 2024 20:09:02 +0100 Subject: [PATCH] Use GEMINI_JSON as default --- docs/concepts/patching.md | 3 ++- instructor/client_gemini.py | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/concepts/patching.md b/docs/concepts/patching.md index 25edb4f59..ece6d02e9 100644 --- a/docs/concepts/patching.md +++ b/docs/concepts/patching.md @@ -35,6 +35,7 @@ Gemini tool calling comes with some known limitations: - Gemini tool calling is incompatible with Pydantic schema customizations such as examples due to API limitations and may result in errors - Gemini can sometimes call the wrong function name, resulting in malformed or invalid json - Gemini tool calling could fail with enum and literal field types + - Gemini tool calling doesn't preserve the order of the fields in the response. Don't rely on the order of the fields in the response. ```python import instructor @@ -45,7 +46,7 @@ client = instructor.from_gemini( ) ``` -### Gemini Vertex AI Tool Callin +### Gemini Vertex AI Tool Calling This method allows us to get structured output from Gemini via tool calling with the Vertex AI SDK. diff --git a/instructor/client_gemini.py b/instructor/client_gemini.py index 69547ba31..628c826c5 100644 --- a/instructor/client_gemini.py +++ b/instructor/client_gemini.py @@ -11,24 +11,26 @@ @overload def from_gemini( client: genai.GenerativeModel, - mode: instructor.Mode = instructor.Mode.GEMINI_TOOLS, + mode: instructor.Mode = instructor.Mode.GEMINI_JSON, use_async: Literal[True] = True, **kwargs: Any, -) -> instructor.AsyncInstructor: ... +) -> instructor.AsyncInstructor: + ... @overload def from_gemini( client: genai.GenerativeModel, - mode: instructor.Mode = instructor.Mode.GEMINI_TOOLS, + mode: instructor.Mode = instructor.Mode.GEMINI_JSON, use_async: Literal[False] = False, **kwargs: Any, -) -> instructor.Instructor: ... +) -> instructor.Instructor: + ... def from_gemini( client: genai.GenerativeModel, - mode: instructor.Mode = instructor.Mode.GEMINI_TOOLS, + mode: instructor.Mode = instructor.Mode.GEMINI_JSON, use_async: bool = False, **kwargs: Any, ) -> instructor.Instructor | instructor.AsyncInstructor: