Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
pipe = pipeline('chat', model='mistral-ai/mistral-large-en')
|
5 |
+
|
6 |
+
if 'message' not in st.session_state:
|
7 |
+
st.session_state.message = []
|
8 |
+
|
9 |
+
def user_input():
|
10 |
+
user_input = st.chat_input("Ask me anything!")
|
11 |
+
st.session_state.message.append({"role": "user", "content": user_input})
|
12 |
+
if user_input:
|
13 |
+
return True
|
14 |
+
return False
|
15 |
+
|
16 |
+
if user_input():
|
17 |
+
response = pipe(st.session_state.message)[0]['generated_text']
|
18 |
+
st.session_state.message.append({"role": "assistant", "content": response})
|
19 |
+
st.chat_message(st.session_state.message)
|