langchain/libs/community/tests/integration_tests/llms/test_gooseai.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

29 lines
936 B
Python

"""Test GooseAI API wrapper."""
from langchain_community.llms.gooseai import GooseAI
def test_gooseai_call() -> None:
"""Test valid call to gooseai."""
llm = GooseAI(max_tokens=10)
output = llm.invoke("Say foo:")
assert isinstance(output, str)
def test_gooseai_call_fairseq() -> None:
"""Test valid call to gooseai with fairseq model."""
llm = GooseAI(model_name="fairseq-1-3b", max_tokens=10)
output = llm.invoke("Say foo:")
assert isinstance(output, str)
def test_gooseai_stop_valid() -> None:
"""Test gooseai stop logic on valid configuration."""
query = "write an ordered list of five items"
first_llm = GooseAI(stop="3", temperature=0)
first_output = first_llm.invoke(query)
second_llm = GooseAI(temperature=0)
second_output = second_llm.invoke(query, stop=["3"])
# Because it stops on new lines, shouldn't return anything
assert first_output == second_output