langchain 0.2.5__py3-none-any.whl → 0.2.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of langchain might be problematic. Click here for more details.
- langchain/__init__.py +1 -0
- langchain/_api/module_import.py +2 -2
- langchain/agents/__init__.py +5 -4
- langchain/agents/agent.py +272 -50
- langchain/agents/agent_iterator.py +20 -0
- langchain/agents/agent_toolkits/__init__.py +1 -0
- langchain/agents/agent_toolkits/file_management/__init__.py +1 -0
- langchain/agents/agent_toolkits/playwright/__init__.py +1 -0
- langchain/agents/agent_toolkits/vectorstore/base.py +1 -0
- langchain/agents/agent_toolkits/vectorstore/toolkit.py +1 -0
- langchain/agents/agent_types.py +1 -0
- langchain/agents/chat/base.py +37 -1
- langchain/agents/chat/output_parser.py +14 -0
- langchain/agents/conversational/base.py +38 -6
- langchain/agents/conversational/output_parser.py +10 -0
- langchain/agents/conversational_chat/base.py +42 -3
- langchain/agents/format_scratchpad/__init__.py +1 -0
- langchain/agents/format_scratchpad/log.py +12 -1
- langchain/agents/format_scratchpad/log_to_messages.py +10 -1
- langchain/agents/format_scratchpad/openai_functions.py +10 -5
- langchain/agents/format_scratchpad/tools.py +11 -7
- langchain/agents/initialize.py +15 -7
- langchain/agents/json_chat/base.py +9 -3
- langchain/agents/loading.py +7 -0
- langchain/agents/mrkl/base.py +39 -10
- langchain/agents/mrkl/output_parser.py +12 -0
- langchain/agents/openai_assistant/base.py +37 -14
- langchain/agents/openai_functions_agent/agent_token_buffer_memory.py +32 -4
- langchain/agents/openai_functions_agent/base.py +61 -10
- langchain/agents/openai_functions_multi_agent/base.py +22 -7
- langchain/agents/openai_tools/base.py +3 -0
- langchain/agents/output_parsers/__init__.py +1 -0
- langchain/agents/react/base.py +1 -0
- langchain/agents/self_ask_with_search/base.py +1 -0
- langchain/agents/structured_chat/output_parser.py +3 -3
- langchain/agents/tool_calling_agent/base.py +13 -3
- langchain/agents/tools.py +3 -0
- langchain/agents/utils.py +9 -1
- langchain/base_language.py +1 -0
- langchain/callbacks/__init__.py +1 -0
- langchain/callbacks/base.py +1 -0
- langchain/callbacks/streaming_stdout.py +1 -0
- langchain/callbacks/streaming_stdout_final_only.py +1 -0
- langchain/callbacks/tracers/evaluation.py +1 -0
- langchain/chains/api/base.py +5 -2
- langchain/chains/base.py +1 -1
- langchain/chains/combine_documents/base.py +59 -0
- langchain/chains/combine_documents/map_reduce.py +4 -2
- langchain/chains/combine_documents/map_rerank.py +5 -3
- langchain/chains/combine_documents/refine.py +4 -2
- langchain/chains/combine_documents/stuff.py +1 -0
- langchain/chains/constitutional_ai/base.py +1 -0
- langchain/chains/constitutional_ai/models.py +1 -0
- langchain/chains/constitutional_ai/principles.py +1 -0
- langchain/chains/conversation/base.py +81 -1
- langchain/chains/conversational_retrieval/base.py +2 -1
- langchain/chains/elasticsearch_database/base.py +2 -1
- langchain/chains/hyde/base.py +1 -0
- langchain/chains/llm.py +4 -2
- langchain/chains/llm_checker/base.py +4 -3
- langchain/chains/llm_math/base.py +1 -0
- langchain/chains/loading.py +2 -1
- langchain/chains/mapreduce.py +1 -0
- langchain/chains/moderation.py +1 -1
- langchain/chains/natbot/base.py +1 -0
- langchain/chains/openai_functions/base.py +1 -0
- langchain/chains/openai_functions/extraction.py +6 -6
- langchain/chains/openai_tools/extraction.py +3 -3
- langchain/chains/qa_generation/base.py +47 -1
- langchain/chains/qa_with_sources/__init__.py +1 -0
- langchain/chains/qa_with_sources/loading.py +1 -0
- langchain/chains/qa_with_sources/vector_db.py +1 -1
- langchain/chains/query_constructor/base.py +1 -0
- langchain/chains/query_constructor/ir.py +1 -0
- langchain/chains/question_answering/chain.py +1 -0
- langchain/chains/retrieval_qa/base.py +3 -2
- langchain/chains/router/base.py +1 -0
- langchain/chains/router/llm_router.py +2 -1
- langchain/chains/router/multi_prompt.py +1 -0
- langchain/chains/router/multi_retrieval_qa.py +1 -0
- langchain/chains/sequential.py +2 -1
- langchain/chains/structured_output/base.py +12 -12
- langchain/chains/summarize/chain.py +1 -0
- langchain/chains/transform.py +4 -3
- langchain/chat_models/__init__.py +1 -0
- langchain/chat_models/base.py +2 -2
- langchain/docstore/__init__.py +1 -0
- langchain/document_loaders/__init__.py +1 -0
- langchain/document_transformers/__init__.py +1 -0
- langchain/embeddings/__init__.py +0 -1
- langchain/evaluation/__init__.py +2 -1
- langchain/evaluation/agents/__init__.py +1 -0
- langchain/evaluation/agents/trajectory_eval_prompt.py +1 -0
- langchain/evaluation/comparison/__init__.py +1 -0
- langchain/evaluation/comparison/eval_chain.py +1 -0
- langchain/evaluation/comparison/prompt.py +1 -0
- langchain/evaluation/embedding_distance/__init__.py +1 -0
- langchain/evaluation/embedding_distance/base.py +1 -0
- langchain/evaluation/loading.py +1 -0
- langchain/evaluation/parsing/base.py +1 -0
- langchain/evaluation/qa/__init__.py +1 -0
- langchain/evaluation/qa/eval_chain.py +1 -0
- langchain/evaluation/qa/generate_chain.py +1 -0
- langchain/evaluation/schema.py +1 -0
- langchain/evaluation/scoring/__init__.py +1 -0
- langchain/evaluation/scoring/eval_chain.py +1 -0
- langchain/evaluation/scoring/prompt.py +1 -0
- langchain/evaluation/string_distance/__init__.py +1 -0
- langchain/example_generator.py +1 -0
- langchain/formatting.py +1 -0
- langchain/globals/__init__.py +1 -0
- langchain/graphs/__init__.py +1 -0
- langchain/indexes/__init__.py +1 -0
- langchain/indexes/_sql_record_manager.py +9 -5
- langchain/indexes/graph.py +1 -0
- langchain/indexes/prompts/__init__.py +1 -0
- langchain/input.py +1 -0
- langchain/llms/__init__.py +1 -0
- langchain/load/__init__.py +1 -0
- langchain/memory/__init__.py +5 -0
- langchain/memory/vectorstore_token_buffer_memory.py +184 -0
- langchain/output_parsers/__init__.py +1 -0
- langchain/output_parsers/combining.py +1 -1
- langchain/output_parsers/enum.py +7 -3
- langchain/output_parsers/fix.py +57 -16
- langchain/output_parsers/pandas_dataframe.py +1 -1
- langchain/output_parsers/regex.py +1 -1
- langchain/output_parsers/regex_dict.py +1 -1
- langchain/output_parsers/retry.py +76 -29
- langchain/output_parsers/structured.py +3 -3
- langchain/output_parsers/yaml.py +4 -0
- langchain/prompts/__init__.py +1 -0
- langchain/prompts/example_selector/__init__.py +1 -0
- langchain/python.py +1 -0
- langchain/requests.py +1 -0
- langchain/retrievers/__init__.py +1 -0
- langchain/retrievers/document_compressors/chain_extract.py +1 -0
- langchain/retrievers/document_compressors/chain_filter.py +1 -0
- langchain/retrievers/ensemble.py +18 -3
- langchain/retrievers/multi_query.py +2 -1
- langchain/retrievers/re_phraser.py +2 -1
- langchain/retrievers/self_query/base.py +9 -8
- langchain/schema/__init__.py +1 -0
- langchain/schema/runnable/__init__.py +1 -0
- langchain/serpapi.py +1 -0
- langchain/smith/__init__.py +6 -5
- langchain/smith/evaluation/__init__.py +0 -1
- langchain/smith/evaluation/string_run_evaluator.py +1 -0
- langchain/sql_database.py +1 -0
- langchain/storage/__init__.py +1 -0
- langchain/storage/_lc_store.py +1 -0
- langchain/storage/in_memory.py +1 -0
- langchain/text_splitter.py +1 -0
- langchain/tools/__init__.py +1 -0
- langchain/tools/amadeus/__init__.py +1 -0
- langchain/tools/azure_cognitive_services/__init__.py +1 -0
- langchain/tools/bing_search/__init__.py +1 -0
- langchain/tools/dataforseo_api_search/__init__.py +1 -0
- langchain/tools/ddg_search/__init__.py +1 -0
- langchain/tools/edenai/__init__.py +1 -0
- langchain/tools/eleven_labs/__init__.py +1 -0
- langchain/tools/file_management/__init__.py +1 -0
- langchain/tools/github/__init__.py +1 -1
- langchain/tools/gitlab/__init__.py +1 -1
- langchain/tools/gmail/__init__.py +1 -0
- langchain/tools/golden_query/__init__.py +1 -0
- langchain/tools/google_cloud/__init__.py +1 -0
- langchain/tools/google_finance/__init__.py +1 -0
- langchain/tools/google_jobs/__init__.py +1 -0
- langchain/tools/google_lens/__init__.py +1 -0
- langchain/tools/google_places/__init__.py +1 -0
- langchain/tools/google_scholar/__init__.py +1 -0
- langchain/tools/google_search/__init__.py +1 -0
- langchain/tools/google_trends/__init__.py +1 -0
- langchain/tools/human/__init__.py +1 -0
- langchain/tools/memorize/__init__.py +1 -0
- langchain/tools/metaphor_search/__init__.py +1 -0
- langchain/tools/multion/__init__.py +1 -0
- langchain/tools/office365/__init__.py +1 -0
- langchain/tools/openapi/utils/openapi_utils.py +1 -0
- langchain/tools/openweathermap/__init__.py +1 -0
- langchain/tools/playwright/__init__.py +1 -0
- langchain/tools/shell/__init__.py +1 -0
- langchain/tools/slack/__init__.py +1 -0
- langchain/tools/sql_database/prompt.py +1 -0
- langchain/tools/steamship_image_generation/__init__.py +1 -0
- langchain/tools/tavily_search/__init__.py +1 -0
- langchain/tools/wolfram_alpha/__init__.py +1 -0
- langchain/tools/zapier/__init__.py +1 -0
- langchain/utilities/__init__.py +1 -0
- langchain/utilities/python.py +1 -0
- langchain/vectorstores/__init__.py +1 -0
- {langchain-0.2.5.dist-info → langchain-0.2.7.dist-info}/METADATA +3 -4
- {langchain-0.2.5.dist-info → langchain-0.2.7.dist-info}/RECORD +197 -196
- {langchain-0.2.5.dist-info → langchain-0.2.7.dist-info}/LICENSE +0 -0
- {langchain-0.2.5.dist-info → langchain-0.2.7.dist-info}/WHEEL +0 -0
- {langchain-0.2.5.dist-info → langchain-0.2.7.dist-info}/entry_points.txt +0 -0
|
@@ -61,7 +61,7 @@ class VectorDBQAWithSourcesChain(BaseQAWithSourcesChain):
|
|
|
61
61
|
) -> List[Document]:
|
|
62
62
|
raise NotImplementedError("VectorDBQAWithSourcesChain does not support async")
|
|
63
63
|
|
|
64
|
-
@root_validator()
|
|
64
|
+
@root_validator(pre=True)
|
|
65
65
|
def raise_deprecation(cls, values: Dict) -> Dict:
|
|
66
66
|
warnings.warn(
|
|
67
67
|
"`VectorDBQAWithSourcesChain` is deprecated - "
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Chain for question-answering against a vector database."""
|
|
2
|
+
|
|
2
3
|
from __future__ import annotations
|
|
3
4
|
|
|
4
5
|
import inspect
|
|
@@ -284,7 +285,7 @@ class VectorDBQA(BaseRetrievalQA):
|
|
|
284
285
|
search_kwargs: Dict[str, Any] = Field(default_factory=dict)
|
|
285
286
|
"""Extra search args."""
|
|
286
287
|
|
|
287
|
-
@root_validator()
|
|
288
|
+
@root_validator(pre=True)
|
|
288
289
|
def raise_deprecation(cls, values: Dict) -> Dict:
|
|
289
290
|
warnings.warn(
|
|
290
291
|
"`VectorDBQA` is deprecated - "
|
|
@@ -292,7 +293,7 @@ class VectorDBQA(BaseRetrievalQA):
|
|
|
292
293
|
)
|
|
293
294
|
return values
|
|
294
295
|
|
|
295
|
-
@root_validator()
|
|
296
|
+
@root_validator(pre=True)
|
|
296
297
|
def validate_search_type(cls, values: Dict) -> Dict:
|
|
297
298
|
"""Validate search type."""
|
|
298
299
|
if "search_type" in values:
|
langchain/chains/router/base.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Base classes for LLM-powered router chains."""
|
|
2
|
+
|
|
2
3
|
from __future__ import annotations
|
|
3
4
|
|
|
4
5
|
from typing import Any, Dict, List, Optional, Type, cast
|
|
@@ -24,7 +25,7 @@ class LLMRouterChain(RouterChain):
|
|
|
24
25
|
llm_chain: LLMChain
|
|
25
26
|
"""LLM chain used to perform routing"""
|
|
26
27
|
|
|
27
|
-
@root_validator()
|
|
28
|
+
@root_validator(pre=False, skip_on_failure=True)
|
|
28
29
|
def validate_prompt(cls, values: dict) -> dict:
|
|
29
30
|
prompt = values["llm_chain"].prompt
|
|
30
31
|
if prompt.output_parser is None:
|
langchain/chains/sequential.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Chain pipeline where the outputs of one step feed directly into next."""
|
|
2
|
+
|
|
2
3
|
from typing import Any, Dict, List, Optional
|
|
3
4
|
|
|
4
5
|
from langchain_core.callbacks import (
|
|
@@ -152,7 +153,7 @@ class SimpleSequentialChain(Chain):
|
|
|
152
153
|
"""
|
|
153
154
|
return [self.output_key]
|
|
154
155
|
|
|
155
|
-
@root_validator()
|
|
156
|
+
@root_validator(pre=False, skip_on_failure=True)
|
|
156
157
|
def validate_chains(cls, values: Dict) -> Dict:
|
|
157
158
|
"""Validate that chains are all single input/output."""
|
|
158
159
|
for chain in values["chains"]:
|
|
@@ -32,13 +32,13 @@ from langchain_core.utils.function_calling import (
|
|
|
32
32
|
"LangChain has introduced a method called `with_structured_output` that "
|
|
33
33
|
"is available on ChatModels capable of tool calling. "
|
|
34
34
|
"You can read more about the method here: "
|
|
35
|
-
"https://python.langchain.com/docs/modules/model_io/chat/structured_output
|
|
35
|
+
"<https://python.langchain.com/docs/modules/model_io/chat/structured_output/>. "
|
|
36
36
|
"Please follow our extraction use case documentation for more guidelines "
|
|
37
37
|
"on how to do information extraction with LLMs. "
|
|
38
|
-
"https://python.langchain.com/docs/use_cases/extraction
|
|
38
|
+
"<https://python.langchain.com/docs/use_cases/extraction/>. "
|
|
39
39
|
"If you notice other issues, please provide "
|
|
40
40
|
"feedback here: "
|
|
41
|
-
"https://github.com/langchain-ai/langchain/discussions/18154"
|
|
41
|
+
"<https://github.com/langchain-ai/langchain/discussions/18154>"
|
|
42
42
|
),
|
|
43
43
|
removal="0.3.0",
|
|
44
44
|
alternative=(
|
|
@@ -150,13 +150,13 @@ def create_openai_fn_runnable(
|
|
|
150
150
|
"LangChain has introduced a method called `with_structured_output` that "
|
|
151
151
|
"is available on ChatModels capable of tool calling. "
|
|
152
152
|
"You can read more about the method here: "
|
|
153
|
-
"https://python.langchain.com/docs/modules/model_io/chat/structured_output
|
|
153
|
+
"<https://python.langchain.com/docs/modules/model_io/chat/structured_output/>."
|
|
154
154
|
"Please follow our extraction use case documentation for more guidelines "
|
|
155
155
|
"on how to do information extraction with LLMs. "
|
|
156
|
-
"https://python.langchain.com/docs/use_cases/extraction
|
|
156
|
+
"<https://python.langchain.com/docs/use_cases/extraction/>. "
|
|
157
157
|
"If you notice other issues, please provide "
|
|
158
158
|
"feedback here: "
|
|
159
|
-
"https://github.com/langchain-ai/langchain/discussions/18154"
|
|
159
|
+
"<https://github.com/langchain-ai/langchain/discussions/18154>"
|
|
160
160
|
),
|
|
161
161
|
removal="0.3.0",
|
|
162
162
|
alternative=(
|
|
@@ -466,9 +466,9 @@ def _get_openai_tool_output_parser(
|
|
|
466
466
|
first_tool_only: bool = False,
|
|
467
467
|
) -> Union[BaseOutputParser, BaseGenerationOutputParser]:
|
|
468
468
|
if isinstance(tool, type) and issubclass(tool, BaseModel):
|
|
469
|
-
output_parser: Union[
|
|
470
|
-
|
|
471
|
-
|
|
469
|
+
output_parser: Union[BaseOutputParser, BaseGenerationOutputParser] = (
|
|
470
|
+
PydanticToolsParser(tools=[tool], first_tool_only=first_tool_only)
|
|
471
|
+
)
|
|
472
472
|
else:
|
|
473
473
|
key_name = convert_to_openai_tool(tool)["function"]["name"]
|
|
474
474
|
output_parser = JsonOutputKeyToolsParser(
|
|
@@ -500,9 +500,9 @@ def get_openai_output_parser(
|
|
|
500
500
|
}
|
|
501
501
|
else:
|
|
502
502
|
pydantic_schema = functions[0]
|
|
503
|
-
output_parser: Union[
|
|
504
|
-
|
|
505
|
-
|
|
503
|
+
output_parser: Union[BaseOutputParser, BaseGenerationOutputParser] = (
|
|
504
|
+
PydanticOutputFunctionsParser(pydantic_schema=pydantic_schema)
|
|
505
|
+
)
|
|
506
506
|
else:
|
|
507
507
|
output_parser = JsonOutputFunctionsParser(args_only=len(functions) <= 1)
|
|
508
508
|
return output_parser
|
langchain/chains/transform.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Chain that runs an arbitrary python function."""
|
|
2
|
+
|
|
2
3
|
import functools
|
|
3
4
|
import logging
|
|
4
5
|
from typing import Any, Awaitable, Callable, Dict, List, Optional
|
|
@@ -31,9 +32,9 @@ class TransformChain(Chain):
|
|
|
31
32
|
"""The keys returned by the transform's output dictionary."""
|
|
32
33
|
transform_cb: Callable[[Dict[str, str]], Dict[str, str]] = Field(alias="transform")
|
|
33
34
|
"""The transform function."""
|
|
34
|
-
atransform_cb: Optional[
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
atransform_cb: Optional[Callable[[Dict[str, Any]], Awaitable[Dict[str, Any]]]] = (
|
|
36
|
+
Field(None, alias="atransform")
|
|
37
|
+
)
|
|
37
38
|
"""The async coroutine transform function."""
|
|
38
39
|
|
|
39
40
|
@staticmethod
|
langchain/chat_models/base.py
CHANGED
|
@@ -94,7 +94,7 @@ def init_chat_model(
|
|
|
94
94
|
_check_pkg("langchain_anthropic")
|
|
95
95
|
from langchain_anthropic import ChatAnthropic
|
|
96
96
|
|
|
97
|
-
return ChatAnthropic(model=model, **kwargs)
|
|
97
|
+
return ChatAnthropic(model=model, **kwargs) # type: ignore[call-arg]
|
|
98
98
|
elif model_provider == "azure_openai":
|
|
99
99
|
_check_pkg("langchain_openai")
|
|
100
100
|
from langchain_openai import AzureChatOpenAI
|
|
@@ -134,7 +134,7 @@ def init_chat_model(
|
|
|
134
134
|
_check_pkg("langchain_mistralai")
|
|
135
135
|
from langchain_mistralai import ChatMistralAI
|
|
136
136
|
|
|
137
|
-
return ChatMistralAI(model=model, **kwargs)
|
|
137
|
+
return ChatMistralAI(model=model, **kwargs) # type: ignore[call-arg]
|
|
138
138
|
elif model_provider == "huggingface":
|
|
139
139
|
_check_pkg("langchain_huggingface")
|
|
140
140
|
from langchain_huggingface import ChatHuggingFace
|
langchain/docstore/__init__.py
CHANGED
langchain/embeddings/__init__.py
CHANGED
langchain/evaluation/__init__.py
CHANGED
|
@@ -38,7 +38,7 @@ name of the dataset to load.
|
|
|
38
38
|
- Comparing the output of two models: :class:`PairwiseStringEvalChain <langchain.evaluation.comparison.eval_chain.PairwiseStringEvalChain>` or :class:`LabeledPairwiseStringEvalChain <langchain.evaluation.comparison.eval_chain.LabeledPairwiseStringEvalChain>` when there is additionally a reference label.
|
|
39
39
|
- Judging the efficacy of an agent's tool usage: :class:`TrajectoryEvalChain <langchain.evaluation.agents.trajectory_eval_chain.TrajectoryEvalChain>`
|
|
40
40
|
- Checking whether an output complies with a set of criteria: :class:`CriteriaEvalChain <langchain.evaluation.criteria.eval_chain.CriteriaEvalChain>` or :class:`LabeledCriteriaEvalChain <langchain.evaluation.criteria.eval_chain.LabeledCriteriaEvalChain>` when there is additionally a reference label.
|
|
41
|
-
- Computing semantic difference between a prediction and reference: :class:`EmbeddingDistanceEvalChain <langchain.evaluation.embedding_distance.base.EmbeddingDistanceEvalChain>` or between two predictions: :class:`PairwiseEmbeddingDistanceEvalChain <langchain.evaluation.embedding_distance.base.PairwiseEmbeddingDistanceEvalChain>`
|
|
41
|
+
- Computing semantic difference between a prediction and reference: :class:`EmbeddingDistanceEvalChain <langchain.evaluation.embedding_distance.base.EmbeddingDistanceEvalChain>` or between two predictions: :class:`PairwiseEmbeddingDistanceEvalChain <langchain.evaluation.embedding_distance.base.PairwiseEmbeddingDistanceEvalChain>`
|
|
42
42
|
- Measuring the string distance between a prediction and reference :class:`StringDistanceEvalChain <langchain.evaluation.string_distance.base.StringDistanceEvalChain>` or between two predictions :class:`PairwiseStringDistanceEvalChain <langchain.evaluation.string_distance.base.PairwiseStringDistanceEvalChain>`
|
|
43
43
|
|
|
44
44
|
**Low-level API**
|
|
@@ -52,6 +52,7 @@ These evaluators implement one of the following interfaces:
|
|
|
52
52
|
These interfaces enable easier composability and usage within a higher level evaluation framework.
|
|
53
53
|
|
|
54
54
|
""" # noqa: E501
|
|
55
|
+
|
|
55
56
|
from langchain.evaluation.agents import TrajectoryEvalChain
|
|
56
57
|
from langchain.evaluation.comparison import (
|
|
57
58
|
LabeledPairwiseStringEvalChain,
|
|
@@ -4,6 +4,7 @@ This prompt is used to compare two responses and evaluate which one best follows
|
|
|
4
4
|
and answers the question. The prompt is based on the paper from
|
|
5
5
|
Zheng, et. al. https://arxiv.org/abs/2306.05685
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
# flake8: noqa
|
|
8
9
|
from langchain_core.prompts.chat import ChatPromptTemplate
|
|
9
10
|
|
langchain/evaluation/loading.py
CHANGED
langchain/evaluation/schema.py
CHANGED
|
@@ -4,6 +4,7 @@ This prompt is used to score the responses and evaluate how it follows the instr
|
|
|
4
4
|
and answers the question. The prompt is based on the paper from
|
|
5
5
|
Zheng, et. al. https://arxiv.org/abs/2306.05685
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
# flake8: noqa
|
|
8
9
|
from langchain_core.prompts.chat import ChatPromptTemplate
|
|
9
10
|
|
langchain/example_generator.py
CHANGED
langchain/formatting.py
CHANGED
langchain/globals/__init__.py
CHANGED
langchain/graphs/__init__.py
CHANGED
langchain/indexes/__init__.py
CHANGED
|
@@ -11,6 +11,7 @@ Importantly, Index keeps on working even if the content being written is derived
|
|
|
11
11
|
via a set of transformations from some source content (e.g., indexing children
|
|
12
12
|
documents that were derived from parent documents by chunking.)
|
|
13
13
|
"""
|
|
14
|
+
|
|
14
15
|
from typing import TYPE_CHECKING, Any
|
|
15
16
|
|
|
16
17
|
from langchain_core.indexing.api import IndexingResult, aindex, index
|
|
@@ -13,6 +13,7 @@ allow it to work with a variety of SQL as a backend.
|
|
|
13
13
|
* Keys can be listed based on the updated at field.
|
|
14
14
|
* Keys can be deleted.
|
|
15
15
|
"""
|
|
16
|
+
|
|
16
17
|
import contextlib
|
|
17
18
|
import decimal
|
|
18
19
|
import uuid
|
|
@@ -20,9 +21,7 @@ from typing import Any, AsyncGenerator, Dict, Generator, List, Optional, Sequenc
|
|
|
20
21
|
|
|
21
22
|
from langchain_core.indexing import RecordManager
|
|
22
23
|
from sqlalchemy import (
|
|
23
|
-
URL,
|
|
24
24
|
Column,
|
|
25
|
-
Engine,
|
|
26
25
|
Float,
|
|
27
26
|
Index,
|
|
28
27
|
String,
|
|
@@ -33,14 +32,19 @@ from sqlalchemy import (
|
|
|
33
32
|
select,
|
|
34
33
|
text,
|
|
35
34
|
)
|
|
35
|
+
from sqlalchemy.engine import URL, Engine
|
|
36
36
|
from sqlalchemy.ext.asyncio import (
|
|
37
37
|
AsyncEngine,
|
|
38
38
|
AsyncSession,
|
|
39
|
-
async_sessionmaker,
|
|
40
39
|
create_async_engine,
|
|
41
40
|
)
|
|
42
|
-
from sqlalchemy.
|
|
43
|
-
|
|
41
|
+
from sqlalchemy.orm import Query, Session, declarative_base, sessionmaker
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
from sqlalchemy.ext.asyncio import async_sessionmaker
|
|
45
|
+
except ImportError:
|
|
46
|
+
# dummy for sqlalchemy < 2
|
|
47
|
+
async_sessionmaker = type("async_sessionmaker", (type,), {}) # type: ignore
|
|
44
48
|
|
|
45
49
|
Base = declarative_base()
|
|
46
50
|
|
langchain/indexes/graph.py
CHANGED
langchain/input.py
CHANGED
langchain/llms/__init__.py
CHANGED
langchain/load/__init__.py
CHANGED
langchain/memory/__init__.py
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
AIMessage, BaseMessage, HumanMessage
|
|
28
28
|
""" # noqa: E501
|
|
29
|
+
|
|
29
30
|
from typing import TYPE_CHECKING, Any
|
|
30
31
|
|
|
31
32
|
from langchain._api import create_importer
|
|
@@ -48,6 +49,9 @@ from langchain.memory.summary import ConversationSummaryMemory
|
|
|
48
49
|
from langchain.memory.summary_buffer import ConversationSummaryBufferMemory
|
|
49
50
|
from langchain.memory.token_buffer import ConversationTokenBufferMemory
|
|
50
51
|
from langchain.memory.vectorstore import VectorStoreRetrieverMemory
|
|
52
|
+
from langchain.memory.vectorstore_token_buffer_memory import (
|
|
53
|
+
ConversationVectorStoreTokenBufferMemory, # avoid circular import
|
|
54
|
+
)
|
|
51
55
|
|
|
52
56
|
if TYPE_CHECKING:
|
|
53
57
|
from langchain_community.chat_message_histories import (
|
|
@@ -122,6 +126,7 @@ __all__ = [
|
|
|
122
126
|
"ConversationSummaryBufferMemory",
|
|
123
127
|
"ConversationSummaryMemory",
|
|
124
128
|
"ConversationTokenBufferMemory",
|
|
129
|
+
"ConversationVectorStoreTokenBufferMemory",
|
|
125
130
|
"CosmosDBChatMessageHistory",
|
|
126
131
|
"DynamoDBChatMessageHistory",
|
|
127
132
|
"ElasticsearchChatMessageHistory",
|