3 ms·
If you look into the instructor code(https://github.com/jxnl/instructor/blob/06a49e7824729b8df1f7253f7cdf3de8240aa0bf/instructor/process_response.py#L177 https:
by resiros 2y ago
If you look into the instructor code(https://github.com/jxnl/instructor/blob/06a49e7824729b8df1f7253f7cdf3de8240aa0bf/instructor/process_response.py#L177 https://github.com/jxnl/instructor/blob/06a49e7824729b8df1f7...). Here is the core code snippet they use:
message = dedent(
f"""
As a genius expert, your task is to understand the content and provide
the parsed objects in json that match the following json_schema:\n
{json.dumps(response_model.model_json_schema(), indent=2)}
Make sure to return an instance of the JSON, not the schema itself
"""
)
Then depending on the mode, either they add another message `Return the correct JSON response within a ```json codeblock. not the JSON_SCHEMA` or they set the response format to json.