mirror of
https://github.com/hanzoai/engine.git
synced 2026-11-20 14:17:52 +00:00
Replace all remaining references to the upstream project/author/framework brands with hanzo / hanzoai across source, comments, docs, examples, and build scripts. - Project spellings mistral.rs / mistral-rs / mistralrs -> hanzo (and the hanzo-* crate/binary names in Dockerfiles, Makefile, install.ps1, .gitignore). - Author EricLBuehler / EricBuehler / EricB / Eric Buehler -> hanzoai / Hanzo AI (incl. Cargo `authors` and LICENSE copyright). - URLs: github.com/EricLBuehler/mistral.rs -> github.com/hanzoai/engine; ericlbuehler.github.io/mistral.rs -> hanzoai.github.io/engine; github.com/huggingface/candle -> github.com/hanzoai/ml; docs.rs/candle-* -> docs.rs/hanzo-ml; ghcr.io image -> ghcr.io/hanzoai/engine. - Env var prefix MISTRALRS_ -> HANZO_ (producers and consumers kept in sync, incl. the build-script-injected HANZO_GIT_REVISION). - ROCm static lib libmistralrsrocm.a / mistralrsrocm -> libhanzorocm.a / hanzorocm. - localStorage keys mistralrs_settings -> hanzo_settings. Deliberately preserved: real model architectures (struct Mistral, models/mistral.rs file, Mixtral/Llama/Gemma/Qwen/Phi), real model-org HF repo-ids (mistralai/, meta-llama/, google/, Qwen/, microsoft/), the `use hanzo_ml as candle` code aliases and `candle::` identifiers, and the upstream-author HF data repo-id suffix in "hanzoai/mistralrs_tests". Both `cargo check` and `cargo check --features vulkan` pass with 0 errors. Co-authored-by: Hanzo Dev <[email protected]>
61 lines
1.7 KiB
Python
61 lines
1.7 KiB
Python
"""
|
|
MCP (Model Context Protocol) client usage with hanzo Python API.
|
|
|
|
Connects to an MCP server, auto-discovers tools, and makes them available
|
|
to the model during conversations.
|
|
|
|
Install the filesystem server first: npx @modelcontextprotocol/server-filesystem . -y
|
|
"""
|
|
|
|
import hanzo
|
|
|
|
|
|
def main():
|
|
# Connect to a local filesystem MCP server
|
|
mcp_config = hanzo.McpClientConfigPy(
|
|
servers=[
|
|
hanzo.McpServerConfigPy(
|
|
id="filesystem",
|
|
name="Filesystem Tools",
|
|
source=hanzo.McpServerSourcePy.Process(
|
|
command="npx",
|
|
args=["@modelcontextprotocol/server-filesystem", "."],
|
|
work_dir=None,
|
|
env=None,
|
|
),
|
|
)
|
|
]
|
|
)
|
|
|
|
# Other transport types are also supported:
|
|
#
|
|
# McpServerSourcePy.Http(url="https://hf.co/mcp", timeout_secs=30, headers=None)
|
|
# McpServerSourcePy.WebSocket(url="wss://api.example.com/mcp", timeout_secs=30, headers=None)
|
|
#
|
|
# For authentication, set bearer_token="your-token".
|
|
# To avoid tool name conflicts, set tool_prefix="prefix".
|
|
|
|
runner = hanzo.Runner(
|
|
which=hanzo.Which.Plain(
|
|
model_id="Qwen/Qwen3-4B",
|
|
arch=hanzo.Architecture.Qwen3,
|
|
),
|
|
mcp_client_config=mcp_config,
|
|
)
|
|
|
|
request = hanzo.ChatCompletionRequest(
|
|
model="default",
|
|
messages=[
|
|
{"role": "user", "content": "List the files in the current directory."}
|
|
],
|
|
max_tokens=1000,
|
|
tool_choice=hanzo.ToolChoice.Auto,
|
|
)
|
|
|
|
response = runner.send_chat_completion_request(request)
|
|
print(response.choices[0].message.content)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|