Flow / app.py
GH111's picture
Update app.py
d890b2c
import streamlit as st
from transformers import pipeline
# Function to generate a message
def generate_message():
return "Hello, this is a generated message!"
# Function to load Hugging Face chatbot model
def load_chatbot_model():
pipe = pipeline("conversational", model="alpindale/goliath-120b")
return pipeline
# Use a pipeline as a high-level helper
# Main Page with Chatbot
def main():
st.title("Main Page with Chatbot")
st.write("Welcome to the Main Page! Type your message to chat with our virtual therapist.")
# Load the chatbot model
chatbot_model = load_chatbot_model()
# User input for the chatbot
user_input = st.text_input("You: ")
# Generate response when user enters input
if user_input:
response = chatbot_model(user_input, max_length=50, num_return_sequences=1)[0]['generated_text']
st.text_area("Therapist:", response, height=100)
# Button to open a new page
if st.button("Open New Page"):
open_new_page()
# Button to generate and show a message
if st.button("Generate Message"):
generate_and_show_message()
# Function to open a new page
def open_new_page():
st.title("New Page")
st.write("This is the New Page!")
# Function to generate and show a message
def generate_and_show_message():
message = generate_message()
st.title("Generated Message")
st.write(f"This message was generated: {message}")
if __name__ == "__main__":
main()