#conversational Q&A chatbot import streamlit as st import os from langchain.schema import HumanMessage, SystemMessage, AIMessage from langchain_openai import ChatOpenAI #streamlit UI st.set_page_config(page_title='Conversationl QA chatbot') st.header('Hello, let do the chat') #from dotenv import load_dotenv #load_dotenv() chat=ChatOpenAI(temperature=0.5) if 'flowmessages' not in st.session_state : st.session_state['flowmessages']=[SystemMessage(content='Yor are a conversational chatbot')] #write a function for chatbot def get_chat(quetion): st.session_state['flowmessages'].append(HumanMessage(content=quetion)) answer=chat(st.session_state['flowmessages']) st.session_state['flowmessages'].append(AIMessage(content=answer.content)) return answer.content input=st.text_input("Input: ", key='input') response=get_chat(input) submit=st.button("Ask the Question") #if button is clicked if submit: response=get_chat(input) st.subheader('The response is: ') st.write(response)