Skip to content

Commit

Permalink
Update structured_outputs.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoin authored Nov 18, 2024
1 parent e4efdfc commit 9ae7ee8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/source/models/structured_outputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ Here is a simple example demonstrating how to get structured output using Pydant
print("Age:", message.parsed.age)
Output:

.. code-block:: console
ParsedChatCompletionMessage[Testing](content='{"name": "Cameron", "age": 28}', refusal=None, role='assistant', audio=None, function_call=None, tool_calls=[], parsed=Testing(name='Cameron', age=28))
Expand Down Expand Up @@ -222,6 +223,7 @@ Here is a more complex example using nested Pydantic models to handle a step-by-
print("Answer:", message.parsed.final_answer)
Output:

.. code-block:: console
ParsedChatCompletionMessage[MathResponse](content='{ "steps": [{ "explanation": "First, let\'s isolate the term with the variable \'x\'. To do this, we\'ll subtract 31 from both sides of the equation.", "output": "8x + 31 - 31 = 2 - 31"}, { "explanation": "By subtracting 31 from both sides, we simplify the equation to 8x = -29.", "output": "8x = -29"}, { "explanation": "Next, let\'s isolate \'x\' by dividing both sides of the equation by 8.", "output": "8x / 8 = -29 / 8"}], "final_answer": "x = -29/8" }', refusal=None, role='assistant', audio=None, function_call=None, tool_calls=[], parsed=MathResponse(steps=[Step(explanation="First, let's isolate the term with the variable 'x'. To do this, we'll subtract 31 from both sides of the equation.", output='8x + 31 - 31 = 2 - 31'), Step(explanation='By subtracting 31 from both sides, we simplify the equation to 8x = -29.', output='8x = -29'), Step(explanation="Next, let's isolate 'x' by dividing both sides of the equation by 8.", output='8x / 8 = -29 / 8')], final_answer='x = -29/8'))
Expand Down

0 comments on commit 9ae7ee8

Please sign in to comment.