#!pip install streamlit
Requirement already satisfied: streamlit in e:\anaconda3\envs\openai\lib\site-packages (1.32.2) Requirement already satisfied: altair<6,>=4.0 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (5.2.0) Requirement already satisfied: blinker<2,>=1.0.0 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (1.7.0) Requirement already satisfied: cachetools<6,>=4.0 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (5.3.3) Requirement already satisfied: click<9,>=7.0 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (8.1.7) Requirement already satisfied: numpy<2,>=1.19.3 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (1.24.4) Requirement already satisfied: packaging<24,>=16.8 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (23.2) Requirement already satisfied: pandas<3,>=1.3.0 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (2.0.3) Requirement already satisfied: pillow<11,>=7.1.0 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (10.2.0) Requirement already satisfied: protobuf<5,>=3.20 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (4.25.3) Requirement already satisfied: pyarrow>=7.0 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (15.0.2) Requirement already satisfied: requests<3,>=2.27 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (2.31.0) Requirement already satisfied: rich<14,>=10.14.0 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (13.7.1) Requirement already satisfied: tenacity<9,>=8.1.0 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (8.2.3) Requirement already satisfied: toml<2,>=0.10.1 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (0.10.2) Requirement already satisfied: typing-extensions<5,>=4.3.0 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (4.9.0) Requirement already satisfied: gitpython!=3.1.19,<4,>=3.0.7 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (3.1.42) Requirement already satisfied: pydeck<1,>=0.8.0b4 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (0.8.1b0) Requirement already satisfied: tornado<7,>=6.0.3 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (6.3.3) Requirement already satisfied: watchdog>=2.1.5 in e:\anaconda3\envs\openai\lib\site-packages (from streamlit) (4.0.0) Requirement already satisfied: jinja2 in e:\anaconda3\envs\openai\lib\site-packages (from altair<6,>=4.0->streamlit) (3.1.3) Requirement already satisfied: jsonschema>=3.0 in e:\anaconda3\envs\openai\lib\site-packages (from altair<6,>=4.0->streamlit) (4.21.1) Requirement already satisfied: toolz in e:\anaconda3\envs\openai\lib\site-packages (from altair<6,>=4.0->streamlit) (0.12.1) Requirement already satisfied: colorama in e:\anaconda3\envs\openai\lib\site-packages (from click<9,>=7.0->streamlit) (0.4.6) Requirement already satisfied: gitdb<5,>=4.0.1 in e:\anaconda3\envs\openai\lib\site-packages (from gitpython!=3.1.19,<4,>=3.0.7->streamlit) (4.0.11) Requirement already satisfied: python-dateutil>=2.8.2 in e:\anaconda3\envs\openai\lib\site-packages (from pandas<3,>=1.3.0->streamlit) (2.8.2) Requirement already satisfied: pytz>=2020.1 in e:\anaconda3\envs\openai\lib\site-packages (from pandas<3,>=1.3.0->streamlit) (2024.1) Requirement already satisfied: tzdata>=2022.1 in e:\anaconda3\envs\openai\lib\site-packages (from pandas<3,>=1.3.0->streamlit) (2024.1) Requirement already satisfied: charset-normalizer<4,>=2 in e:\anaconda3\envs\openai\lib\site-packages (from requests<3,>=2.27->streamlit) (3.3.2) Requirement already satisfied: idna<4,>=2.5 in e:\anaconda3\envs\openai\lib\site-packages (from requests<3,>=2.27->streamlit) (3.6) Requirement already satisfied: urllib3<3,>=1.21.1 in e:\anaconda3\envs\openai\lib\site-packages (from requests<3,>=2.27->streamlit) (2.2.1) Requirement already satisfied: certifi>=2017.4.17 in e:\anaconda3\envs\openai\lib\site-packages (from requests<3,>=2.27->streamlit) (2024.2.2) Requirement already satisfied: markdown-it-py>=2.2.0 in e:\anaconda3\envs\openai\lib\site-packages (from rich<14,>=10.14.0->streamlit) (3.0.0) Requirement already satisfied: pygments<3.0.0,>=2.13.0 in e:\anaconda3\envs\openai\lib\site-packages (from rich<14,>=10.14.0->streamlit) (2.15.1) Requirement already satisfied: smmap<6,>=3.0.1 in e:\anaconda3\envs\openai\lib\site-packages (from gitdb<5,>=4.0.1->gitpython!=3.1.19,<4,>=3.0.7->streamlit) (5.0.1) Requirement already satisfied: MarkupSafe>=2.0 in e:\anaconda3\envs\openai\lib\site-packages (from jinja2->altair<6,>=4.0->streamlit) (2.1.5) Requirement already satisfied: attrs>=22.2.0 in e:\anaconda3\envs\openai\lib\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (23.2.0) Requirement already satisfied: importlib-resources>=1.4.0 in e:\anaconda3\envs\openai\lib\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (6.4.0) Requirement already satisfied: jsonschema-specifications>=2023.03.6 in e:\anaconda3\envs\openai\lib\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (2023.12.1) Requirement already satisfied: pkgutil-resolve-name>=1.3.10 in e:\anaconda3\envs\openai\lib\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (1.3.10) Requirement already satisfied: referencing>=0.28.4 in e:\anaconda3\envs\openai\lib\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (0.34.0) Requirement already satisfied: rpds-py>=0.7.1 in e:\anaconda3\envs\openai\lib\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (0.18.0) Requirement already satisfied: mdurl~=0.1 in e:\anaconda3\envs\openai\lib\site-packages (from markdown-it-py>=2.2.0->rich<14,>=10.14.0->streamlit) (0.1.2) Requirement already satisfied: six>=1.5 in e:\anaconda3\envs\openai\lib\site-packages (from python-dateutil>=2.8.2->pandas<3,>=1.3.0->streamlit) (1.16.0) Requirement already satisfied: zipp>=3.1.0 in e:\anaconda3\envs\openai\lib\site-packages (from importlib-resources>=1.4.0->jsonschema>=3.0->altair<6,>=4.0->streamlit) (3.17.0)
WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages)
#!pip install langchain
Requirement already satisfied: langchain in e:\anaconda3\envs\openai\lib\site-packages (0.1.13) Requirement already satisfied: PyYAML>=5.3 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (6.0.1) Requirement already satisfied: SQLAlchemy<3,>=1.4 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (2.0.29) Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (3.9.3) Requirement already satisfied: async-timeout<5.0.0,>=4.0.0 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (4.0.3) Requirement already satisfied: dataclasses-json<0.7,>=0.5.7 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (0.6.4) Requirement already satisfied: jsonpatch<2.0,>=1.33 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (1.33) Requirement already satisfied: langchain-community<0.1,>=0.0.29 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (0.0.29) Requirement already satisfied: langchain-core<0.2.0,>=0.1.33 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (0.1.36) Requirement already satisfied: langchain-text-splitters<0.1,>=0.0.1 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (0.0.1) Requirement already satisfied: langsmith<0.2.0,>=0.1.17 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (0.1.38) Requirement already satisfied: numpy<2,>=1 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (1.24.4) Requirement already satisfied: pydantic<3,>=1 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (2.6.4) Requirement already satisfied: requests<3,>=2 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (2.31.0) Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in e:\anaconda3\envs\openai\lib\site-packages (from langchain) (8.2.3) Requirement already satisfied: aiosignal>=1.1.2 in e:\anaconda3\envs\openai\lib\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.3.1) Requirement already satisfied: attrs>=17.3.0 in e:\anaconda3\envs\openai\lib\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (23.2.0) Requirement already satisfied: frozenlist>=1.1.1 in e:\anaconda3\envs\openai\lib\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.4.1) Requirement already satisfied: multidict<7.0,>=4.5 in e:\anaconda3\envs\openai\lib\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (6.0.5) Requirement already satisfied: yarl<2.0,>=1.0 in e:\anaconda3\envs\openai\lib\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.9.4) Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in e:\anaconda3\envs\openai\lib\site-packages (from dataclasses-json<0.7,>=0.5.7->langchain) (3.21.1) Requirement already satisfied: typing-inspect<1,>=0.4.0 in e:\anaconda3\envs\openai\lib\site-packages (from dataclasses-json<0.7,>=0.5.7->langchain) (0.9.0) Requirement already satisfied: jsonpointer>=1.9 in e:\anaconda3\envs\openai\lib\site-packages (from jsonpatch<2.0,>=1.33->langchain) (2.4) Requirement already satisfied: packaging<24.0,>=23.2 in e:\anaconda3\envs\openai\lib\site-packages (from langchain-core<0.2.0,>=0.1.33->langchain) (23.2) Requirement already satisfied: orjson<4.0.0,>=3.9.14 in e:\anaconda3\envs\openai\lib\site-packages (from langsmith<0.2.0,>=0.1.17->langchain) (3.10.0) Requirement already satisfied: annotated-types>=0.4.0 in e:\anaconda3\envs\openai\lib\site-packages (from pydantic<3,>=1->langchain) (0.6.0) Requirement already satisfied: pydantic-core==2.16.3 in e:\anaconda3\envs\openai\lib\site-packages (from pydantic<3,>=1->langchain) (2.16.3) Requirement already satisfied: typing-extensions>=4.6.1 in e:\anaconda3\envs\openai\lib\site-packages (from pydantic<3,>=1->langchain) (4.9.0) Requirement already satisfied: charset-normalizer<4,>=2 in e:\anaconda3\envs\openai\lib\site-packages (from requests<3,>=2->langchain) (3.3.2) Requirement already satisfied: idna<4,>=2.5 in e:\anaconda3\envs\openai\lib\site-packages (from requests<3,>=2->langchain) (3.6) Requirement already satisfied: urllib3<3,>=1.21.1 in e:\anaconda3\envs\openai\lib\site-packages (from requests<3,>=2->langchain) (2.2.1) Requirement already satisfied: certifi>=2017.4.17 in e:\anaconda3\envs\openai\lib\site-packages (from requests<3,>=2->langchain) (2024.2.2) Requirement already satisfied: greenlet!=0.4.17 in e:\anaconda3\envs\openai\lib\site-packages (from SQLAlchemy<3,>=1.4->langchain) (3.0.3) Requirement already satisfied: mypy-extensions>=0.3.0 in e:\anaconda3\envs\openai\lib\site-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.7,>=0.5.7->langchain) (1.0.0)
WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages)
#!pip install openai
WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages) WARNING: Ignoring invalid distribution -pype1 (c:\users\jyseo\appdata\roaming\python\python38\site-packages)
Requirement already satisfied: openai in e:\anaconda3\envs\openai\lib\site-packages (1.14.3) Requirement already satisfied: anyio<5,>=3.5.0 in e:\anaconda3\envs\openai\lib\site-packages (from openai) (4.3.0) Requirement already satisfied: distro<2,>=1.7.0 in e:\anaconda3\envs\openai\lib\site-packages (from openai) (1.9.0) Requirement already satisfied: httpx<1,>=0.23.0 in e:\anaconda3\envs\openai\lib\site-packages (from openai) (0.27.0) Requirement already satisfied: pydantic<3,>=1.9.0 in e:\anaconda3\envs\openai\lib\site-packages (from openai) (2.6.4) Requirement already satisfied: sniffio in e:\anaconda3\envs\openai\lib\site-packages (from openai) (1.3.1) Requirement already satisfied: tqdm>4 in e:\anaconda3\envs\openai\lib\site-packages (from openai) (4.66.2) Requirement already satisfied: typing-extensions<5,>=4.7 in e:\anaconda3\envs\openai\lib\site-packages (from openai) (4.9.0) Requirement already satisfied: idna>=2.8 in e:\anaconda3\envs\openai\lib\site-packages (from anyio<5,>=3.5.0->openai) (3.6) Requirement already satisfied: exceptiongroup>=1.0.2 in e:\anaconda3\envs\openai\lib\site-packages (from anyio<5,>=3.5.0->openai) (1.2.0) Requirement already satisfied: certifi in e:\anaconda3\envs\openai\lib\site-packages (from httpx<1,>=0.23.0->openai) (2024.2.2) Requirement already satisfied: httpcore==1.* in e:\anaconda3\envs\openai\lib\site-packages (from httpx<1,>=0.23.0->openai) (1.0.5) Requirement already satisfied: h11<0.15,>=0.13 in e:\anaconda3\envs\openai\lib\site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0) Requirement already satisfied: annotated-types>=0.4.0 in e:\anaconda3\envs\openai\lib\site-packages (from pydantic<3,>=1.9.0->openai) (0.6.0) Requirement already satisfied: pydantic-core==2.16.3 in e:\anaconda3\envs\openai\lib\site-packages (from pydantic<3,>=1.9.0->openai) (2.16.3) Requirement already satisfied: colorama in e:\anaconda3\envs\openai\lib\site-packages (from tqdm>4->openai) (0.4.6)
import streamlit as st
import os
os.environ["OPENAI_API_KEY"] = "sk-" #openai 키 입력
st.set_page_config(page_title="이메일 작성 서비스예요~", page_icon=":robot:")
st.header("이메일 작성기")
2024-03-30 18:48:37.050
Warning: to view this Streamlit app on a browser, run it with the following
command:
streamlit run e:\anaconda3\envs\openai\lib\site-packages\ipykernel_launcher.py [ARGUMENTS]
DeltaGenerator()
def getEmail():
input_text = st.text_area(label="메일 입력", label_visibility='collapsed',
placeholder="당신의 메일은...", key="input_text")
return input_text
input_text = getEmail()
# 이메일 변환 작업을 위한 템플릿 정의
query_template = """
메일을 작성해주세요.
아래는 이메일입니다:
이메일: {email}
"""
from langchain import PromptTemplate
# PromptTemplate 인스턴스 생성
prompt = PromptTemplate(
input_variables=["email"],
template=query_template,
)
from langchain.chat_models import ChatOpenAI
# 언어 모델을 호출합니다
def loadLanguageModel():
llm = ChatOpenAI(temperature=0.0,model_name='gpt-4')
return llm
# 예시 이메일을 표시
st.button("*예제를 보여주세요*", type='secondary', help="봇이 작성한 메일을 확인해보세요.")
st.markdown("### 봇이 작성한 메일은:")
if input_text:
llm = loadLanguageModel()
# PromptTemplate 및 언어 모델을 사용하여 이메일 형식을 지정
prompt_with_email = prompt.format(email=input_text)
formatted_email = llm.predict(prompt_with_email)
# 서식이 지정된 이메일 표시
st.write(formatted_email)