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]>
27 lines
661 B
Python
27 lines
661 B
Python
from openai import OpenAI
|
|
|
|
client = OpenAI(api_key="foobar", base_url="http://localhost:1234/v1/")
|
|
|
|
messages = [
|
|
{
|
|
"role": "user",
|
|
"content": "Can you show me some code using mistral.rs for running Llama 3.2 Vision?",
|
|
}
|
|
]
|
|
|
|
completion = client.chat.completions.create(
|
|
model="default",
|
|
messages=messages,
|
|
tool_choice="auto",
|
|
max_tokens=1024,
|
|
web_search_options={},
|
|
)
|
|
|
|
# print(completion.usage)
|
|
print(completion.choices[0].message.content)
|
|
|
|
if completion.choices[0].message.tool_calls is not None:
|
|
# Should never happen.
|
|
tool_called = completion.choices[0].message.tool_calls[0].function
|
|
print(tool_called)
|