Spaces:
Runtime error
Runtime error
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)
|