Download chatMode.py from Kurian07/RAG_LLM: direct link, hf CLI and curl.
- Browser
- Download file 954 Bytes
-
https://huggingface.co/spaces/Kurian07/RAG_LLM/resolve/main/chatMode.py
- Command line
-
hf download hf://spaces/Kurian07/RAG_LLM/chatMode.py
-
curl -L -o chatMode.py https://huggingface.co/spaces/Kurian07/RAG_LLM/resolve/main/chatMode.py
954 Bytes
| import streamlit as st | |
| import os | |
| def chat_response(user_prompt, assistant_response): | |
| if "chat_history" not in st.session_state: | |
| st.session_state.chat_history = [] | |
| for message in st.session_state.chat_history: | |
| if message["role"] == "user": | |
| with st.chat_message("user"): | |
| st.write(f"**You**: {message['content']}") | |
| elif message["role"] == "assistant": | |
| with st.chat_message("assistant"): | |
| st.write(f"**Assistant**: {message['content']}") | |
| if user_prompt: | |
| st.session_state.chat_history.append({"role": "user", "content": user_prompt}) | |
| with st.chat_message("user"): | |
| st.write(f"**You**: {user_prompt}") | |
| with st.chat_message("assistant"): | |
| st.write(f"**Assistant**: {assistant_response}") | |
| st.session_state.chat_history.append({"role": "assistant", "content": assistant_response}) |