# Author : Sapnil Patel # Date : 18/12/23 # This file contains the code related to Chatbot Application # Import libraries import os import streamlit as st from dotenv import load_dotenv from langchain.llms import OpenAI # take evironment variables from .env file load_dotenv() # Function to load OpenAI and get response def get_openai_response(question): llm = OpenAI(openai_api_key=os.getenv("OPEANAI_API_KEY"),model_name='text-davinci-003',temperature=0.5) response=llm(question) return response # Initialize our streamlit app st.set_page_config(page_title = "Q & A App") st.header("Langchain Application with OpenAI") input = st.text_input("Input: ", key="Input") response = get_openai_response(input) submit = st.button("Ask the question") # If ask button is clicked if submit: st.subheader("The Response is") st.write(response)