-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for openai structure outputs
- Loading branch information
1 parent
12ac9e9
commit 382ca1f
Showing
6 changed files
with
92 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
import os | ||
|
||
import schema | ||
|
||
from griptape.drivers import OpenAiChatPromptDriver | ||
from griptape.rules import Rule | ||
from griptape.structures import Agent | ||
|
||
agent = Agent( | ||
prompt_driver=OpenAiChatPromptDriver( | ||
api_key=os.environ["OPENAI_API_KEY"], | ||
model="gpt-4o-2024-08-06", | ||
temperature=0.1, | ||
model="gpt-4o", | ||
response_format="json_object", | ||
seed=42, | ||
response_format={ | ||
"type": "json_schema", | ||
"json_schema": { | ||
"strict": True, | ||
"name": "Output", | ||
"schema": schema.Schema({"css_code": str, "relevant_emojies": [str]}).json_schema("Output Schema"), | ||
}, | ||
}, | ||
), | ||
input="You will be provided with a description of a mood, and your task is to generate the CSS code for a color that matches it. Description: {{ args[0] }}", | ||
rules=[Rule(value='Write your output in json with a single key called "css_code".')], | ||
input="You will be provided with a description of a mood, and your task is to generate the CSS color code for a color that matches it. Description: {{ args[0] }}", | ||
) | ||
|
||
agent.run("Blue sky at dusk.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters