Chong-U Lim
commited on
Commit
·
390058b
1
Parent(s):
7adfd09
Prevent llm from returning misformatted menu items
Browse files- langchain_helper.py +5 -3
langchain_helper.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
|
| 3 |
-
from
|
| 4 |
from langchain.prompts import PromptTemplate
|
| 5 |
from langchain.chains import LLMChain, SequentialChain
|
| 6 |
|
|
@@ -22,11 +22,13 @@ name_chain = LLMChain(
|
|
| 22 |
|
| 23 |
prompt_template_items = PromptTemplate(
|
| 24 |
input_variables=["restaurant_name"],
|
| 25 |
-
template="Suggest some menu items for {restaurant_name}. Return
|
| 26 |
)
|
| 27 |
|
| 28 |
food_items_chain = LLMChain(
|
| 29 |
-
llm=llm,
|
|
|
|
|
|
|
| 30 |
)
|
| 31 |
|
| 32 |
chain = SequentialChain(
|
|
|
|
| 1 |
import os
|
| 2 |
|
| 3 |
+
from langchain_community.llms import OpenAI
|
| 4 |
from langchain.prompts import PromptTemplate
|
| 5 |
from langchain.chains import LLMChain, SequentialChain
|
| 6 |
|
|
|
|
| 22 |
|
| 23 |
prompt_template_items = PromptTemplate(
|
| 24 |
input_variables=["restaurant_name"],
|
| 25 |
+
template="Suggest some menu items for {restaurant_name}. Return the menu items as a comma separated string with no additional preamble.",
|
| 26 |
)
|
| 27 |
|
| 28 |
food_items_chain = LLMChain(
|
| 29 |
+
llm=llm,
|
| 30 |
+
prompt=prompt_template_items,
|
| 31 |
+
output_key="menu_items",
|
| 32 |
)
|
| 33 |
|
| 34 |
chain = SequentialChain(
|