File size: 2,287 Bytes
36a658e
96b9b91
53d95a9
36a658e
53d95a9
f03bf02
 
 
36a658e
53d95a9
36a658e
 
f03bf02
 
 
 
36a658e
 
53d95a9
36a658e
53d95a9
36a658e
 
 
 
53d95a9
36a658e
f03bf02
0a13ca3
d4c8e4f
 
53d95a9
 
d4c8e4f
53d95a9
f03bf02
0a13ca3
d4c8e4f
 
 
 
53d95a9
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
import streamlit as st
from langchain_openai import ChatOpenAI
from langchain.schema import AIMessage, HumanMessage, SystemMessage

# Streamlit UI ์„ค์ •
st.set_page_config(page_title="๊ฒฝ๊ธฐ์ผ๋ณด ํ—ค๋“œ๋ผ์ธ ์ƒ์„ฑ AI", page_icon=":robot:")
#st.header("์•ˆ๋…•ํ•˜์„ธ์š”. ๊ธฐ์‚ฌ๋‚ด์šฉ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
st.header("์•ˆ๋…•ํ•˜์„ธ์š”. ๊ธฐ์‚ฌ๋‚ด์šฉ์„ ์ž…๋ ฅํ•˜์‹œ๋ฉด ๋ฉ‹์ง„ ๊ธฐ์‚ฌ ์ œ๋ชฉ์„ ์ƒ์„ฑํ•ด๋“œ๋ฆฝ๋‹ˆ๋‹ค!")

# ์„ธ์…˜ ๋ฉ”์‹œ์ง€ ์ดˆ๊ธฐํ™”
if "sessionMessages" not in st.session_state:
    st.session_state.sessionMessages = [
        SystemMessage(content="Imagine you are a seasoned journalist with a keen insight into societal trends, audience interests, and the pulse of current events. You have a knack for condensing complex stories into captivating titles that instantly grab attention. Your task is to create a newspaper article title that resonates with readers by sparking curiosity, offering value, or highlighting urgent issues. The title should be concise, no more than ten words, and must cleverly use language to intrigue, provoke thought, or convey the significance of the story. Consider using puns, alliterations, or unexpected juxtapositions to make the title memorable. Reflect on the core message of the article, its impact on the reader, and the broader implications for society. The title should stand as a call to action or an invitation to delve deeper into the narrative, compelling the subscriber to engage with the content immediately


Make a Korean title on the upper article.")
    ]

# ๋Œ€๋‹ต ๋กœ๋“œ ํ•จ์ˆ˜
def load_answer(question):
    st.session_state.sessionMessages.append(HumanMessage(content=question))
    assistant_answer = chat(st.session_state.sessionMessages)
    st.session_state.sessionMessages.append(AIMessage(content=assistant_answer.content))
    return assistant_answer.content

# ์‚ฌ์šฉ์ž ์ž…๋ ฅ ๋ฐ›๊ธฐ
def get_text():
    #input_text = st.text_input("๊ธฐ์ž: ", key="input")
    input_text = st.text_input("Client: ", key="input")
    return input_text

# ChatOpenAI ๊ฐ์ฒด ์ƒ์„ฑ
chat = ChatOpenAI(temperature=0.7)

user_input = get_text()
#submit = st.button('์ œ๋ชฉ ์ƒ์„ฑํ•˜๊ธฐ')
submit = st.button('Counsel')

if submit:
    response = load_answer(user_input)
    st.subheader("Answer:")
    st.write(response, key=1)