Spaces:
Sleeping
Sleeping
import streamlit as st | |
import freegpt | |
from freegpt import Client | |
# Initialize the client with your API key | |
client = Client() | |
st.title("ChatBot") | |
st.write("Welcome to our ChatBot! Ask me anything.") | |
# Create a text area for user input | |
user_input = st.text_area("Enter your message here: ", height=100) | |
# Create a submit button | |
submit_button = st.button("Submit") | |
# Define a function to handle form submission | |
def handle_form(): | |
global user_input | |
if user_input != "": | |
# Generate response using the freeGPT model | |
response = client.create_completion("MODEL", user_input) | |
# Print the response | |
st.write(response) | |
else: | |
st.write("Please enter a valid message.") | |
# Set up event handler for submit button click | |
submit_button.onclick(handle_form) | |
# Display the form | |
st.form(user_input, submit_button) |