Skip to content

Commit

Permalink
structured output (#175)
Browse files Browse the repository at this point in the history
* structured output

* update doc

* remove ignore

* speed up poetry
  • Loading branch information
XuhuiZhou authored Aug 26, 2024
1 parent 7bd088f commit 77a97f8
Show file tree
Hide file tree
Showing 5 changed files with 736 additions and 624 deletions.
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
uses: abatilo/actions-poetry@v2
- name: Install dependencies
run: |
poetry lock
poetry install --with test -E chat
- name: Test with pytest
env: # Or as an environment variable
Expand Down
10 changes: 10 additions & 0 deletions docs/pages/concepts/generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,24 @@ async def agenerate(
input_values: dict[str, str],
output_parser: BaseOutputParser[OutputType],
temperature: float = 0.7,
structured_output: bool = False,
) -> OutputType:
input_variables = re.findall(r"(?<!{){([^{}]+)}(?!})", template)
```

The `agenerate` function is versatile by taking the output_parser as an argument and returning the output in the desired format.
<Callout type="info" emoji="ℹ️">
Structured output is used to return the output in a structured format, such as a dictionary or a Pydantic object.
Currently, the structured output is only supported for the models below:
* `gpt-4o-mini-2024-07-18` and later
* `gpt-4o-2024-08-06` and later

</Callout>

Here are a few examples of how to use the `agenerate` function:



### Automatically generate scenarios

```python
Expand Down
Loading

0 comments on commit 77a97f8

Please sign in to comment.