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

Use GEMINI_JSON as default #1286

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/concepts/patching.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down
12 changes: 7 additions & 5 deletions instructor/client_gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading