Skip to content

Commit

Permalink
Fix CustomListOutputParser format instructions (langchain-ai#2860)
Browse files Browse the repository at this point in the history
* Fix format instruction of CustomListOutputParser when length is undefined

* removing temporary example

* Fix formatting

---------

Co-authored-by: jacoblee93 <[email protected]>
  • Loading branch information
jeromeetienne and jacoblee93 authored Oct 10, 2023
1 parent bc0c4fb commit 49be133
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion langchain/src/output_parsers/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export class CustomListOutputParser extends ListOutputParser {
* @returns A string containing instructions on the expected format of the response.
*/
getFormatInstructions(): string {
return `Your response should be a list of ${this.length} items separated by "${this.separator}" (eg: \`foo${this.separator} bar${this.separator} baz\`)`;
return `Your response should be a list of ${
this.length === undefined ? "" : `${this.length} `
}items separated by "${this.separator}" (eg: \`foo${this.separator} bar${
this.separator
} baz\`)`;
}
}

0 comments on commit 49be133

Please sign in to comment.