first commit
Browse files- .gitignore +1 -0
- __pycache__/secret_key.cpython-39.pyc +0 -0
- app.py +30 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
secret_key.py
|
__pycache__/secret_key.cpython-39.pyc
ADDED
|
Binary file (260 Bytes). View file
|
|
|
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain_openai import OpenAI
|
| 2 |
+
from langchain.prompts import PromptTemplate
|
| 3 |
+
from langchain.chains import LLMChain
|
| 4 |
+
from langchain.chains import SimpleSequentialChain
|
| 5 |
+
from secret_key import openapi_key
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
os.environ['OPENAI_API_KEY'] = openapi_key
|
| 9 |
+
|
| 10 |
+
llm = OpenAI(temperature=0.6)
|
| 11 |
+
|
| 12 |
+
prompt_template_name = PromptTemplate(
|
| 13 |
+
input_variables = ['cuisine'],
|
| 14 |
+
template = "I want to open a restaurant for {cuisine} food. Suggest a fancy name for this."
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
name_chain = LLMChain(llm=llm, prompt=prompt_template_name)
|
| 18 |
+
|
| 19 |
+
prompt_template_items = PromptTemplate(
|
| 20 |
+
input_variables = ['restaurant_name'],
|
| 21 |
+
template = "Suggest some menu items for {restaurant_name}. Return it as a comma separated list. "
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
food_items_chain = LLMChain(llm=llm, prompt=prompt_template_items)
|
| 25 |
+
|
| 26 |
+
chain = SimpleSequentialChain(chains = [name_chain, food_items_chain])
|
| 27 |
+
|
| 28 |
+
response = chain.invoke("American")
|
| 29 |
+
print(response)
|
| 30 |
+
# {'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'}
|