abefore_model() — langchain Function Reference
Architecture documentation for the abefore_model() function in openai_moderation.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD dba8c922_0033_80d5_1547_3a5900e4ba64["abefore_model()"] 48713c67_3a9a_ec9e_ec74_46e6955f07bd["OpenAIModerationMiddleware"] dba8c922_0033_80d5_1547_3a5900e4ba64 -->|defined in| 48713c67_3a9a_ec9e_ec74_46e6955f07bd e4877997_5734_a30d_80bc_a99942eef494["_amoderate_inputs()"] dba8c922_0033_80d5_1547_3a5900e4ba64 -->|calls| e4877997_5734_a30d_80bc_a99942eef494 style dba8c922_0033_80d5_1547_3a5900e4ba64 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/langchain_openai/middleware/openai_moderation.py lines 135–154
async def abefore_model(
self, state: AgentState[Any], runtime: Runtime[Any]
) -> dict[str, Any] | None: # type: ignore[override]
"""Async version of before_model.
Args:
state: Current agent state containing messages.
runtime: Agent runtime context.
Returns:
Updated state with moderated messages, or `None` if no changes.
"""
if not self.check_input and not self.check_tool_results:
return None
messages = list(state.get("messages", []))
if not messages:
return None
return await self._amoderate_inputs(messages)
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does abefore_model() do?
abefore_model() is a function in the langchain codebase, defined in libs/partners/openai/langchain_openai/middleware/openai_moderation.py.
Where is abefore_model() defined?
abefore_model() is defined in libs/partners/openai/langchain_openai/middleware/openai_moderation.py at line 135.
What does abefore_model() call?
abefore_model() calls 1 function(s): _amoderate_inputs.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free