Skip to content

Commit db1d5eb

Browse files
committed
remove python / json tabs
1 parent f47aa15 commit db1d5eb

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

docs/inference-providers/guides/structured-output.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ Before making any API calls, you need to define the structure you want. Let's bu
3232

3333
We'll create a simple schema that captures the most essential elements: the paper's title and a summary of its abstract. The easiest way to do this is to use Pydantic, a library that allows you to define Python classes that represent JSON schemas (among other things).
3434

35-
<hfoptions id="json-pydantic">
36-
37-
<hfoption id="pydantic">
38-
3935
```python
4036
from pydantic import BaseModel
4137

@@ -44,9 +40,7 @@ class PaperAnalysis(BaseModel):
4440
abstract_summary: str
4541
```
4642

47-
</hfoption>
48-
49-
<hfoption id="json">
43+
Using `model_json_schema` we can convert the Pydantic model to a JSON Schema which is what the model will receive as a response format instruction. This is the schema that the model will use to generate the response.
5044

5145
```json
5246
{
@@ -59,12 +53,6 @@ class PaperAnalysis(BaseModel):
5953
}
6054
```
6155

62-
</hfoption>
63-
64-
</hfoptions>
65-
66-
If you switch to the JSON option, you can see that the schema is exactly the same as the Pydantic model. This is what the LLM will receive as a response format instruction.
67-
6856
This simple schema ensures we'll always get the paper's title and a concise summary of its abstract. Notice how we mark both fields as required - this guarantees they'll always be present in the response, making our application more reliable.
6957

7058
## Step 2: Set up your inference client

0 commit comments

Comments
 (0)