mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-25 04:49:17 +00:00
BUG: more core fixes (#13665)
Fix some circular deps: - move PromptValue into top level module bc both PromptTemplates and OutputParsers import - move tracer context vars to `tracers.context` and import them in functions in `callbacks.manager` - add core import tests
This commit is contained in:
15
libs/core/tests/unit_tests/tracers/test_imports.py
Normal file
15
libs/core/tests/unit_tests/tracers/test_imports.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from langchain_core.tracers import __all__
|
||||
|
||||
EXPECTED_ALL = [
|
||||
"BaseTracer",
|
||||
"EvaluatorCallbackHandler",
|
||||
"LangChainTracer",
|
||||
"ConsoleCallbackHandler",
|
||||
"Run",
|
||||
"RunLog",
|
||||
"RunLogPatch",
|
||||
]
|
||||
|
||||
|
||||
def test_all_imports() -> None:
|
||||
assert set(__all__) == set(EXPECTED_ALL)
|
16
libs/core/tests/unit_tests/tracers/test_run_collector.py
Normal file
16
libs/core/tests/unit_tests/tracers/test_run_collector.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""Test the run collector."""
|
||||
|
||||
import uuid
|
||||
|
||||
from langchain_core.tracers.context import collect_runs
|
||||
from tests.unit_tests.fake.llm import FakeListLLM
|
||||
|
||||
|
||||
def test_collect_runs() -> None:
|
||||
llm = FakeListLLM(responses=["hello"])
|
||||
with collect_runs() as cb:
|
||||
llm.predict("hi")
|
||||
assert cb.traced_runs
|
||||
assert len(cb.traced_runs) == 1
|
||||
assert isinstance(cb.traced_runs[0].id, uuid.UUID)
|
||||
assert cb.traced_runs[0].inputs == {"prompts": ["hi"]}
|
Reference in New Issue
Block a user