Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Néda <[email protected]>
  • Loading branch information
bene2k1 and nerda-codes authored Feb 11, 2025
1 parent f39a811 commit 7ce8221
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pages/generative-apis/how-to/use-structured-outputs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ There are several ways to interact with language models:
- JSON mode is older and has been used by developers since early API implementations but lack reliability in response formats.

<Message type="note">
- All LLMs on the Scaleway library support **Structured outputs** and **JSON mode**. However, schemaless **JSON mode** will produce lower quality result and is not recommended.
- All LLMs on the Scaleway library support **Structured outputs** and **JSON mode**. However, a schemaless **JSON mode** will produce lower quality results and is not recommended.
</Message>

## Code examples
Expand All @@ -57,8 +57,7 @@ There are several ways to interact with language models:

The following Python examples demonstrate how to use both **Structured outputs** and to generate structured responses.

We will send to our LLM a voice note transcript in order to structure it.
Below is our base code:
We are using the base code below to send our LLM a voice note transcript to structure:

```python
import json
Expand Down Expand Up @@ -193,7 +192,7 @@ Output example:

### Using JSON mode (schemaless, Legacy method)

<Message type="warning">
<Message type="important">
- When using the OpenAI SDKs like in the examples above, you are expected to set `additionalProperties` to false, and to specify all your properties as required.
- JSON mode: It is important to explicitly ask the model to generate a JSON output either in system prompt or user prompt. To prevent infinite generations, model providers most often encourage users to ask the model for short JSON objects. Prompt example: `Only answer in JSON using '{' as the first character.`.
</Message>
Expand Down Expand Up @@ -249,4 +248,4 @@ Using structured outputs with LLMs can significantly improve their reliability,
- **Structured outputs** provide strict adherence to a predefined schema, ensuring consistency.
- **JSON mode** (Legacy Method) is flexible but less predictable.

We recommend using Structured outputs (`json_schema`) for most use cases.
We recommend using structured outputs (`json_schema`) for most use cases.

0 comments on commit 7ce8221

Please sign in to comment.