Files
engine/examples/server/streaming_completion.py
85dcfbef20 Add the SmolLM3 model! (#1501)
* Add model

* Update loader

* Fix llama config usage

* Docs

* Fix config no_rope_layers

* Fix tie_word_embeddings default

* Add chat template

* Embed the chat templates

* Fix embedding template

* enable_thinking default true

* Update examples

* XML tools for smollm3

* Add smollm3 docs

* Fix openai examples

* Clippy

---------

Co-authored-by: Eric Buehler <[email protected]>
2025-07-08 14:48:58 -04:00

17 lines
351 B
Python

import sys
from openai import OpenAI
client = OpenAI(api_key="foobar", base_url="http://localhost:1234/v1/")
response = client.completions.create(
model="default",
prompt="My favorite theorem is",
max_tokens=32,
stream=True,
)
for chunk in response:
delta = chunk.choices[0].text
print(delta, end="")
sys.stdout.flush()