Anoop Srivastava
Upload app.py
5d70aee
raw
history blame contribute delete
761 Bytes
# Q&A chatbot
from langchain.llms import OpenAI
from dotenv import load_dotenv
import streamlit as st
import os
# take environment variables from .env
load_dotenv()
# Function to load OpenAI model and get response
def get_openai_reponse(question):
llm = OpenAI(openai_api_key=os.getenv("OPEN_API_KEY"), model_name='text-davinci-003',
temperature=0.6)
response = llm(question)
return response
# initialize our 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_reponse(input)
submit = st.button("Ask the question")
# If ask button is clicked
if submit:
st.subheader("The response is: ")
st.write(response)