Organization_Name_Generator / langchain_helper.py
thisisdev's picture
Update Helper
65b8f24 verified
raw
history blame
1.45 kB
# Import the necessary libraries needed for the operation
import os
from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
from langchain.chains import SequentialChain
from secret_key import openapi_key
# Reading the OPEN API KEY
os.environ['OPENAI_API_KEY'] = openapi_key
# First chain of command: Name of the organization
def generate_name(feild):
prompt_template = PromptTemplate(
input_variables=["feild"],
template="I want to open a edtech organization for {feild} domain. Suggest a great name for this and the course structure to be followed.",
)
name_chain = LLMChain(llm = model, prompt = prompt_template, output_key = "organization_name")
# Second chain of command: Tips
prompt_template = PromptTemplate(
input_variables=["specifics"],
template="Suggest me tips of how we can elevate the {specifics} for generative AI, and return it in comma seperated format",
)
specific_chain = LLMChain(llm = model, prompt = prompt_template, output_key = "tips")
chain = SequentialChain(
chains = [name_chain, specific_chain],
input_variables = ["feild", "specifics"], # Added "specifics" to the input variables
output_variables = ["organization_name", "tips"]
)
resp = chain({"feild" : feild})
return resp
if __name__ == "__main__":
print(generate_name("Data Science"))