I am learning structured_output
in langchain from the doc How to return structured data from a model | ๐ฆ๏ธ๐ Langchain
Is there any best practice and the better packages in JS stack to extract JSON response from the llm without using `.withStructuredOutput`๏ผ
The llm I am using is not good at `extract` tool based on the `withStructuredOutput` approach like below, here is the
extract schema:
{
"name": "extract",
"parameters": {
"type": "object",
"properties": {
"summary": {
"type": "string",
"description": "Concise summary of the webpage content"
},
"key_excerpts": {
"type": "string",
"description": "Important quotes and excerpts from the content"
}
},
"required": [
"summary",
"key_excerpts"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
Most of time, itโs failed to extract (maybe the llm is poor):
So, the only way for me is to use prompt to let llm return json code block, and build a custom extactor.
I am finding some help and the packages can improve the efficiency:
-
better way or packages to extract code block from markdown
-
packages recommendation like
dirty-json or `
jsonrepair`