[e1b945]: / scripts / 01.chatgpt_api_app_example.py

Download this file

28 lines (22 with data), 546 Bytes

 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
import streamlit as st
import openai
openai.api_key = YOUR_API_KEY
st.set_page_config(page_title="Chat GPT API EXAMPLE", page_icon=":tada:", layout="wide")
st.subheader(
"""
This is Test Landing Page
"""
)
st.title("EXAMPLE")
title = st.text_input("YOU:")
response = openai.Completion.create(
model="text-davinci-003",
prompt=title,
temperature=0,
max_tokens=60,
top_p=1,
frequency_penalty=0.5,
presence_penalty=0,
)
if st.button("Send"):
st.success(response.choices[0].text)