| |
| 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 |
|
|
| |
| os.environ['OPENAI_API_KEY'] = openapi_key |
|
|
| |
| 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") |
| |
| |
| |
| 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"], |
| output_variables = ["organization_name", "tips"] |
| ) |
|
|
| resp = chain({"feild" : feild}) |
|
|
| return resp |
|
|
|
|
| if __name__ == "__main__": |
| print(generate_name("Data Science")) |