TarotGPT / app.py
tykimos's picture
Update app.py
aaad262
raw
history blame
4.55 kB
import openai
import streamlit as st
from streamlit_pills import pills
st.subheader("AI Assistant : Streamlit + OpenAI: `stream` *argument*")
# You can also use radio buttons instead
selected = pills("", ["์งˆ๋ฌธ", "๊ฑด๊ฐ•"], ["๐ŸŽˆ", "๐ŸŒˆ"])
user_input = st.text_input("You: ",placeholder = "๊ณ ๋ฏผ์ด ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?", key="input")
api_key = st.text_input("api_key: ",placeholder = "OpenAI API Key", key="api_key")
if st.button("Submit", type="primary"):
st.markdown("----")
res_box = st.empty()
openai.api_key = api_key
report = []
# Looping over the response
for resp in openai.Completion.create(
model="text-davinci-003",
prompt="๋‹น์‹ ์€ ํƒ€๋กœ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค. \n1. ํ•˜๋‹จ์˜ [์งˆ๋ฌธ]์„ ์ดํ•ดํ•œ ํ›„ [ํƒ€๋กœ์นด๋“œ๋ชฉ๋ก]์—์„œ ์ž„์˜์˜ 3์žฅ์˜ ์นด๋“œ๋ฅผ ๊ณ ๋ฆ…๋‹ˆ๋‹ค.\n2. [์งˆ๋ฌธ]์— ๋งž๊ฒŒ ๊ณ ๋ฅธ ์นด๋“œ๋ฅผ ์ˆœ์„œ๋Œ€๋กœ ํ•ด์„ํ•œ ๋’ค, ์ข…ํ•ฉ์ ์œผ๋กœ ํ•ด์„ํ•œ ๋‚ด์šฉ์„ ๊นŠ์ด์žˆ๊ณ  ์นœ์ ˆํ•˜๊ฒŒ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.\n\n[์งˆ๋ฌธ]: \"" + user_input + "\"\n\n[ํƒ€๋กœ์นด๋“œ๋ชฉ๋ก] \n{์นด๋“œ ๋ฒˆํ˜ธ}, {์นด๋“œ ์ด๋ฆ„}, {์นด๋“œ ๋งํฌ}\n1, The Fool, 9/90/RWS_Tarot_00_Fool \n2, The Magician, d/de/RWS_Tarot_01_Magician \n3, The High Priestess, 8/88/RWS_Tarot_02_High_Priestess \n4, The Empress, d/d2/RWS_Tarot_03_Empress \n5, The Emperor, c/c3/RWS_Tarot_04_Emperor \n6, The Hierophant, 8/8d/RWS_Tarot_05_Hierophant \n7, The Lovers, 3/3a/TheLovers \n8, The Chariot, 9/9b/RWS_Tarot_07_Chariot \n9, Strength, f/f5/RWS_Tarot_08_Strength \n10, The Hermit, 4/4d/RWS_Tarot_09_Hermit \n11, Wheel of Fortune, 3/3c/RWS_Tarot_10_Wheel_of_Fortune \n12, Justice, e/e0/RWS_Tarot_11_Justice \n13, The Hanged Man, 2/2b/RWS_Tarot_12_Hanged_Man \n14, Death, d/d7/RWS_Tarot_13_Death \n15, Temperance, f/f8/RWS_Tarot_14_Temperance \n16, The Devil, 5/55/RWS_Tarot_15_Devil\n17, The Tower, 5/53/RWS_Tarot_16_Tower \n18, The Star, d/db/RWS_Tarot_17_Star \n19, The Moon, 7/7f/RWS_Tarot_18_Moon \n20, The Sun, 1/17/RWS_Tarot_19_Sun \n21, Judgment, d/dd/RWS_Tarot_20_Judgement \n22, The World, f/ff/RWS_Tarot_21_World 2\n3, Ace of Wands, 1/11/Wands01 \n24, Two of Wands, 0/0f/Wands02 \n25, Three of Wands, f/ff/Wands03 \n26, Four of Wands, a/a4/Wands04 \n27, Five of Wands, 9/9d/Wands05 \n28, Six of Wands, 3/3b/Wands06 \n29, Seven of Wands, e/e4/Wands07 \n30, Eight of Wands, 6/6b/Wands08 \n31, Nine of Wands, /4/4d/Tarot_Nine_of_Wands \n32, Ten of Wands, 0/0b/Wands10 \n33, Page of Wands, 6/6a/Wands11 \n34, Knight of Wands, 1/16/Wands12 \n35, Queen of Wands, 0/0d/Wands13 \n36, King of Wands, c/ce/Wands14 \n37, Ace of Cups, 3/36/Cups01 \n38, Two of Cups, f/f8/Cups02 \n39, Three of Cups, 7/7a/Cups03 \n40, Four of Cups, 3/35/Cups04 \n41, Five of Cups, d/d7/Cups05 \n42, Six of Cups, 1/17/Cups06 \n43, Seven of Cups, a/ae/Cups07 \n44, Eight of Cups, 6/60/Cups08 \n45, Nine of Cups, 2/24/Cups09 \n46, Ten of Cups, 8/84/Cups10 \n47, Page of Cups, a/ad/Cups11 \n48, Knight of Cups, f/fa/Cups12 \n49, Queen of Cups, 6/62/Cups13 \n50, King of Cups, 0/04/Cups14 \n51, Ace of Swords, 1/1a/Swords01 \n52, Two of Swords, 9/9e/Swords02 \n53, Three of Swords, 0/02/Swords03 \n54, Four of Swords, b/bf/Swords04 \n55, Five of Swords, 2/23/Swords05 \n56, Six of Swords, 2/29/Swords06 \n57, Seven of Swords, 3/34/Swords07 \n58, Eight of Swords, a/a7/Swords08 \n59, Nine of Swords, 2/2f/Swords09 \n60, Ten of Swords, d/d4/Swords10 \n61, Page of Swords, 4/4c/Swords11 \n62, Knight of Swords, b/b0/Swords12 \n63, Queen of Swords, d/d4/Swords13 \n64, King of Swords, 3/33/Swords14 \n65, Ace of Pentacles, f/fd/Pents01 \n66, Two of Pentacles, 9/9f/Pents02 \n67, Three of Pentacles, 4/42/Pents03 \n68, Four of Pentacles, 3/35/Pents04 \n69, Five of Pentacles, 9/96/Pents05 \n70, Six of Pentacles, a/a6/Pents06 \n71, Seven of Pentacles, 6/6a/Pents07 \n72, Eight of Pentacles, 4/49/Pents08 \n73, Nine of Pentacles, f/f0/Pents09 \n74, Ten of Pentacles, 4/42/Pents10 \n75, Page of Pentacles, e/ec/Pents11 \n76, Knight of Pentacles, d/d5/Pents12 \n77, Queen of Pentacles, 8/88/Pents13 \n78, King of Pentacles, 1/1c/Pents14\n\nํ•ด์„:",
temperature=0.3,
max_tokens=1607,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
stream = True
):
# join method to concatenate the elements of the list
# into a single string,
# then strip out any empty strings
report.append(resp.choices[0].text)
result = "".join(report).strip()
#result = result.replace("\n", "")
res_box = None
res_box.markdown({result})
st.markdown("----")