File size: 1,040 Bytes
aded65f
b95f6dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4e6eff0
 
 
aded65f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import streamlit as st
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
import transformers

# Define the Streamlit app
st.title("Mistral Model Integration")

# Create a text input for the user to enter their prompt
instruction = st.text_area("Enter your prompt:")

# Function to interact with Mistral Model
def mistral_model(prompt, token_limit):
    # Your model loading and inference code here (from the code you provided)
    # ...

    return responses

# Check if the user entered a prompt
if instruction:
    # Add a slider for selecting the token limit
    token_limit = st.slider("Select token limit", min_value=10, max_value=500, value=250)

    # Create a button to trigger model inference
    if st.button("Generate Response"):
        responses = mistral_model(instruction, token_limit)
        st.write("Generated Responses:")
        for response in responses:
            st.write(response)

# # Finally, run the Streamlit app
# if __name__ == "__main__":
#     st.run()