!
참고할 만한 마인드맵
https://mm.tt/map/2747334464?t=HWe5qzpNir
class Chain(BaseModel, ABC):
"""Base interface that all chains should implement."""
memory: BaseMemory
callbacks: Callbacks
def __call__(
self,
inputs: Any,
return_only_outputs: bool = False,
callbacks: Callbacks = None,
) -> Dict[str, Any]:
...
!pip install -qU langchain openai
from langchain import OpenAI, PromptTemplate
from langchain.chains import LLMChain, LLMMathChain, TransformChain, SequentialChain, SimpleSequentialChain
OPENAI_API_KEY = "~~~~"
llm = OpenAI(temperature=0, openai_api_key=OPENAI_API_KEY)
template = """Your job is to come up with a classic dish from the area that the users suggests.
{user_location}
YOUR RESPONSE:
"""
prompt_template = PromptTemplate(input_variables=["user_location"], template=template)
location_chain = LLMChain(llm=llm, prompt=prompt_template)
print(prompt_template.template)
...
overall_chain = SimpleSequentialChain(chains=[location_chain, meal_chain, nutrients_nutrients], verbose=True)
review = overall_chain.run("Korea")
print(review)