| 40 | |
| 41 | |
| 42 | def 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 | |
| 64 | def run_streaming(client: OpenAI, label: str, model: str) -> None: |