Cli Anything Ollama

作者 hkuds34f519533bc1無授權條款51K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫2 週前更新

Command-line interface for Ollama - Local LLM inference and model management via Ollama REST API. Designed for AI agents and power users who need to manage models, generate text, chat, and create embeddings without a GUI.

僅含說明AI & Agents
AI 產生的概覽

用於管理 Ollama 模型並執行本機大型語言模型文字生成、對話與嵌入的命令列介面。

功能
提供圍繞 Ollama REST API 的命令列封裝,用於本機大型語言模型推論與模型管理。它可以列出、檢視、拉取、複製與刪除模型,生成文字與對話補全,並產生文字嵌入。它也會回報伺服器狀態與版本,維護輕量工作階段狀態,並提供人類可讀或 JSON 輸出。
適用情境
當你需要管理本機 Ollama 模型,或在不使用圖形介面的情況下執行本機文字生成、對話或嵌入請求時使用。它適合需要 JSON 輸出與非串流回應的代理或指令碼化情境。
執行需求
需要 Python 3.10+ 以及已安裝並執行的 Ollama 伺服器(ollama serve)。此命令列工具透過 pip 以 cli-anything-ollama 套件安裝;需要網路存取以連線 Ollama 主機,主機可為本機或遠端。此技能不隨附指令碼。

cli-anything-ollama

Local LLM inference and model management via the Ollama REST API. Designed for AI agents and power users who need to manage models, generate text, chat, and create embeddings without a GUI.

Installation

This CLI is installed as part of the cli-anything-ollama package:

bash
pip install cli-anything-ollama

Prerequisites:

  • Python 3.10+
  • Ollama must be installed and running (ollama serve)

Usage

Basic Commands

bash
# Show helpcli-anything-ollama --help
# Start interactive REPL modecli-anything-ollama
# List available modelscli-anything-ollama model list
# Run with JSON output (for agent consumption)cli-anything-ollama --json model list

REPL Mode

When invoked without a subcommand, the CLI enters an interactive REPL session:

bash
cli-anything-ollama# Enter commands interactively with tab-completion and history

Command Groups

Model

Model management commands.

CommandDescription
listList locally available models
showShow model details (parameters, template, license)
pullDownload a model from the Ollama library
rmDelete a model from local storage
copyCopy a model to a new name
psList models currently loaded in memory

Generate

Text generation and chat commands.

CommandDescription
textGenerate text from a prompt
chatSend a chat completion request

Embed

Embedding generation commands.

CommandDescription
textGenerate embeddings for text

Server

Server status and info commands.

CommandDescription
statusCheck if Ollama server is running
versionShow Ollama server version

Session

Session state commands.

CommandDescription
statusShow current session state
historyShow chat history for current session

Examples

List and Pull Models

bash
# List available modelscli-anything-ollama model list
# Pull a modelcli-anything-ollama model pull llama3.2
# Show model detailscli-anything-ollama model show llama3.2

Generate Text

bash
# Stream text (default)cli-anything-ollama generate text --model llama3.2 --prompt "Explain quantum computing in one sentence"
# Non-streaming with JSON output (for agents)cli-anything-ollama --json generate text --model llama3.2 --prompt "Hello" --no-stream

Chat

bash
# Single-turn chatcli-anything-ollama generate chat --model llama3.2 --message "user:What is Python?"
# Multi-turn chatcli-anything-ollama generate chat --model llama3.2 \  --message "user:What is Python?" \  --message "user:How does it compare to JavaScript?"
# Chat from JSON filecli-anything-ollama generate chat --model llama3.2 --file messages.json

Embeddings

bash
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"

Interactive REPL Session

Start an interactive session for exploratory use.

bash
cli-anything-ollama# Enter commands interactively# Use 'help' to see available commands

Connect to Remote Host

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

State Management

The CLI maintains lightweight session state:

  • Current host URL: Configurable via --host
  • Chat history: Tracked for multi-turn conversations in REPL
  • Last used model: Shown in REPL prompt

Output Formats

All commands support dual output modes:

  • Human-readable (default): Tables, colors, formatted text
  • Machine-readable (--json flag): Structured JSON for agent consumption
bash
# Human outputcli-anything-ollama model list
# JSON output for agentscli-anything-ollama --json model list

For AI Agents

When using this CLI programmatically:

  1. Always use --json flag for parseable output
  2. Check return codes - 0 for success, non-zero for errors
  3. Parse stderr for error messages on failure
  4. Use --no-stream for generate/chat to get complete responses
  5. Verify Ollama is running with server status before other commands

More Information

  • Full documentation: See README.md in the package
  • Test coverage: See TEST.md in the package
  • Methodology: See HARNESS.md in the cli-anything-plugin

Version

1.0.1

來源與署名

來源:hkuds/cli-anything位於skills/cli-anything-ollama提交34f5195

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架