-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
56 lines (39 loc) · 1.34 KB
/
main.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
import openai
import streamlit as st
openai.api_key = st.secrets["OPENAI_API_KEY"]
# Completion Version
def getNameCompletion(prompt):
response = openai.Completion.create(
model="text-davinci-003",
prompt=prompt,
temperature=0.7,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
return response
#Chat Completion Version
def getNameChat(messages):
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=messages,
temperature=0.7
)
return response
st.title("Hedge Fund Name Generator")
st.text("Powered by OpenAI's ChatGPT")
st.divider()
user_prompt = st.text_input(label="Enter some keywords in the text box below to generate some names.")
# user_prompt = 'geographic features, (Global)'
prompt_template=f"""
You are a hedge fund name generator. Given a theme I want you to provide the top 3 names you can come up with.
Make sure not to closely replicate existing hedge fund names.
{user_prompt}
"""
messages = [{"role": "user", "content": prompt_template}]
response = getNameChat(messages=messages)
st.write ("Here are some ideas:")
st.write(response.choices[0].message.content)
st.divider()
st.write("To talk more about some real hedge funds or discuss data science and AI, reach out to me on [LinkedIn](https://www.linkedin.com/in/jonathan-cole-7852a33/).")