Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add completion specification for ollama command-line tool #2490

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions src/ollama.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
const ListModelGenerator: Fig.Generator = {
script: ["bash", "-c", "ollama ls | awk '!/NAME/ { print $1 }'"],
postProcess: (out) => out.trim().split("\n"),
};

const RunModelGenerator: Fig.Generator = {
script: ["bash", "-c", "ollama ps | awk '!/NAME/ { print $1 }'"],
postProcess: (out) => out.trim().split("\n"),
};

const completionSpec: Fig.Spec = {
name: "ollama",
description:
"A command-line tool for managing and deploying machine learning models",
subcommands: [
{
name: "serve",
description: "Start ollama",
},
{
name: "create",
description: "Create a model from a Modelfile",
options: [
{
name: "-f",
description: "Specify Modelfile",
args: {
name: "filename",
template: "filepaths",
},
},
],
},
{
name: "show",
description: "Show information for a model",
args: {
name: "model",
generators: ListModelGenerator,
},
},
{
name: "run",
description: "Run a model",
args: {
name: "model",
generators: ListModelGenerator,
},
options: [
{
name: "--verbose",
description: "Enable verbose output",
},
],
},
{
name: "stop",
description: "Stop the ollama server",
args: {
name: "model",
generators: RunModelGenerator,
},
},
{
name: "pull",
description: "Pull a model from a registry",
},
{
name: "push",
description: "Push a model to a registry",
},
{
name: ["list", "ls"],
description: "List models",
},
{
name: "ps",
description: "List running models",
},
{
name: "cp",
description: "Copy a model",
args: {
name: "SOURCE",
generators: ListModelGenerator,
},
},
{
name: "rm",
description: "Remove a model",
args: {
name: "model",
generators: ListModelGenerator,
},
},
{
name: "help",
description: "Help about any command",
subcommands: [
{
name: "serve",
description: "Start ollama",
},
{
name: "create",
description: "Create a model from a Modelfile",
},
{
name: "show",
description: "Show information for a model",
},
{
name: "run",
description: "Run a model",
},
{
name: "stop",
description: "Stop the ollama server",
},
{
name: "pull",
description: "Pull a model from a registry",
},
{
name: "push",
description: "Push a model to a registry",
},
{
name: "list",
description: "List models",
},
{
name: "ps",
description: "List running models",
},
{
name: "cp",
description: "Copy a model",
},
{
name: "rm",
description: "Remove a model",
},
],
},
],
options: [
{
name: ["--help", "-h"],
description: "Show help for ollama",
isPersistent: true,
},
{
name: ["--version", "-v"],
description: "Show version information",
},
],
};

export default completionSpec;
Loading