-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
104 lines (82 loc) · 2.94 KB
/
app.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import openai
import streamlit as st
streamlit_style = """
<style>
@import url('https://fonts.googleapis.com/css2?family=Cutive+Mono&display=swap');
html, body, [class*="css"] {
font-family: 'Cutive Mono', monospace;
}
</style>
"""
st.markdown(streamlit_style, unsafe_allow_html = True)
openai.api_key = st.secrets["SECRET_KEY"]
#text on the bottom position of the page
st.title('Behaviour Cloning')
st.caption('Still in development.')
st.caption('Backed by [Inside Labs](https://insidelibrary.weebly.com/)')
st.markdown('This is an experiment of prompt designing by using GPT-3(A Transformer based model), a neural network trained and hosted by OpenAI.')
st.caption('Tips: Try to ask specific detaied questions, like "Why are you?"')
prompt_text = st.text_input(label="Input" , value="Ask me anything!")
response0 = openai.Completion.create(
engine="davinci-instruct-beta-v3",
max_tokens=500,
prompt="Expand the prompt text in to a detailed philosophical and creative explanation.\n\n {}".format(prompt_text),
temperature=0.8,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
response1 = openai.Completion.create(
engine="davinci-instruct-beta-v3",
max_tokens=500,
prompt="Expand the prompt text into a full chad response.\n\n {}".format(prompt_text),
temperature=0.8,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
response2 = openai.Completion.create(
engine="davinci-instruct-beta-v3",
max_tokens=500,
prompt="Expand the prompt text into a Playboy type of response.\n\n {}".format(prompt_text),
temperature=0.8,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
response3 = openai.Completion.create(
engine="davinci-instruct-beta-v3",
max_tokens=500,
prompt="Expand the prompt text into a funny, dank and roasting response.\n\n {}".format(prompt_text),
temperature=0.8,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
response4 = openai.Completion.create(
engine="davinci-instruct-beta-v3",
max_tokens=500,
prompt="Create a creative Poem with strict rhyme scheme for \n{}".format(prompt_text),
temperature=0.8,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
st.text('Output:')
#sidebar
st.sidebar.title('Behavioral Cloning')
st.sidebar.text('Choose a behaviour to clone:')
response_type = st.sidebar.selectbox('Behaviour types', ['Default', 'Denk', 'CowBoy', 'Philosopher', 'Poet'])
if st.button('Generate'):
if response_type == 'Default':
st.markdown(response0.choices[0].text)
elif response_type == 'Denk':
st.markdown(response1.choices[0].text)
elif response_type == 'CowBoy':
st.markdown(response2.choices[0].text)
elif response_type == 'Philosopher':
st.markdown(response3.choices[0].text)
elif response_type == 'Poet' :
st.markdown(response4.choices[0].text)
else:
st.markdown('Please select a behaviour to clone.')