-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Added "JSON_mode" notebook for javascript #854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
||
|
||
## Setup | ||
### Install SDK and set-up the client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two level 3 titles without anything in between
// [CODE ENDS] | ||
|
||
/* Markdown (render) | ||
## Set your constrained output in the prompt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should first explain what Json mode is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check how we do it in the documentation, but µI think we should explain why you would need to use json mode (like an example), and then how it works.
// [CODE ENDS] | ||
|
||
/* Markdown (render) | ||
Now select the model you want to use in this guide, either by selecting one in the list or writing it down. Keep in mind that some models, like the 2.5 ones are thinking models and thus take slightly more time to respond (cf. [thinking notebook](./Get_started_thinking.ipynb) for more details and in particular learn how to switch the thiking off). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong link (point to the python cookbook for now as it will be easier to find them all and fix them)
prompt = ` | ||
List a few popular cookie recipes using this JSON schema: | ||
|
||
Recipe = {'recipe_name': str} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should also explain where the format comes from since it's a python thing if I'm not mistaken.
/* Markdown (render) | ||
## Supply the schema to the model directly | ||
|
||
The newest models (1.5 and beyond) allow you to pass a schema object (or a python type equivalent) directly and the output will strictly follow that schema. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can drop the "newest models" as the older ones are not available anymore.
``` | ||
[ | ||
{ | ||
"recipe_name": "Chocolate Chip Cookies" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's an encoding error here.
|
||
### Continue your discovery of the Gemini API | ||
|
||
JSON is not the only way to constrain the output of the model, you can also use an [Enum](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Enum.ipynb). [Function calling](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Function_calling.ipynb) and [Code execution](https://github.com/google-gemini/cookbook/blob/main/quickstarts/Code_Execution.ipynb) are other ways to enhance your model by either using your own functions or by letting the model write and run them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a link to the quickstart as that's the only one we have at the moment.
No description provided.