|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
pipe = pipeline('chat', model='mistralai/Mixtral-8x7B-Instruct-v0.1') |
|
|
|
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) |