langchain/libs/community/tests/integration_tests/llms/test_clarifai.py
ccurme 481d3855dc
patch: remove usage of llm, chat model __call__ (#20788)
- `llm(prompt)` -> `llm.invoke(prompt)`
- `llm(prompt=prompt` -> `llm.invoke(prompt)` (same with `messages=`)
- `llm(prompt, callbacks=callbacks)` -> `llm.invoke(prompt,
config={"callbacks": callbacks})`
- `llm(prompt, **kwargs)` -> `llm.invoke(prompt, **kwargs)`
2024-04-24 19:39:23 -04:00

30 lines
1.0 KiB
Python

"""Test Clarifai API wrapper.
In order to run this test, you need to have an account on Clarifai.
You can sign up for free at https://clarifai.com/signup.
pip install clarifai
You'll need to set env variable CLARIFAI_PAT_KEY to your personal access token key.
"""
from langchain_community.llms.clarifai import Clarifai
def test_clarifai_call() -> None:
"""Test valid call to clarifai."""
llm = Clarifai(
user_id="google-research",
app_id="summarization",
model_id="text-summarization-english-pegasus",
)
output = llm.invoke(
"A chain is a serial assembly of connected pieces, called links, \
typically made of metal, with an overall character similar to that\
of a rope in that it is flexible and curved in compression but \
linear, rigid, and load-bearing in tension. A chain may consist\
of two or more links."
)
assert isinstance(output, str)
assert llm._llm_type == "clarifai"
assert llm.model_id == "text-summarization-english-pegasus"