description=”a list of strings”,
type=”List[string]”
),
ResponseSchema(name=”bar”,
description=”a string”,
type=”string”
),
]
parser = StructuredOutputParser.from_response_schemas(response_schemas)
print(parser.get_format_instructions())
output:
# The output should be a Markdown code snippet formatted in the following
# schema, including the leading and trailing “`json" and "`”:
#
# ```json
# {
#     “foo”: List[string]  // a list of strings
#     “bar”: string  // a string
# }
Parameters
only_json (bool) – If True, only the json in the Markdown code snippet
will be returned, without the introducing text. Defaults to False.
invoke(input: str | langchain.schema.messages.BaseMessage, config: langchain.schema.runnable.RunnableConfig | None = None) → T¶
json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
parse(text: str) → Any[source]¶
Parse a single string model output into some structure.
Parameters
text – String output of a language model.
Returns
Structured output.