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]>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
from openai import OpenAI
|
||
|
||
|
||
# Point the client to the locally running server
|
||
client = OpenAI(api_key="foobar", base_url="http://localhost:1234/v1/")
|
||
|
||
# Remote assets – feel free to swap for anything else
|
||
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"
|
||
|
||
completion = client.chat.completions.create(
|
||
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 with explicit tokens referring to the audio/image above
|
||
"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(completion.choices[0].message.content)
|