File size: 1,559 Bytes
c8a0f34
 
 
7b6cdd4
 
c020cdf
 
 
c8a0f34
54c11e5
 
307f1d8
 
 
 
 
 
 
 
 
 
c020cdf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import streamlit as st
from transformers import pipeline
from PIL import Image
from datetime import time

if "messages" not in st.session_state:
    st.session_state.messages = []


st.title("USC GPT - Find the perfect class")

class_time = st.slider(
    "Filter Class Times:",
    value=(time(11, 30), time(12, 45)))

# st.write("You're scheduled for:", class_time)

units = st.slider(
    "Number of units",
    1, 4,
    value = (1, 4)
)


for message in st.session_state.messages:
    with st.chat_message(message["role"]):
        st.markdown(message["content"])

if prompt := st.chat_input("What kind of class are you looking for?"):
    # Display user message in chat message container
    with st.chat_message("user"):
        st.markdown(prompt)
    # Add user message to chat history
    st.session_state.messages.append({"role": "user", "content": prompt})



### GPT Response
# Display assistant response in chat message container
with st.chat_message("assistant"):
    message_placeholder = st.empty()
    full_response = ""
    assistant_response = "Hello there! How can I assist you today?"
    )
    # Simulate stream of response with milliseconds delay
    for chunk in assistant_response.split():
        full_response += chunk + " "
        time.sleep(0.05)
        # Add a blinking cursor to simulate typing
        message_placeholder.markdown(full_response + "▌")
    message_placeholder.markdown(full_response)
# Add assistant response to chat history
st.session_state.messages.append({"role": "assistant", "content": full_response})