Skip to content

Commit

Permalink
tutorial113
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed Aug 30, 2024
1 parent e445f0d commit f2729f1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tutorial113/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import streamlit as st
from langchain_openai import ChatOpenAI
from langchain_mongodb.chat_message_histories import MongoDBChatMessageHistory
llm=ChatOpenAI(model="gpt-4o")

st.title("chat app with message history")
user=st.text_input("enter your username")
qsn=st.text_input("enter your question")
chat_with_history=MongoDBChatMessageHistory(
session_id=user,
connection_string="mongodb+srv://ronidas:[email protected]",
database_name="langchain",
collection_name="chat_history"
)
if user:
if qsn:
btn=st.button("ok")
if btn:
chat_with_history.add_user_message(qsn)
response=llm.invoke(qsn)
chat_with_history.add_ai_message(response.content)
st.write(response.content)
Binary file added tutorial113/tutorial113.pptx
Binary file not shown.

0 comments on commit f2729f1

Please sign in to comment.