mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-31 20:19:43 +00:00
- `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)`
26 lines
656 B
Python
26 lines
656 B
Python
# flake8: noqa
|
|
"""Test Llama.cpp wrapper."""
|
|
import os
|
|
from urllib.request import urlretrieve
|
|
|
|
from langchain_community.llms import GPT4All
|
|
|
|
|
|
def _download_model() -> str:
|
|
"""Download model."""
|
|
model_url = "http://gpt4all.io/models/ggml-gpt4all-l13b-snoozy.bin"
|
|
local_filename = model_url.split("/")[-1]
|
|
|
|
if not os.path.exists(local_filename):
|
|
urlretrieve(model_url, local_filename)
|
|
|
|
return local_filename
|
|
|
|
|
|
def test_gpt4all_inference() -> None:
|
|
"""Test valid gpt4all inference."""
|
|
model_path = _download_model()
|
|
llm = GPT4All(model=model_path)
|
|
output = llm.invoke("Say foo:")
|
|
assert isinstance(output, str)
|