Spaces:
Sleeping
Sleeping
Commit
·
bb05e2d
1
Parent(s):
b7cbcd2
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from freegpt import Client
|
3 |
+
|
4 |
+
# Initialize the client with your API key
|
5 |
+
client = Client()
|
6 |
+
|
7 |
+
st.title("ChatBot")
|
8 |
+
st.write("Welcome to our ChatBot! Ask me anything.")
|
9 |
+
|
10 |
+
# Create a text area for user input
|
11 |
+
user_input = st.text_area("Enter your message here: ", height=100)
|
12 |
+
|
13 |
+
# Create a submit button
|
14 |
+
submit_button = st.button("Submit")
|
15 |
+
|
16 |
+
# Define a function to handle form submission
|
17 |
+
def handle_form():
|
18 |
+
global user_input
|
19 |
+
if user_input != "":
|
20 |
+
# Generate response using the freeGPT model
|
21 |
+
response = client.create_completion("MODEL", user_input)
|
22 |
+
|
23 |
+
# Print the response
|
24 |
+
st.write(response)
|
25 |
+
else:
|
26 |
+
st.write("Please enter a valid message.")
|
27 |
+
|
28 |
+
# Set up event handler for submit button click
|
29 |
+
submit_button.onclick(handle_form)
|
30 |
+
|
31 |
+
# Display the form
|
32 |
+
st.form(user_input, submit_button)
|