from langchain.llms import OpenAI from dotenv import load_dotenv import os load_dotenv() import streamlit as st ## function to load openai and get responses def get_openai_response(quesetion): llm=OpenAI(openai_api_key=os.getenv("OPEN_API_KEY"), model_name="text-davinci-003", temperature=0.5) response = llm(quesetion) return response ## initialize streamlit and set input field and button st.set_page_config(page_title="Q&A demo") st.header("Langchain application") input = st.text_input("Input: ", key="input") response = get_openai_response(input) submit = st.button("Ask the question") ## if button is submitted if submit: st.subheader("The response is") st.write(response)