singla's picture
Upload 2 files
750a61d
raw
history blame
678 Bytes
# Q&A Chatbot
from langchain.llms import OpenAI
from dotenv import load_dotenv
load_dotenv()
import streamlit as st
import os
##Function to load Open AI model and get response
def get_openai_response(question):
llm = OpenAI(openai_api_key=os.getenv("OPEN_API_KEY"), model_name = "text-davinci-003", temperature = 0.6)
response = llm(question)
return response
## Intialize streamlit app
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 submit:
st.subheader("The response is")
st.write(response)