souvikmaji22's picture
Upload app.py
1bdff54 verified
raw
history blame
756 Bytes
# Chatbot
from langchain_community.llms import OpenAI
from dotenv import load_dotenv
load_dotenv() #take environment variable from .env
import streamlit as st
import os
## function to load OpenAI model and get reponses
def response(question):
llm = OpenAI(openai_api_key=os.getenv("OPEN_API_KEY"), model_name="gpt-3.5-turbo-instruct",temperature=0.6)
res= llm(question)
return res
# streamlit
st.set_page_config(page_title="Question Answering App")
st.header("Langchain Question Answering App")
input = st.text_input("Input: ",key="input")
res=response(input)
submit = st.button("Ask the Question")
# when button is clicked, we should get response
if submit:
st.subheader("RESPONSE:")
st.write(res)