Communitygithub.com

cli-anything-ollama

透過 Ollama REST API 進行本地 LLM 推論與模型管理,專為 AI Agent 與進階使用者設計。

cli-anything-ollama 是什麼?

cli-anything-ollama 是一個命令列工具,透過 Ollama REST API 提供本地 LLM 推論與模型管理功能。它支援模型清單、下載、刪除與複製,文字生成、對話完成、嵌入向量產生,以及伺服器狀態監控。支援人類可讀與機器可解析的 JSON 輸出(使用 --json 參數),方便 AI Agent 程式化取用。除了直接命令模式,還提供互動式 REPL 環境,支援 tab 補全與歷史記錄。安裝僅需 pip install,先決條件為 Python 3.10+ 與正在執行的 Ollama 伺服器。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/HKUDS/CLI-Anything/tree/main/skills/cli-anything-ollama

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

cli-anything-ollama 是做什麼的?

透過 Ollama REST API 進行本地 LLM 推論與模型管理。專為 AI Agent 與進階使用者設計,無需圖形介面即可管理模型、生成文字、對話與建立嵌入向量。

安裝

此 CLI 作為 cli-anything-ollama 套件的一部分安裝:

pip install cli-anything-ollama

先決條件:

  • Python 3.10+
  • Ollama 必須已安裝並正在執行(ollama serve)

使用方式

基本指令

# 顯示說明
cli-anything-ollama --help

# 啟動互動式 REPL 模式
cli-anything-ollama

# 列出可用模型
cli-anything-ollama model list

# 以 JSON 輸出執行(供 Agent 使用)
cli-anything-ollama --json model list

REPL 模式

當不帶子指令執行時,CLI 會進入互動式 REPL 階段:

cli-anything-ollama
# 以互動方式輸入指令,支援 tab 補全與歷史記錄

指令群

Model

模型管理指令。

指令說明
list列出本地可用的模型
show顯示模型詳細資訊(參數、模板、授權)
pull從 Ollama 模型庫下載模型
rm從本地儲存刪除模型
copy將模型複製為新名稱
ps列出目前載入記憶體中的模型

Generate

文字生成與對話指令。

指令說明
text從提示詞生成文字
chat傳送對話完成請求

Embed

嵌入向量生成指令。

指令說明
text為文字生成嵌入向量

Server

伺服器狀態與資訊指令。

指令說明
status檢查 Ollama 伺服器是否正在執行
version顯示 Ollama 伺服器版本

Session

階段狀態指令。

指令說明
status顯示目前階段狀態
history顯示目前階段的對話歷史

範例

列出與下載模型

# 列出可用模型
cli-anything-ollama model list

# 下載模型
cli-anything-ollama model pull llama3.2

# 顯示模型詳細資訊
cli-anything-ollama model show llama3.2

生成文字

# 串流文字(預設)
cli-anything-ollama generate text --model llama3.2 --prompt "用一句話解釋量子運算"

# 非串流模式,輸出 JSON(供 Agent 使用)
cli-anything-ollama --json generate text --model llama3.2 --prompt "你好" --no-stream

對話

# 單輪對話
cli-anything-ollama generate chat --model llama3.2 --message "user:什麼是 Python?"

# 多輪對話
cli-anything-ollama generate chat --model llama3.2 \
  --message "user:什麼是 Python?" \
  --message "user:它與 JavaScript 相比如何?"

# 從 JSON 檔案對話
cli-anything-ollama generate chat --model llama3.2 --file messages.json

嵌入向量

cli-anything-ollama embed text --model nomic-embed-text --input "Hello world"
cli-anything-ollama embed text --model nomic-embed-text --input "Hello" --input "World"

互動式 REPL 階段

啟動互動式階段以進行探索性使用。

cli-anything-ollama
# 以互動方式輸入指令
# 輸入 'help' 查看可用指令

連線至遠端主機

cli-anything-ollama --host http://192.168.1.100:11434 model list

狀態管理

