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

Function _chat_chunk

tests/test_format_translate_processor.py:44–66  ·  view source on GitHub ↗
(
    *,
    content: str | None = None,
    finish_reason: str | None = None,
)

Source from the content-addressed store, hash-verified

42
43
44def _chat_chunk(
45 *,
46 content: str | None = None,
47 finish_reason: str | None = None,
48) -> ChatCompletionChunk:
49 delta: dict[str, Any] = {}
50 if content is not None:
51 delta["content"] = content
52 return ChatCompletionChunk.model_validate(
53 {
54 "id": "chatcmpl-test",
55 "object": "chat.completion.chunk",
56 "created": 1700000000,
57 "model": "backend-model",
58 "choices": [
59 {
60 "index": 0,
61 "delta": delta,
62 "finish_reason": finish_reason,
63 }
64 ],
65 }
66 )
67
68
69def _chat_tool_chunk(

Calls

no outgoing calls

Tested by

no test coverage detected