Space3 / app.py
SAMBOOM's picture
Create app.py
ec839a1 verified
raw
history blame
605 Bytes
import streamlit as st
from transformers import pipeline
pipe = pipeline('chat', model='mistral-ai/mistral-large-en')
if 'message' not in st.session_state:
st.session_state.message = []
def user_input():
user_input = st.chat_input("Ask me anything!")
st.session_state.message.append({"role": "user", "content": user_input})
if user_input:
return True
return False
if user_input():
response = pipe(st.session_state.message)[0]['generated_text']
st.session_state.message.append({"role": "assistant", "content": response})
st.chat_message(st.session_state.message)