跳到主要内容
Luminous 系列是大型语言模型家族。 本示例介绍了如何使用 LangChain 与 Aleph Alpha 模型进行交互。
# Installing the langchain package needed to use the integration
pip install -qU langchain-community
# Install the package
pip install -qU  aleph-alpha-client
# create a new token: https://docs.aleph-alpha.com/docs/account/#create-a-new-token

from getpass import getpass

ALEPH_ALPHA_API_KEY = getpass()
········
from langchain_community.llms import AlephAlpha
from langchain_core.prompts import PromptTemplate
template = """Q: {question}

A:"""

prompt = PromptTemplate.from_template(template)
llm = AlephAlpha(
    model="luminous-extended",
    maximum_tokens=20,
    stop_sequences=["Q:"],
    aleph_alpha_api_key=ALEPH_ALPHA_API_KEY,
)
llm_chain = prompt | llm
question = "What is AI?"

llm_chain.invoke({"question": question})
' Artificial Intelligence is the simulation of human intelligence processes by machines.\n\n'

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.