mirror of
https://github.com/zenlm/engine.git
synced 2026-10-30 15:00:05 +00:00
* 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]>
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
from mistralrs import Runner, Which, ChatCompletionRequest, VisionArchitecture
|
|
|
|
|
|
# Choose a Vision model that supports both modalities
|
|
runner = Runner(
|
|
which=Which.VisionPlain(
|
|
model_id="microsoft/Phi-4-multimodal-instruct",
|
|
arch=VisionArchitecture.Phi4MM,
|
|
),
|
|
)
|
|
|
|
# Remote media assets (swap for anything you like)
|
|
IMAGE_URL = "https://www.allaboutbirds.org/guide/assets/og/528129121-1200px.jpg"
|
|
AUDIO_URL = "https://upload.wikimedia.org/wikipedia/commons/4/42/Bird_singing.ogg"
|
|
|
|
|
|
response = runner.send_chat_completion_request(
|
|
ChatCompletionRequest(
|
|
model="default",
|
|
messages=[
|
|
{
|
|
"role": "user",
|
|
"content": [
|
|
{ # Audio clip
|
|
"type": "audio_url",
|
|
"audio_url": {"url": AUDIO_URL},
|
|
},
|
|
{ # Image
|
|
"type": "image_url",
|
|
"image_url": {"url": IMAGE_URL},
|
|
},
|
|
{ # Text prompt referencing above media
|
|
"type": "text",
|
|
"text": "<|audio_1|><|image_1|> Describe in detail what is happening, referencing both what you hear and what you see.",
|
|
},
|
|
],
|
|
}
|
|
],
|
|
max_tokens=256,
|
|
temperature=0.2,
|
|
top_p=0.9,
|
|
)
|
|
)
|
|
|
|
print(response.choices[0].message.content)
|