SAMBOOM commited on
Commit
ec839a1
1 Parent(s): bf1d2d9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
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)