File size: 593 Bytes
31401fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from langchain_openai import OpenAI
from langchain.prompts import PromptTemplate 
from langchain.chains import LLMChain
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."
)

chain = LLMChain(llm=llm, prompt=prompt_template_name)
response = chain.invoke({"cuisine":"American"})
print(response)
# {'cuisine': 'American', 'text': '\n\n"Stateside Eats" '}