ローカル LLM ゲートウェイ(local-llm-server / OpenAI 互換)に繋ぐ高レベルクライアント。エージェント共通のクライアントで、openai のボイラープレートを再実装しない。
Project description
local-llm-client
ローカル LLM ゲートウェイ(local-llm-server / OpenAI 互換)に繋ぐ高レベルクライアント。
- サーバー(ゲートウェイ)は別パッケージ。これは接続する側(エージェント共通のクライアント)。
- 各エージェントが openai のボイラープレート(メッセージ整形・画像入力・thinking 切替・ストリーム)を 再実装しなくて済む。
- 依存は公式
openaiSDK のみ。
インストール
uv add local-llm-client
使い方
ゲートウェイ(local-llm-server)を起動しておき、公開ポートに繋ぐだけ。
from local_llm_client import LLMClient
llm = LLMClient(
model="mlx-community/Qwen3.6-27B-4bit",
base_url="http://127.0.0.1:8799/v1",
)
print(llm.respond("ローカル LLM の利点を3つ。"))
# 画像入力・ストリーム
print(llm.respond("これは何?", images=["photo.jpg"]))
for piece in llm.respond("長い説明を", stream=True):
print(piece, end="", flush=True)
起動確認付きのワンライナー(未起動なら親切なエラー。サーバーは起動しない):
from local_llm_client import connect, ServerNotRunningError
try:
llm = connect(model="mlx-community/Qwen3.6-27B-4bit",
base_url="http://127.0.0.1:8799/v1")
except ServerNotRunningError:
print("先にゲートウェイ(local-llm-server)を起動してください")
高度な操作(embeddings / tool calling / 構造化出力 / async など)は、土台の openai クライアントに
llm.openai で直接アクセスできる。素の openai SDK で base_url を指してもよい。
ライセンス
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file local_llm_client-0.2.0.tar.gz.
File metadata
- Download URL: local_llm_client-0.2.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc7ca7bf6d784088a23ad243e35b622c829d99dac975a18359ed4899952eef54
|
|
| MD5 |
058312c4317eab03f793dcc57c844cc9
|
|
| BLAKE2b-256 |
f87293cb4cb1464755ecf9a2693374c37c350746f47d75567aa7223bce62636b
|
File details
Details for the file local_llm_client-0.2.0-py3-none-any.whl.
File metadata
- Download URL: local_llm_client-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
702979841003fbda9700c10e7cfe85bcfdee0ec5e72fd42edd42ec7fae0b4d53
|
|
| MD5 |
6fdb2002eab0a232a7742e438d51b508
|
|
| BLAKE2b-256 |
9b17b9224cd674876b171ccb35923b719d49b2c42a767e1059483d90e5f4a335
|