Skip to content

Commit

Permalink
update example of ConstitutionalChain.from_llm (#3630)
Browse files Browse the repository at this point in the history
Example code was missing an argument and import. Fixed.
  • Loading branch information
piotrm0 authored Apr 27, 2023
1 parent e6c8cce commit 8a54217
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion langchain/chains/constitutional_ai/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ class ConstitutionalChain(Chain):
from langchain.llms import OpenAI
from langchain.chains import LLMChain, ConstitutionalChain
from langchain.chains.constitutional_ai.models \
import ConstitutionalPrinciple
llm = OpenAI()
qa_prompt = PromptTemplate(
template="Q: {question} A:",
input_variables=["question"],
)
qa_chain = LLMChain(llm=OpenAI(), prompt=qa_prompt)
qa_chain = LLMChain(llm=llm, prompt=qa_prompt)
constitutional_chain = ConstitutionalChain.from_llm(
llm=llm,
chain=qa_chain,
constitutional_principles=[
ConstitutionalPrinciple(
Expand Down

0 comments on commit 8a54217

Please sign in to comment.