MCPcopy Create free account
hub / github.com/NVIDIA-NeMo/Switchyard / validate

Method validate

switchyard_rust/core.py:96–102  ·  view source on GitHub ↗

Reject semantically invalid message-based requests.

(self)

Source from the content-addressed store, hash-verified

94 return None
95
96 def validate(self) -> None:
97 """Reject semantically invalid message-based requests."""
98 if self.request_type in {ChatRequestType.OPENAI_CHAT, ChatRequestType.ANTHROPIC}:
99 if isinstance(self._body, dict) and self._body.get("messages") == []:
100 raise _load_native().SwitchyardInvalidRequestError(
101 "messages must be a non-empty array"
102 )
103
104 def set_model(self, model: str) -> None:
105 """Set the request model, replacing a malformed non-object body."""

Callers 2

anthropic_messagesMethod · 0.45
chat_completionsMethod · 0.45

Calls 2

_load_nativeFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected