Spaces:
Sleeping
Sleeping
from langchain.llms import OpenAI | |
from dotenv import load_dotenv | |
import streamlit as st | |
import os | |
load_dotenv() | |
# function to load OpenAI model and get responses | |
def get_openai_response(question): | |
llm = OpenAI(openai_api_key=os.getenv('OPENAI_API_KEY'), model_name="text-davinci-003", temperature=0.5) | |
output = llm(question) | |
return output | |
# initialize streamlit app | |
st.set_page_config(page_title="Q&A Demo") | |
st.header("Langchain Application") | |
intext = st.text_input("Input: ", key="input") | |
response = get_openai_response(intext) | |
submit = st.button("Ask Question") | |
# if submit button is clicked | |
if submit: | |
st.subheader("The Response is") | |
st.write(response) | |