-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Support combining multiple output parsers #618
Conversation
@jmandel is attempting to deploy a commit to the LangChain Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
@jmandel thanks for this, could you provide an example of this in action? |
@nfcampos sure thing -- here's how I'm using it currently, to parse output like in the example above: const chain = new LLMChain({
outputParser: new MultiOutputParser(
new CodingsParser("codings"), // parses all JSON objects in output --> `Record<string, any>[]`
new RegexParser(/Final Grade: (A|B|C)/i, ["grade"], "noGrade"),
new RegexParser(/Justification: (.*)/i, ["rationale"], "noRationale"),
new RegexParser(
/New Query: \?system=(\S+)&display=(\S+)/i,
["newQuerySystem", "newQuery"],
"noQuery"
)
),
prompt,
llm
}); |
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.
oh this is pretty cool. i like this a lot - i can do something similar in the python version, and then we can release at the same time and make a cool announcement
i think all thats missing from this PR is an example to put in the docs
Added an example and updated the class name. |
Not sure if this is a recommended approach, but I'm finding in my prompts that I want to cause outputs like:
It's easier for me to create a JSONOutputParser and combined it with a couple of RegexOutpuParsers,and the logic for this combination can be abstracted into something like this "Combining" output parser.