Update Helper
Browse files- langchain_helper.py +32 -0
langchain_helper.py
CHANGED
@@ -9,3 +9,35 @@ from secret_key import openapi_key
|
|
9 |
# Reading the OPEN API KEY
|
10 |
os.environ['OPENAI_API_KEY'] = openapi_key
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Reading the OPEN API KEY
|
10 |
os.environ['OPENAI_API_KEY'] = openapi_key
|
11 |
|
12 |
+
# First chain of command: Name of the organization
|
13 |
+
def generate_name(feild):
|
14 |
+
prompt_template = PromptTemplate(
|
15 |
+
input_variables=["feild"],
|
16 |
+
template="I want to open a edtech organization for {feild} domain. Suggest a great name for this and the course structure to be followed.",
|
17 |
+
)
|
18 |
+
|
19 |
+
name_chain = LLMChain(llm = model, prompt = prompt_template, output_key = "organization_name")
|
20 |
+
|
21 |
+
# Second chain of command: Tips
|
22 |
+
|
23 |
+
prompt_template = PromptTemplate(
|
24 |
+
input_variables=["specifics"],
|
25 |
+
template="Suggest me tips of how we can elevate the {specifics} for generative AI, and return it in comma seperated format",
|
26 |
+
)
|
27 |
+
|
28 |
+
specific_chain = LLMChain(llm = model, prompt = prompt_template, output_key = "tips")
|
29 |
+
|
30 |
+
|
31 |
+
chain = SequentialChain(
|
32 |
+
chains = [name_chain, specific_chain],
|
33 |
+
input_variables = ["feild", "specifics"], # Added "specifics" to the input variables
|
34 |
+
output_variables = ["organization_name", "tips"]
|
35 |
+
)
|
36 |
+
|
37 |
+
resp = chain({"feild" : feild})
|
38 |
+
|
39 |
+
return resp
|
40 |
+
|
41 |
+
|
42 |
+
if __name__ == "__main__":
|
43 |
+
print(generate_name("Data Science"))
|