Eli Wilner
first commit
291b2ba
raw
history blame contribute delete
830 Bytes
# Q&A Chatbot
import warnings
warnings.filterwarnings("ignore")
from langchain.llms import OpenAI
from dotenv import load_dotenv
load_dotenv()
import streamlit as st
import os
from typing import Any
## Function to load OpenAI model and get respones
def get_openai_response(question: Any):
llm = OpenAI(openai_api_key=os.getenv("OPEN_API_KEY"),
model_name="gpt-3.5-turbo-instruct",
temperature=.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 asked button is clicked
if submit:
st.subheader("The response is:")
st.write(response)