mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
33fd6184ba
Co-authored-by: Bagatur <baskaryan@gmail.com>
14 lines
376 B
Plaintext
14 lines
376 B
Plaintext
```python
|
|
from langchain.schema import BaseOutputParser
|
|
|
|
class CommaSeparatedListOutputParser(BaseOutputParser):
|
|
"""Parse the output of an LLM call to a comma-separated list."""
|
|
|
|
|
|
def parse(self, text: str):
|
|
"""Parse the output of an LLM call."""
|
|
return text.strip().split(", ")
|
|
|
|
CommaSeparatedListOutputParser().parse("hi, bye")
|
|
# >> ['hi', 'bye']
|
|
``` |