File size: 805 Bytes
8bbfca2
41fe4ff
8bbfca2
41fe4ff
 
8bbfca2
41fe4ff
 
 
8bbfca2
41fe4ff
 
8bbfca2
41fe4ff
 
 
 
a5a0bc7
41fe4ff
0221f0f
41fe4ff
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import streamlit as st
from transformers import pipeline

# Load the conversational pipeline
conversational_pipeline = pipeline("conversational")

# Streamlit app header
st.set_page_config(page_title="Conversational Model Demo", page_icon="🤖")
st.header("Conversational Model Demo")

# Input for user message
user_message = st.text_input("You:", "")

if st.button("Send"):
    # Format the conversation for the conversational pipeline
    conversation_history = [{"role": "system", "content": "You are an AI assistant."},
                           {"role": "user", "content": user_message}]

    # Get the model's response
    model_response = conversational_pipeline(conversation_history)[0]['generated_text']

    # Display the model's response
    st.text_area("Model:", model_response, height=100)