String output parser
The StringOutputParser takes language model output (either an entire response or as a stream) and converts
it into a string. This is useful for standardizing chat model and LLM output.
This output parser can act as a transform stream and work with streamed response chunks from a model.
Usage
- npm
 - Yarn
 - pnpm
 
npm install @langchain/openai
yarn add @langchain/openai
pnpm add @langchain/openai
import { ChatOpenAI } from "@langchain/openai";
import { StringOutputParser } from "@langchain/core/output_parsers";
const parser = new StringOutputParser();
const model = new ChatOpenAI({ temperature: 0 });
const stream = await model.pipe(parser).stream("Hello there!");
for await (const chunk of stream) {
  console.log(chunk);
}
/*
  Hello
  !
  How
  can
  I
  assist
  you
  today
  ?
*/
API Reference:
- ChatOpenAI from 
@langchain/openai - StringOutputParser from 
@langchain/core/output_parsers