Skip to content

Commit

Permalink
fix: dedent json system prompt (#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyasp authored Mar 2, 2024
1 parent 413949a commit ed2a702
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions instructor/patch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import inspect
import json
import logging
from textwrap import dedent
from collections.abc import Iterable
from functools import wraps
from tenacity import Retrying, AsyncRetrying, stop_after_attempt, RetryError
Expand Down Expand Up @@ -133,11 +134,11 @@ def handle_response_model(
elif mode in {Mode.JSON, Mode.MD_JSON, Mode.JSON_SCHEMA}:
# If its a JSON Mode we need to massage the prompt a bit
# in order to get the response we want in a json format
message = f"""
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
{response_model.model_json_schema()['properties']}
"""
""")
# Check for nested models
if "$defs" in response_model.model_json_schema():
message += f"\nHere are some more definitions to adhere too:\n{response_model.model_json_schema()['$defs']}"
Expand Down

0 comments on commit ed2a702

Please sign in to comment.