MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / run_non_streaming

Function run_non_streaming

examples/local-inference/inference.py:42–61  ·  view source on GitHub ↗
(client: OpenAI, label: str, model: str)

Source from the content-addressed store, hash-verified

40
41
42def run_non_streaming(client: OpenAI, label: str, model: str) -> None:
43 print("=" * 60)
44 print(f"NON-STREAMING — {label}")
45 print("=" * 60)
46
47 t0 = time.monotonic()
48 response = client.chat.completions.create(
49 model=model,
50 messages=MESSAGES,
51 temperature=0,
52 )
53 elapsed = time.monotonic() - t0
54
55 content = (response.choices[0].message.content or "").strip()
56 words = content.split()
57 print(f" model = {response.model}")
58 print(f" words = {len(words)}")
59 print(f" preview = {' '.join(words[:20])}...")
60 print(f" total = {elapsed:.2f}s")
61 print()
62
63
64def run_streaming(client: OpenAI, label: str, model: str) -> None:

Callers 1

mainFunction · 0.85

Calls 1

createMethod · 0.45

Tested by

no test coverage detected