LiuZiyi's picture
first commit
2bf70cd
from langchain_openai import OpenAI
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
from langchain.chains import SimpleSequentialChain
from secret_key import openapi_key
import os
os.environ['OPENAI_API_KEY'] = openapi_key
llm = OpenAI(temperature=0.6)
prompt_template_name = PromptTemplate(
input_variables = ['cuisine'],
template = "I want to open a restaurant for {cuisine} food. Suggest a fancy name for this."
)
name_chain = LLMChain(llm=llm, prompt=prompt_template_name)
prompt_template_items = PromptTemplate(
input_variables = ['restaurant_name'],
template = "Suggest some menu items for {restaurant_name}. Return it as a comma separated list. "
)
food_items_chain = LLMChain(llm=llm, prompt=prompt_template_items)
chain = SimpleSequentialChain(chains = [name_chain, food_items_chain])
response = chain.invoke("American")
print(response)
# {'input': 'American', 'output': '\n\n1. Classic American Burger\n2. BBQ Pulled Pork Sandwich\n3. Buffalo Wings\n4. Mac and Cheese\n5. Southern Fried Chicken\n6. Philly Cheesesteak\n7. Tex-Mex Burrito\n8. New England Clam Chowder\n9. California Cobb Salad\n10. Hawaiian Pizza\n11. Chicago Deep Dish Pizza\n12. Maine Lobster Roll\n13. Texas Chili\n14. Kansas City BBQ Ribs\n15. New York Style Cheesecake'}