tykimos commited on
Commit
3a20360
Β·
1 Parent(s): e787eaf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -33
app.py CHANGED
@@ -5,10 +5,10 @@ from streamlit_pills import pills
5
  st.subheader("AI Assistant : Streamlit + OpenAI: `stream` *argument*")
6
 
7
  # You can also use radio buttons instead
8
- selected = pills("", ["NO Streaming", "Streaming"], ["🎈", "🌈"])
9
 
10
- user_input = st.text_input("You: ",placeholder = "Ask me anything ...", key="input")
11
- api_key = st.text_input("api_key: ",placeholder = "api_key ...", key="api_key")
12
 
13
  if st.button("Submit", type="primary"):
14
  st.markdown("----")
@@ -16,35 +16,25 @@ if st.button("Submit", type="primary"):
16
 
17
  openai.api_key = api_key
18
 
19
- if selected == "Streaming":
20
- report = []
21
- # Looping over the response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- for resp in openai.Completion.create(
24
- model="text-davinci-003",
25
- 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해석:",
26
- temperature=0.3,
27
- max_tokens=1607,
28
- top_p=1,
29
- frequency_penalty=0,
30
- presence_penalty=0,
31
- stream = True
32
- ):
33
- # join method to concatenate the elements of the list
34
- # into a single string,
35
- # then strip out any empty strings
36
- report.append(resp.choices[0].text)
37
- result = "".join(report).strip()
38
- result = result.replace("\n", "")
39
- res_box.markdown(f'*{result}*')
40
-
41
- else:
42
- completions = openai.Completion.create(model='text-davinci-003',
43
- prompt=user_input,
44
- max_tokens=120,
45
- temperature = 0.5,
46
- stream = False)
47
- result = completions.choices[0].text
48
-
49
- res_box.write(result)
50
  st.markdown("----")
 
5
  st.subheader("AI Assistant : Streamlit + OpenAI: `stream` *argument*")
6
 
7
  # You can also use radio buttons instead
8
+ selected = pills("", ["질문", "건강"], ["🎈", "🌈"])
9
 
10
+ user_input = st.text_input("You: ",placeholder = "고민이 λ¬΄μ—‡μž…λ‹ˆκΉŒ?", key="input")
11
+ api_key = st.text_input("api_key: ",placeholder = "OpenAI API Key", key="api_key")
12
 
13
  if st.button("Submit", type="primary"):
14
  st.markdown("----")
 
16
 
17
  openai.api_key = api_key
18
 
19
+ report = []
20
+ # Looping over the response
21
+
22
+ for resp in openai.Completion.create(
23
+ model="text-davinci-003",
24
+ 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해석:",
25
+ temperature=0.3,
26
+ max_tokens=1607,
27
+ top_p=1,
28
+ frequency_penalty=0,
29
+ presence_penalty=0,
30
+ stream = True
31
+ ):
32
+ # join method to concatenate the elements of the list
33
+ # into a single string,
34
+ # then strip out any empty strings
35
+ report.append(resp.choices[0].text)
36
+ result = "".join(report).strip()
37
+ #result = result.replace("\n", "")
38
+ res_box.markdown({result})
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  st.markdown("----")