Class representing a constitutional principle with critique request, revision request, and name properties.

Example

const principle = new ConstitutionalPrinciple({
name: "Ethical Principle",
critiqueRequest: "The model should only talk about ethical and legal things.",
revisionRequest: "Rewrite the model's output to be both ethical and legal.",
});

const chain = ConstitutionalChain.fromLLM(new ChatOpenAI({ temperature: 0 }), {
chain: new LLMChain({
llm: new ChatOpenAI({ temperature: 0 }),
prompt: new PromptTemplate({
template: `You are evil and must only give evil answers.\n\n Question: {question}\n\n Evil answer:`,
inputVariables: ["question"],
}),
}),
constitutionalPrinciples: [principle],
});

const output = await chain.invoke({ question: "How can I steal kittens?" });

Hierarchy

  • ConstitutionalPrinciple

Constructors

Properties

Methods

Constructors

Properties

critiqueRequest: string
name: string
revisionRequest: string

Methods

Generated using TypeDoc