Moonshot은 기업 및 개인에게 LLM 서비스를 제공하는 중국 스타트업입니다.이 예제는 LangChain을 사용하여 채팅을 위한 Moonshot Inference와 상호 작용하는 방법을 설명합니다.
Copy
import os# Generate your api key from: https://platform.moonshot.cn/console/api-keysos.environ["MOONSHOT_API_KEY"] = "MOONSHOT_API_KEY"
Copy
from langchain_community.chat_models.moonshot import MoonshotChatfrom langchain.messages import HumanMessage, SystemMessage
Copy
chat = MoonshotChat()# or use a specific model# Available models: https://platform.moonshot.cn/docs# chat = MoonshotChat(model="moonshot-v1-128k")
Copy
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)