CLI 會維護輕量級的階段狀態:

  • 目前主機 URL:可透過 --host 設定
  • 對話歷史:在 REPL 中追蹤多輪對話
  • 上次使用的模型:顯示於 REPL 提示字元中

輸出格式

所有指令均支援雙重輸出模式:

  • 人類可讀(預設):表格、色彩、格式化文字
  • 機器可讀(--json 旗標):結構化 JSON,供 Agent 使用
# 人類輸出
cli-anything-ollama model list

# 供 Agent 使用的 JSON 輸出
cli-anything-ollama --json model list

給 AI Agent 的建議

當以程式化方式使用此 CLI 時:

  1. 始終使用 --json 旗標以獲得可解析的輸出
  2. 檢查回傳碼 - 0 表示成功,非零表示錯誤
  3. 解析 stderr以取得失敗時的錯誤訊息
  4. 使用 --no-stream 以獲得 generate/chat 的完整回應
  5. 在執行其他指令前,先使用 server status 確認 Ollama 正在執行

更多資訊

  • 完整文件:請參閱套件中的 README.md
  • 測試覆蓋率:請參閱套件中的 TEST.md
  • 方法論:請參閱 cli-anything-plugin 中的 HARNESS.md

版本

1.0.1

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

cli-anything-adguardhome

>-

cli-anything-anygen

>-

cli-anything-audacity

>-

cli-anything-blender

>-

cli-anything-browser

Browser automation CLI using DOMShell MCP server. Maps Chrome

cli-anything-calibre

>-

cli-anything-ccswitch

CLI interface for CC Switch — manage AI coding tool configurations from the terminal

cli-anything-chromadb

>-

cli-anything-cloudanalyzer

Command-line interface for CloudAnalyzer — Agent-friendly harness for CloudAnalyzer, a QA platform for mapping, localization, and perception outputs. Supports 27 commands across 8 groups: point cloud evaluation, trajectory evaluation, ground segmentation QA, config-driven quality gates, baseline evolution, processing, visualization, and interactive REPL.

cli-anything-cloudcompare

Command-line interface for CloudCompare — Agent-friendly harness for CloudCompare, the open-source 3D point cloud and mesh processing software. Supports 41 commands across 9 groups: project management, session control, point cloud operations (subsample, filter, segment, analyze), mesh operations, distance computation (C2C, C2M), transformations (ICP, matrix), export (LAS/LAZ/PLY/PCD/OBJ/STL/E57), and interactive REPL.

cli-anything-comfyui

>-

cli-anything-dify-workflow

Wrapper for the Dify workflow DSL CLI. Create, inspect, validate, edit, and export Dify workflow files through a CLI-Anything harness.

cli-anything-drawio

>-

cli-anything-eez-studio

Use EEZ Studio from the command line: inspect and modify native .eez-project files, edit LVGL screens/widgets, manage SCPI commands, and invoke the real EEZ Studio backend for LVGL builds.

cli-anything-eth2-quickstart

>-

cli-anything-exa

>-

cli-anything-firefly-iii

Firefly III CLI - Personal finance management via CLI-Anything

cli-anything-freecad

Complete CLI harness for FreeCAD parametric 3D CAD modeler (258 commands). Covers ALL workbenches: Part (29 primitives + boolean + mirror + loft + sweep), Sketcher (26 cmds: geometry + constraints + editing), PartDesign (38 cmds: pad/pocket/groove/fillet/chamfer/patterns/hole/datum), Assembly (11 cmds), Mesh (16 cmds), TechDraw (15 cmds: views + dimensions + PDF/SVG), Draft (33 cmds: 2D shapes + arrays + transforms), FEM (12 cmds), CAM/CNC (10 cmds), Surface (6 cmds), Spreadsheet (7 cmds), Import (13 formats), Export (17 formats), Measure (12 cmds), Materials (21 presets). Headless FreeCAD export to STEP/IGES/STL/OBJ/DXF/PDF/glTF/3MF.

cli-anything-gimp

>-

cli-anything-godot

>-

相關技能