CoolFace
Apppublic

Subbab/chatbox

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py35 linesDownload Raw Back to root
1# Q&A Chatbot2from langchain.llms import OpenAI3 4from dotenv import load_dotenv5 6load_dotenv()  # take environment variables from .env.7 8import streamlit as st9import os10 11 12## Function to load OpenAI model and get respones13 14def get_openai_response(question):15    llm=OpenAI(openai_api_key=os.getenv("OPEN_API_KEY"),model_name="text-davinci-003",temperature=0.5)16    response=llm(question)17    return response18 19##initialize our streamlit app20 21st.set_page_config(page_title="Q&A Demo")22 23st.header("Langchain Application")24 25input=st.text_input("Input: ",key="input")26response=get_openai_response(input)27 28submit=st.button("Ask the question")29 30## If ask button is clicked31 32if submit:33    st.subheader("The Response is")34    st.write(response)35