mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-14 15:16:21 +00:00
Signed-off-by: ChengZi <chen.zhang@zilliz.com> Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com> Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com> Co-authored-by: Dan O'Donovan <dan.odonovan@gmail.com> Co-authored-by: Tom Daniel Grande <tomdgrande@gmail.com> Co-authored-by: Grande <Tom.Daniel.Grande@statsbygg.no> Co-authored-by: Bagatur <baskaryan@gmail.com> Co-authored-by: ccurme <chester.curme@gmail.com> Co-authored-by: Harrison Chase <hw.chase.17@gmail.com> Co-authored-by: Tomaz Bratanic <bratanic.tomaz@gmail.com> Co-authored-by: ZhangShenao <15201440436@163.com> Co-authored-by: Friso H. Kingma <fhkingma@gmail.com> Co-authored-by: ChengZi <chen.zhang@zilliz.com> Co-authored-by: Nuno Campos <nuno@langchain.dev> Co-authored-by: Morgante Pell <morgantep@google.com>
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
from typing import List, Literal, Optional
|
|
|
|
import pytest
|
|
from pydantic import BaseModel, ValidationError
|
|
|
|
from langchain_community.chat_models import ChatOllama
|
|
|
|
|
|
def test_standard_params() -> None:
|
|
class ExpectedParams(BaseModel):
|
|
ls_provider: str
|
|
ls_model_name: str
|
|
ls_model_type: Literal["chat", "llm"]
|
|
ls_temperature: Optional[float]
|
|
ls_max_tokens: Optional[int] = None
|
|
ls_stop: Optional[List[str]] = None
|
|
|
|
model = ChatOllama(model="llama3")
|
|
ls_params = model._get_ls_params()
|
|
try:
|
|
ExpectedParams(**ls_params)
|
|
except ValidationError as e:
|
|
pytest.fail(f"Validation error: {e}")
|
|
assert ls_params["ls_model_name"] == "llama3"
|
|
|
|
# Test optional params
|
|
model = ChatOllama(num_predict=10, stop=["test"], temperature=0.33)
|
|
ls_params = model._get_ls_params()
|
|
try:
|
|
ExpectedParams(**ls_params)
|
|
except ValidationError as e:
|
|
pytest.fail(f"Validation error: {e}")
|
|
assert ls_params["ls_max_tokens"] == 10
|
|
assert ls_params["ls_stop"] == ["test"]
|
|
assert ls_params["ls_temperature"] == 0.33
|