Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnl committed Mar 29, 2024
1 parent 1d40a22 commit ab1b10b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 34 deletions.
4 changes: 2 additions & 2 deletions docs/blog/posts/anthropic.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors:

A special shoutout to [Shreya](https://twitter.com/shreyaw_) for her contributions to the anthropic support. As of now, all features are operational with the exception of streaming support.

For those eager to experiment, simply patch the client with `ANTHROPIC_TOOLS`, which will enable you to leverage the `anthropic` client for making requests.
For those eager to experiment, simply patch the client with `ANTHROPIC_JSON`, which will enable you to leverage the `anthropic` client for making requests.

```
pip install instructor[anthropic]
Expand All @@ -28,7 +28,7 @@ import instructor
# Patching the Anthropics client with the instructor for enhanced capabilities
anthropic_client = instructor.patch(
create=anthropic.Anthropic().messages.create,
mode=instructor.Mode.ANTHROPIC_TOOLS
mode=instructor.Mode.ANTHROPIC_JSON
)

class Properties(BaseModel):
Expand Down
30 changes: 30 additions & 0 deletions docs/concepts/patching.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,33 @@ from openai import OpenAI

client = instructor.patch(OpenAI(), mode=instructor.Mode.MD_JSON)
```

## Anthropic JSON Mode

Anthropic JSON mode uses Anthropic's JSON format for responses by setting the `mode` parameter to `instructor.Mode.ANTHROPIC_JSON` when patching the client.

```python
import instructor
from anthropic import Anthropic

create = instructor.patch(
create=anthropic.Anthropic().messages.create,
mode=instructor.Mode.ANTHROPIC_JSON
)

class User(BaseModel):
name: str
age: int

resp = create(
model="claude-3-haiku-20240307",
max_tokens=1024,
messages=[
{
"role": "user",
"content": "Create a user",
}
],
response_model=User,
)
```
32 changes: 0 additions & 32 deletions examples/classification/test_run.py

This file was deleted.

0 comments on commit ab1b10b

Please sign in to comment.