From 7ce82217aa7295f5e0f1afb8ec378c637992dae8 Mon Sep 17 00:00:00 2001 From: Benedikt Rollik Date: Tue, 11 Feb 2025 10:30:50 +0100 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: NĂ©da <87707325+nerda-codes@users.noreply.github.com> --- pages/generative-apis/how-to/use-structured-outputs.mdx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pages/generative-apis/how-to/use-structured-outputs.mdx b/pages/generative-apis/how-to/use-structured-outputs.mdx index 5aaafb64e9..df285b32b3 100644 --- a/pages/generative-apis/how-to/use-structured-outputs.mdx +++ b/pages/generative-apis/how-to/use-structured-outputs.mdx @@ -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. - - 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. ## Code examples @@ -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 @@ -193,7 +192,7 @@ Output example: ### Using JSON mode (schemaless, Legacy method) - + - 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.`. @@ -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.