Manith Marapperuma commited on
Commit
4617143
·
verified ·
1 Parent(s): 5e7d199

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Initialize the pipeline with the Mistral model
5
+ generator = pipeline(model="bigscience/Mistral", model_kwargs={"use_auth_token": True})
6
+
7
+ # Streamlit app setup
8
+ st.title('Mistral LLM Explorer with Transformers')
9
+ st.write('Enter your prompt below to interact with the Mistral model.')
10
+
11
+ # User input
12
+ user_input = st.text_area("Prompt:")
13
+
14
+ # When the user presses the 'Submit' button
15
+ if st.button('Submit'):
16
+ if user_input:
17
+ with st.spinner('Generating response...'):
18
+ # Generate response from the Mistral model
19
+ results = generator(user_input, max_length=100, clean_up_tokenization_spaces=True)
20
+ # Display the generated text
21
+ st.text_area("Response:", value=results[0]['generated_text'], height=300)
22
+ else:
23
+ st.warning('Please enter a prompt.')