Copy
Ask AI
# Installing the langchain package needed to use the integration
%pip install -qU langchain-community
Copy
Ask AI
# Install the package
%pip install -qU aleph-alpha-client
Copy
Ask AI
# create a new token: https://docs.aleph-alpha.com/docs/account/#create-a-new-token
from getpass import getpass
ALEPH_ALPHA_API_KEY = getpass()
Copy
Ask AI
········
Copy
Ask AI
from langchain_community.llms import AlephAlpha
from langchain_core.prompts import PromptTemplate
Copy
Ask AI
template = """Q: {question}
A:"""
prompt = PromptTemplate.from_template(template)
Copy
Ask AI
llm = AlephAlpha(
model="luminous-extended",
maximum_tokens=20,
stop_sequences=["Q:"],
aleph_alpha_api_key=ALEPH_ALPHA_API_KEY,
)
Copy
Ask AI
llm_chain = prompt | llm
Copy
Ask AI
question = "What is AI?"
llm_chain.invoke({"question": question})
Copy
Ask AI
' Artificial Intelligence is the simulation of human intelligence processes by machines.\n\n'