Skip to main content
Moonshot은 기업 및 개인에게 LLM 서비스를 제공하는 중국 스타트업입니다. 이 예제는 LangChain을 사용하여 채팅을 위한 Moonshot Inference와 상호 작용하는 방법을 설명합니다.
import os

# Generate your api key from: https://platform.moonshot.cn/console/api-keys
os.environ["MOONSHOT_API_KEY"] = "MOONSHOT_API_KEY"
from langchain_community.chat_models.moonshot import MoonshotChat
from langchain.messages import HumanMessage, SystemMessage
chat = MoonshotChat()
# or use a specific model
# Available models: https://platform.moonshot.cn/docs
# chat = MoonshotChat(model="moonshot-v1-128k")
messages = [
    SystemMessage(
        content="You are a helpful assistant that translates English to French."
    ),
    HumanMessage(
        content="Translate this sentence from English to French. I love programming."
    ),
]

chat.invoke(messages)

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