Skip to main content
이 노트북은 Upstage 채팅 모델을 시작하는 방법을 다룹니다.

설치

langchain-upstage 패키지를 설치합니다.
pip install -U langchain-upstage

환경 설정

다음 환경 변수를 설정해야 합니다:

사용법

import os

os.environ["UPSTAGE_API_KEY"] = "YOUR_API_KEY"
from langchain_core.prompts import ChatPromptTemplate
from langchain_upstage import ChatUpstage

chat = ChatUpstage()
# chat invoke 사용
chat.invoke("Hello, how are you?")
# chat stream 사용
for m in chat.stream("Hello, how are you?"):
    print(m)

체이닝

# 체인 사용
prompt = ChatPromptTemplate.from_messages(
    [
        ("system", "You are a helpful assistant that translates English to French."),
        ("human", "Translate this sentence from English to French. {english_text}."),
    ]
)
chain = prompt | chat

chain.invoke({"english_text": "Hello, how are you?"})

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I