File size: 858 Bytes
bb05e2d
e9b1dfc
bb05e2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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)