mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
Add tags to all callback handler methods (#7073)
<!-- Thank you for contributing to LangChain! Replace this comment with: - Description: a description of the change, - Issue: the issue # it fixes (if applicable), - Dependencies: any dependencies required for this change, - Tag maintainer: for a quicker response, tag the relevant maintainer (see below), - Twitter handle: we announce bigger features on Twitter. If your PR gets announced and you'd like a mention, we'll gladly shout you out! If you're adding a new integration, please include: 1. a test for the integration, preferably unit tests that do not rely on network access, 2. an example notebook showing its use. Maintainer responsibilities: - General / Misc / if you don't know who to tag: @dev2049 - DataLoaders / VectorStores / Retrievers: @rlancemartin, @eyurtsev - Models / Prompts: @hwchase17, @dev2049 - Memory: @hwchase17 - Agents / Tools / Toolkits: @vowelparrot - Tracing / Callbacks: @agola11 - Async: @agola11 If no one reviews your PR within a few days, feel free to @-mention the same people again. See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md -->
This commit is contained in:
parent
d0c7f7c317
commit
98dbea6310
@ -291,6 +291,7 @@ class AsyncCallbackHandler(BaseCallbackHandler):
|
|||||||
*,
|
*,
|
||||||
run_id: UUID,
|
run_id: UUID,
|
||||||
parent_run_id: Optional[UUID] = None,
|
parent_run_id: Optional[UUID] = None,
|
||||||
|
tags: Optional[List[str]] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run on new LLM token. Only available when streaming is enabled."""
|
"""Run on new LLM token. Only available when streaming is enabled."""
|
||||||
@ -301,6 +302,7 @@ class AsyncCallbackHandler(BaseCallbackHandler):
|
|||||||
*,
|
*,
|
||||||
run_id: UUID,
|
run_id: UUID,
|
||||||
parent_run_id: Optional[UUID] = None,
|
parent_run_id: Optional[UUID] = None,
|
||||||
|
tags: Optional[List[str]] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run when LLM ends running."""
|
"""Run when LLM ends running."""
|
||||||
@ -311,6 +313,7 @@ class AsyncCallbackHandler(BaseCallbackHandler):
|
|||||||
*,
|
*,
|
||||||
run_id: UUID,
|
run_id: UUID,
|
||||||
parent_run_id: Optional[UUID] = None,
|
parent_run_id: Optional[UUID] = None,
|
||||||
|
tags: Optional[List[str]] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run when LLM errors."""
|
"""Run when LLM errors."""
|
||||||
@ -333,6 +336,7 @@ class AsyncCallbackHandler(BaseCallbackHandler):
|
|||||||
*,
|
*,
|
||||||
run_id: UUID,
|
run_id: UUID,
|
||||||
parent_run_id: Optional[UUID] = None,
|
parent_run_id: Optional[UUID] = None,
|
||||||
|
tags: Optional[List[str]] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run when chain ends running."""
|
"""Run when chain ends running."""
|
||||||
@ -343,6 +347,7 @@ class AsyncCallbackHandler(BaseCallbackHandler):
|
|||||||
*,
|
*,
|
||||||
run_id: UUID,
|
run_id: UUID,
|
||||||
parent_run_id: Optional[UUID] = None,
|
parent_run_id: Optional[UUID] = None,
|
||||||
|
tags: Optional[List[str]] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run when chain errors."""
|
"""Run when chain errors."""
|
||||||
@ -365,6 +370,7 @@ class AsyncCallbackHandler(BaseCallbackHandler):
|
|||||||
*,
|
*,
|
||||||
run_id: UUID,
|
run_id: UUID,
|
||||||
parent_run_id: Optional[UUID] = None,
|
parent_run_id: Optional[UUID] = None,
|
||||||
|
tags: Optional[List[str]] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run when tool ends running."""
|
"""Run when tool ends running."""
|
||||||
@ -375,6 +381,7 @@ class AsyncCallbackHandler(BaseCallbackHandler):
|
|||||||
*,
|
*,
|
||||||
run_id: UUID,
|
run_id: UUID,
|
||||||
parent_run_id: Optional[UUID] = None,
|
parent_run_id: Optional[UUID] = None,
|
||||||
|
tags: Optional[List[str]] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run when tool errors."""
|
"""Run when tool errors."""
|
||||||
@ -385,6 +392,7 @@ class AsyncCallbackHandler(BaseCallbackHandler):
|
|||||||
*,
|
*,
|
||||||
run_id: UUID,
|
run_id: UUID,
|
||||||
parent_run_id: Optional[UUID] = None,
|
parent_run_id: Optional[UUID] = None,
|
||||||
|
tags: Optional[List[str]] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run on arbitrary text."""
|
"""Run on arbitrary text."""
|
||||||
@ -395,6 +403,7 @@ class AsyncCallbackHandler(BaseCallbackHandler):
|
|||||||
*,
|
*,
|
||||||
run_id: UUID,
|
run_id: UUID,
|
||||||
parent_run_id: Optional[UUID] = None,
|
parent_run_id: Optional[UUID] = None,
|
||||||
|
tags: Optional[List[str]] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run on agent action."""
|
"""Run on agent action."""
|
||||||
@ -405,6 +414,7 @@ class AsyncCallbackHandler(BaseCallbackHandler):
|
|||||||
*,
|
*,
|
||||||
run_id: UUID,
|
run_id: UUID,
|
||||||
parent_run_id: Optional[UUID] = None,
|
parent_run_id: Optional[UUID] = None,
|
||||||
|
tags: Optional[List[str]] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run on agent end."""
|
"""Run on agent end."""
|
||||||
@ -415,6 +425,7 @@ class AsyncCallbackHandler(BaseCallbackHandler):
|
|||||||
*,
|
*,
|
||||||
run_id: UUID,
|
run_id: UUID,
|
||||||
parent_run_id: Optional[UUID] = None,
|
parent_run_id: Optional[UUID] = None,
|
||||||
|
tags: Optional[List[str]] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run on retriever start."""
|
"""Run on retriever start."""
|
||||||
@ -425,6 +436,7 @@ class AsyncCallbackHandler(BaseCallbackHandler):
|
|||||||
*,
|
*,
|
||||||
run_id: UUID,
|
run_id: UUID,
|
||||||
parent_run_id: Optional[UUID] = None,
|
parent_run_id: Optional[UUID] = None,
|
||||||
|
tags: Optional[List[str]] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run on retriever end."""
|
"""Run on retriever end."""
|
||||||
@ -435,6 +447,7 @@ class AsyncCallbackHandler(BaseCallbackHandler):
|
|||||||
*,
|
*,
|
||||||
run_id: UUID,
|
run_id: UUID,
|
||||||
parent_run_id: Optional[UUID] = None,
|
parent_run_id: Optional[UUID] = None,
|
||||||
|
tags: Optional[List[str]] = None,
|
||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run on retriever error."""
|
"""Run on retriever error."""
|
||||||
|
@ -442,6 +442,7 @@ class RunManager(BaseRunManager):
|
|||||||
text,
|
text,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -469,6 +470,7 @@ class AsyncRunManager(BaseRunManager):
|
|||||||
text,
|
text,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -493,6 +495,7 @@ class CallbackManagerForLLMRun(RunManager, LLMManagerMixin):
|
|||||||
token=token,
|
token=token,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -509,6 +512,7 @@ class CallbackManagerForLLMRun(RunManager, LLMManagerMixin):
|
|||||||
response,
|
response,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -529,6 +533,7 @@ class CallbackManagerForLLMRun(RunManager, LLMManagerMixin):
|
|||||||
error,
|
error,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -553,6 +558,7 @@ class AsyncCallbackManagerForLLMRun(AsyncRunManager, LLMManagerMixin):
|
|||||||
token,
|
token,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -569,6 +575,7 @@ class AsyncCallbackManagerForLLMRun(AsyncRunManager, LLMManagerMixin):
|
|||||||
response,
|
response,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -589,6 +596,7 @@ class AsyncCallbackManagerForLLMRun(AsyncRunManager, LLMManagerMixin):
|
|||||||
error,
|
error,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -626,6 +634,7 @@ class CallbackManagerForChainRun(RunManager, ChainManagerMixin):
|
|||||||
outputs,
|
outputs,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -646,6 +655,7 @@ class CallbackManagerForChainRun(RunManager, ChainManagerMixin):
|
|||||||
error,
|
error,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -665,6 +675,7 @@ class CallbackManagerForChainRun(RunManager, ChainManagerMixin):
|
|||||||
action,
|
action,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -684,6 +695,7 @@ class CallbackManagerForChainRun(RunManager, ChainManagerMixin):
|
|||||||
finish,
|
finish,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -721,6 +733,7 @@ class AsyncCallbackManagerForChainRun(AsyncRunManager, ChainManagerMixin):
|
|||||||
outputs,
|
outputs,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -741,6 +754,7 @@ class AsyncCallbackManagerForChainRun(AsyncRunManager, ChainManagerMixin):
|
|||||||
error,
|
error,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -760,6 +774,7 @@ class AsyncCallbackManagerForChainRun(AsyncRunManager, ChainManagerMixin):
|
|||||||
action,
|
action,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -779,6 +794,7 @@ class AsyncCallbackManagerForChainRun(AsyncRunManager, ChainManagerMixin):
|
|||||||
finish,
|
finish,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -820,6 +836,7 @@ class CallbackManagerForToolRun(RunManager, ToolManagerMixin):
|
|||||||
output,
|
output,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -840,6 +857,7 @@ class CallbackManagerForToolRun(RunManager, ToolManagerMixin):
|
|||||||
error,
|
error,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -877,6 +895,7 @@ class AsyncCallbackManagerForToolRun(AsyncRunManager, ToolManagerMixin):
|
|||||||
output,
|
output,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -897,6 +916,7 @@ class AsyncCallbackManagerForToolRun(AsyncRunManager, ToolManagerMixin):
|
|||||||
error,
|
error,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -926,6 +946,7 @@ class CallbackManagerForRetrieverRun(RunManager, RetrieverManagerMixin):
|
|||||||
documents,
|
documents,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -942,6 +963,7 @@ class CallbackManagerForRetrieverRun(RunManager, RetrieverManagerMixin):
|
|||||||
error,
|
error,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -972,6 +994,7 @@ class AsyncCallbackManagerForRetrieverRun(
|
|||||||
documents,
|
documents,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -988,6 +1011,7 @@ class AsyncCallbackManagerForRetrieverRun(
|
|||||||
error,
|
error,
|
||||||
run_id=self.run_id,
|
run_id=self.run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1188,6 +1212,7 @@ class CallbackManager(BaseCallbackManager):
|
|||||||
query,
|
query,
|
||||||
run_id=run_id,
|
run_id=run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1454,6 +1479,7 @@ class AsyncCallbackManager(BaseCallbackManager):
|
|||||||
query,
|
query,
|
||||||
run_id=run_id,
|
run_id=run_id,
|
||||||
parent_run_id=self.parent_run_id,
|
parent_run_id=self.parent_run_id,
|
||||||
|
tags=self.tags,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user