Spaces:
Sleeping
Sleeping
File size: 943 Bytes
767f45d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import os
import streamlit as st
from langchain.schema import HumanMessage, SystemMessage, AIMessage
from langchain_community.chat_models import ChatOpenAI
st.set_page_config(page_title="Convorsational QA Chatbot")
st.header("Hey, Type your queries")
from dotenv import load_dotenv
load_dotenv()
chat = ChatOpenAI(temperature=0.5)
if 'flownMessages' not in st.session_state:
st.session_state['flownMessages'] = [
SystemMessage(content="You are a simple therapist")
]
def get_chatmodel_response(query):
st.session_state['flownMessages'].append(HumanMessage(content=query))
answer = chat(st.session_state['flownMessages'])
st.session_state['flownMessages'].append(AIMessage(answer.content))
return answer.content
input = st.text_input("Input: ", key="input")
response = get_chatmodel_response(input)
submit = st.button("Ask the question")
if submit:
st.subheader("The Response is: ")
st.write(response)
|