|
from annotated_text import annotated_text |
|
import streamlit as st |
|
import openai |
|
import os |
|
|
|
|
|
openai.api_key = os.getenv("OPENAI_API_KEY") |
|
|
|
def main(): |
|
st.title("ํ๊ตญ์ด ํ์ต์๋ฅผ ์ํ HCI tools") |
|
|
|
col1, col2 = st.columns(2) |
|
|
|
with col1: |
|
st.header("์ง๋ฌธ") |
|
|
|
user_text = """๋ฏผ์ฃผ์ฃผ์ ์ฌํ๋ ๊ตญ๋ฏผ์ด ์ ์น์ ์ฐธ์ฌํ ๊ถ๋ฆฌ๋ฅผ ๋ณด์ฅํ๋ค. ๊ทธ๋ฌํ ๊ถ๋ฆฌ๋ฅผ ์ฐธ์ ๊ถ์ด๋ผ ํ๋๋ฐ, ์ด๋ ๊ธฐ๋ณธ์ ์ผ๋ก โ์ ๊ฑฐโ๋ก ์คํ๋๋ค. ์ ๊ฑฐ๋ ์ฌํ ์ง๋จ์ ๋ํ์๋ ๊ณต์ง์๋ฅผ ์ ์ถํ์ฌ ๊ทธ๋ค์๊ฒ ๋ํ์ฑ์ ๋ถ์ฌํ๋ ํ์์ด๋ค. ๊ทธ๋ฌ๋ฏ๋ก ๋์ ํฌํ์จ์ ๋ฏผ์ฃผ์ฃผ์์ ์ ๋น์ฑ ํ๋ณด์ ๊น์ ๊ด๋ จ์ด ์๋ค.""" |
|
st.write(user_text) |
|
|
|
|
|
with col2: |
|
st.header("์กฐ์ ํจ๋") |
|
user_input = st.text_input("๋ชจ๋ฅด๋ ๋ฌธ์ฅ์ด๋ ๋จ์ด๋ฅผ ์
๋ ฅํ์ธ์:", "") |
|
|
|
|
|
cols = st.columns(4) |
|
with cols[0]: |
|
btn_keyword = st.button("ํค์๋ ์ฐพ๊ธฐ") |
|
with cols[1]: |
|
btn_explanation = st.button("์ถ๊ฐ ์ค๋ช
") |
|
with cols[2]: |
|
btn_simple = st.button("์ฌ์ด ํํ") |
|
with cols[3]: |
|
btn_rewrite = st.button("๋ค์ ์ฐ๊ธฐ") |
|
|
|
|
|
with st.container(): |
|
st.header("๊ฒฐ๊ณผ") |
|
|
|
if btn_keyword: |
|
|
|
|
|
|
|
response = openai.ChatCompletion.create( |
|
model="gpt-3.5-turbo-16k", |
|
prompt=f"Extract key words from the text: {user_text}", |
|
temperature=0.1, |
|
max_tokens=200 |
|
) |
|
keywords = response['choices'][0]['text'] |
|
|
|
keywords = "๋ฏผ์ฃผ์ฃผ์, ๊ตญ๋ฏผ, ์ ์น, ์ฐธ์ฌ, ๊ถ๋ฆฌ, ์ฐธ์ ๊ถ, ์ ๊ฑฐ, ์ฌํ ์ง๋จ, ๋ํ์, ๊ณต์ง์, ๋ํ์ฑ, ํฌํ์จ, ์ ๋น์ฑ" |
|
st.write(f"ํค์๋: {keywords}") |
|
|
|
if btn_explanation: |
|
|
|
|
|
|
|
response = openai.ChatCompletion.create( |
|
model="gpt-3.5-turbo-16k", |
|
prompt=f"Explain the term '{user_input}' in the context of the text: {user_text}", |
|
temperature=0.1, |
|
max_tokens=200 |
|
) |
|
explanation = response['choices'][0]['text'] |
|
|
|
explanation = "์ฌ๊ธฐ์ ์ถ๊ฐ ์ค๋ช
์ด ๋ค์ด๊ฐ๋๋ค." |
|
st.write(f"์ค๋ช
: {explanation}") |
|
|
|
if btn_simple: |
|
|
|
|
|
|
|
response = openai.ChatCompletion.create( |
|
model="gpt-3.5-turbo-16k", |
|
prompt=f"Rewrite the text in simpler terms: {user_text}", |
|
temperature=0.1, |
|
max_tokens=200 |
|
) |
|
simple_text = response['choices'][0]['text'] |
|
simple_text = "์ฌ๊ธฐ์ ์ฌ์ด ํํ์ด ๋ค์ด๊ฐ๋๋ค." |
|
st.write(f"์ฌ์ด ํํ: {simple_text}") |
|
|
|
if btn_rewrite: |
|
|
|
|
|
|
|
response = openai.ChatCompletion.create( |
|
model="gpt-3.5-turbo-16k", |
|
prompt=f"Rewrite the text: {user_text}", |
|
temperature=0.1, |
|
max_tokens=200 |
|
) |
|
rewritten_text = response['choices'][0]['text'] |
|
|
|
rewritten_text = "์ฌ๊ธฐ์ ๋ค์ ์ด ํ
์คํธ๊ฐ ๋ค์ด๊ฐ๋๋ค." |
|
st.write(f"๋ค์ ์ฐ๊ธฐ: {rewritten_text}") |
|
|
|
if __name__ == "__main__": |
|
main() |
|
|