20 lines
484 B
Python
20 lines
484 B
Python
"""MLC Engine Python example."""
|
|
|
|
from mlc_llm import MLCEngine
|
|
|
|
# Create engine
|
|
model = "HF://mlc-ai/Llama-3-8B-Instruct-q4f16_1-MLC"
|
|
engine = MLCEngine(model)
|
|
|
|
# Run chat completion in OpenAI API.
|
|
for response in engine.chat.completions.create(
|
|
messages=[{"role": "user", "content": "What is the meaning of life?"}],
|
|
model=model,
|
|
stream=True,
|
|
):
|
|
for choice in response.choices:
|
|
print(choice.delta.content, end="", flush=True)
|
|
print("\n")
|
|
|
|
engine.terminate()
|