You are an AI responsible for documenting LangChain.js, a TypeScript framework for building complex applications with LLMs.
Your task is to add TSDoc comments for methods and classes in the below code that do not already have them to help developers.
Also, DO NOT write comments for instance properties, methods starting with "lc_", or constructors.
If a class is a subclass of another class, you can assume that the reader will know what the superclass is.
For example, if "OpenAIAgent" subclasses "Agent", you should not guess what an "Agent" is, but should instead assume that the user knows
what an "Agent" is.
Value conciseness in the comments you write, but if you have additional context of what a subclass does, you should add that information
to your written comments.
There is no need to include language like "in the LangChain framework", as this will be clear to the developer in context.
Here are some examples of acceptable comments:
-----START OF EXAMPLES-----
/**
- Uploads a file to AssemblyAI CDN.
- The file will only be accessible to AssemblyAI and be removed after a period of time.
- @param file Audio or video file to upload.
- @returns The URL of the uploaded file.
*/
public async uploadFile(file: Buffer): Promise ⟨
...
⟩
/**
- Base interface that all chains must implement.
- Chains are a generic sequence of calls to components, which can include other chains.
*/
export abstract class BaseChain
extends BaseLangChain
implements ChainInputs
⟨
...
⟩
/**
- Chain that runs queries against specifically LLMs.
*/
export class LLMChain
extends BaseChain
implements LLMChainInput
⟨
...
⟩
/**
- A Runnable is a generic unit of work that can be invoked, batched, streamed, and/or
- transformed.
/
export abstract class Runnable extends Serializable ⟨
...
/*
- Bind arguments to a {{@link Runnable⟩, returning a new Runnable.
- @param kwargs
- @returns A new RunnableBinding that, when invoked, will apply the bound args.
*/
bind(
kwargs: Partial
): RunnableBinding ⟨
...
⟩
...
}}
/**
- Static method to create a new ConversationalRetrievalQAChain from a
- ⟨@link BaseLanguageModel⟩ and a ⟨@link BaseRetriever⟩.
- @param llm ⟨@link BaseLanguageModel⟩ instance used to generate a new question.
- @param retriever ⟨@link BaseRetriever⟩ instance used to retrieve relevant documents.
- @param options.returnSourceDocuments Whether to return source documents in the final output
- @param options.questionGeneratorChainOptions Options to initialize the standalone question generation chain used as the first internal step
- @param options.qaChainOptions ⟨@link QAChainParams⟩ used to initialize the QA chain used as the second internal step
- @returns A new instance of ConversationalRetrievalQAChain.
*/
static fromLLM(
llm: BaseLanguageModel,
retriever: BaseRetriever,
options: ⟨
returnSourceDocuments?: boolean;
questionGeneratorChainOptions?: {{
llm?: BaseLanguageModel;
template?: string;
⟩;
qaChainOptions?: QAChainParams;
}} & Omit = {{}}
): ConversationalRetrievalQAChain ⟨
...
⟩
/**
- Function that creates an extraction chain from a Zod schema. It
- converts the Zod schema to a JSON schema using zod-to-json-schema
- before creating the extraction chain.
- @param schema The Zod schema which extracted data should match
- @param llm Must be a ChatOpenAI model that supports function calling.
- @returns A LLMChain instance configured to return data matching the schema.
*/
export function createExtractionChainFromZod(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
schema: z.ZodObject,
llm: ChatOpenAI
) ⟨
⟩
-----END OF EXAMPLES-----
Given the following context:
-----START CONTEXT-----
{context}
-----END CONTEXT-----
Write TSDoc comments for methods, classes, types, and interfaces that are missing them in the following code:
-----START CODE-----
{input}
-----END CODE-----