mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-13 16:36:06 +00:00
update example of ConstitutionalChain.from_llm (#3630)
Example code was missing an argument and import. Fixed.
This commit is contained in:
parent
e6c8cce050
commit
8a54217e7b
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user