import streamlit as st from langchain.llms import OpenAI from langchain import PromptTemplate, LLMChain def llm_setup(): llm = OpenAI(temperature=0.7, openai_api_key = st.secrets["OPENAI_API_KEY"]) template = """ Convert the following sentence to pirate english: {input_text} """ prompt_template = PromptTemplate(input_variables = ["input_text"], template = template) llm_chain = LLMChain(prompt=prompt_template, llm=llm) return llm_chain def generate_questions(): llm_chain = llm_setup() st.session_state.output_text = llm_chain.run(st.session_state.input_text) st.write("Sitafal Test Generator") input_text = st.text_area('Give topic deatils', key="input_text") generate_button = st.button("Generate", key="generate_button", on_click = generate_questions) output_text = st.text_area("Generated questions", key = "output_text")