File size: 517 Bytes
bb05e2d
89c2209
bb05e2d
08a9b60
3e13a7d
78338d6
c5977e3
7b1e2dd
 
78338d6
d05c1c9
78338d6
08a9b60
5cfdd73
08a9b60
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import streamlit as st
from freeGPT import Client

@st.cache(ttl=3600)
def get_response(user_input):
    try:
        response = client.create_completion("gpt3", user_input)
        st.chat_message("You", user_input, avatar=None)
        st.chat_message("KviGPT", response, avatar=None)
    except Exception as e:
        return "Error: {}".format(str(e))

st.sidebar.title("KviGPT")
st.sidebar.subheader("Chat based on Gpt-3")

user_input = st.chat_input("Say something")

if user_input:
    get_response(user_input)