test_base.py — langchain Source File
Architecture documentation for test_base.py, a python file in the langchain codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 204cc001_68a7_581b_cd96_8944220aaf5d["test_base.py"] 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c["os"] 204cc001_68a7_581b_cd96_8944220aaf5d --> 9e98f0a7_ec6e_708f_4f1b_e9428b316e1c 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] 204cc001_68a7_581b_cd96_8944220aaf5d --> 120e2591_3e15_b895_72b6_cb26195e40a6 ac2a9b92_4484_491e_1b48_ec85e71e1d58["langchain_core.outputs"] 204cc001_68a7_581b_cd96_8944220aaf5d --> ac2a9b92_4484_491e_1b48_ec85e71e1d58 0b28cff6_d823_1571_d2bb_ec61508cc89c["langchain_openai"] 204cc001_68a7_581b_cd96_8944220aaf5d --> 0b28cff6_d823_1571_d2bb_ec61508cc89c 4271a109_76ed_f75d_f4f5_19af386bcf65["langchain_openai.llms.base"] 204cc001_68a7_581b_cd96_8944220aaf5d --> 4271a109_76ed_f75d_f4f5_19af386bcf65 style 204cc001_68a7_581b_cd96_8944220aaf5d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import os
import pytest
from langchain_core.outputs import GenerationChunk
from langchain_openai import OpenAI
from langchain_openai.llms.base import _stream_response_to_generation_chunk
os.environ["OPENAI_API_KEY"] = "foo"
def test_openai_model_param() -> None:
llm = OpenAI(model="foo")
assert llm.model_name == "foo"
llm = OpenAI(model_name="foo") # type: ignore[call-arg]
assert llm.model_name == "foo"
# Test standard tracing params
ls_params = llm._get_ls_params()
assert ls_params == {
"ls_provider": "openai",
"ls_model_type": "llm",
"ls_model_name": "foo",
"ls_temperature": 0.7,
"ls_max_tokens": 256,
}
ls_params = llm._get_ls_params(model="bar")
assert ls_params["ls_model_name"] == "bar"
def test_openai_model_kwargs() -> None:
llm = OpenAI(model_kwargs={"foo": "bar"})
assert llm.model_kwargs == {"foo": "bar"}
def test_openai_fields_in_model_kwargs() -> None:
"""Test that for backwards compatibility fields can be passed in as model_kwargs."""
llm = OpenAI(model_kwargs={"model_name": "foo"})
assert llm.model_name == "foo"
llm = OpenAI(model_kwargs={"model": "foo"})
assert llm.model_name == "foo"
def test_openai_incorrect_field() -> None:
with pytest.warns(match="not default parameter"):
llm = OpenAI(foo="bar") # type: ignore[call-arg]
assert llm.model_kwargs == {"foo": "bar"}
@pytest.fixture
def mock_completion() -> dict:
return {
"id": "cmpl-3evkmQda5Hu7fcZavknQda3SQ",
"object": "text_completion",
"created": 1689989000,
"model": "text-davinci-003",
"choices": [
{"text": "Bar Baz", "index": 0, "logprobs": None, "finish_reason": "length"}
],
// ... (61 more lines)
Domain
Subdomains
Functions
Dependencies
- langchain_core.outputs
- langchain_openai
- langchain_openai.llms.base
- os
- pytest
Source
Frequently Asked Questions
What does test_base.py do?
test_base.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_base.py?
test_base.py defines 9 function(s): mock_completion, test_custom_token_counting, test_generate_streaming_multiple_prompts_error, test_get_token_ids, test_openai_fields_in_model_kwargs, test_openai_incorrect_field, test_openai_model_kwargs, test_openai_model_param, test_stream_response_to_generation_chunk.
What does test_base.py depend on?
test_base.py imports 5 module(s): langchain_core.outputs, langchain_openai, langchain_openai.llms.base, os, pytest.
Where is test_base.py in the architecture?
test_base.py is located at libs/partners/openai/tests/unit_tests/llms/test_base.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/openai/tests/unit_tests/llms).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free