MCPcopy Create free account
hub / github.com/NVIDIA/NeMo-Relay / SimpleCodec

Class SimpleCodec

python/tests/test_codecs.py:31–47  ·  view source on GitHub ↗

Test codec that treats LLMRequest.content as an OpenAI-like payload.

Source from the content-addressed store, hash-verified

29
30
31class SimpleCodec(LlmCodec):
32 """Test codec that treats LLMRequest.content as an OpenAI-like payload."""
33
34 def decode(self, request):
35 content = request.content
36 messages = content.get("messages", [])
37 return AnnotatedLLMRequest(
38 messages,
39 model=content.get("model"),
40 params={"temperature": content.get("temperature")} if "temperature" in content else None,
41 )
42
43 def encode(self, annotated, original):
44 content = {**original.content, "messages": annotated.messages}
45 if annotated.model is not None:
46 content["model"] = annotated.model
47 return LLMRequest(original.headers, content)
48
49
50class AlternateCodec(LlmCodec):

Calls

no outgoing calls