跳到主要內容

Minimax

Minimax 是一家中國新創公司,為公司和個人提供自然語言處理模型。

本範例展示了如何使用 Langchain 與 Minimax 互動。

設定

要運行此筆記本,您需要一個Minimax 帳戶、一個API 金鑰和一個群組 ID

單個模型呼叫

from langchain_community.llms import Minimax
API 參考:Minimax
# Load the model
minimax = Minimax(minimax_api_key="YOUR_API_KEY", minimax_group_id="YOUR_GROUP_ID")
# Prompt the model
minimax("What is the difference between panda and bear?")

鏈式模型呼叫

# get api_key and group_id: https://api.minimax.chat/user-center/basic-information
# We need `MINIMAX_API_KEY` and `MINIMAX_GROUP_ID`

import os

os.environ["MINIMAX_API_KEY"] = "YOUR_API_KEY"
os.environ["MINIMAX_GROUP_ID"] = "YOUR_GROUP_ID"
from langchain.chains import LLMChain
from langchain_community.llms import Minimax
from langchain_core.prompts import PromptTemplate
template = """Question: {question}

Answer: Let's think step by step."""

prompt = PromptTemplate.from_template(template)
llm = Minimax()
llm_chain = LLMChain(prompt=prompt, llm=llm)
question = "What NBA team won the Championship in the year Jay Zhou was born?"

llm_chain.run(question)

此頁面是否有幫助?