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

Function _completion

tests/test_rl_logging.py:54–70  ·  view source on GitHub ↗
(*, content: str | None = "hi there", tool_calls: list | None = None,
                choices: list | None = None)

Source from the content-addressed store, hash-verified

52
53
54def _completion(*, content: str | None = "hi there", tool_calls: list | None = None,
55 choices: list | None = None) -> ChatResponse:
56 message: dict = {"role": "assistant"}
57 if content is not None:
58 message["content"] = content
59 if tool_calls is not None:
60 message["tool_calls"] = tool_calls
61 if choices is None:
62 choices = [{"index": 0, "message": message, "finish_reason": "stop"}]
63 return ChatResponse.openai_completion({
64 "id": "chatcmpl-test",
65 "object": "chat.completion",
66 "created": 1700000000,
67 "model": "gpt-test",
68 "choices": choices,
69 "usage": {"prompt_tokens": 5, "completion_tokens": 3, "total_tokens": 8},
70 })
71
72
73def _read_only_trace(log_dir: Path) -> dict:

Calls 1

openai_completionMethod · 0.45

Tested by

no test coverage detected