fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Mahmoud Al-Qudsicompletions/llm: Complete model alias targetd69a9296a

master
7.6 KiB142 linesraw
1# Completions for simonw/llm
2
3set -l subcmds prompt aliases chat collections embed embed-models embed-multi install keys logs models openai plugins similar templates uninstall
4function __fish_llm_subcmds
5    printf "%s\t%s\n" prompt "Execute a prompt" \
6        aliases "Manage model aliases" \
7        chat "Hold chat with model" \
8        collections "View/manage embedding collections" \
9        embed "Embed text and get/store result" \
10        embed-models "Manage available embedding models" \
11        embed-multi "Store embeddings for multiple strings" \
12        install "Install PyPI packages into llm env" \
13        keys "Manage stored API keys" \
14        logs "Explore logged prompts/responses" \
15        models "Manage available models" \
16        openai "Work with OpenAI API directly" \
17        plugins "List installed plugins" \
18        similar "Return top-N similar IDs for collection" \
19        templates "Manage stored prompt templates" \
20        uninstall "Uninstall Python packages from llm env"
21end
22
23complete -c llm -n __fish_is_first_token -xa "(__fish_llm_subcmds)"
24
25# This applies to the base command only
26complete -c llm -n "not __fish_seen_subcommand_from $subcmds" -l version -d "Show version info"
27# This applies to the base command or any subcommands
28complete -c llm -l help -d "Show command usage info" -x
29
30function __fish_llm_models
31    llm models |
32        string replace -r '^[^:\\n]+: (\\S+)(?: \\(aliases: )?((?:[^),\\s]+,?)?+.*?)\\)?$' '$1 $2' |
33        string split ' ' -n |
34        string trim -c ','
35end
36
37function __fish_embedding_models
38    llm models |
39        string replace -r '^[^:\\n]+: (\\S+)(?: \\(aliases: )?((?:[^),\\s]+,?)?+.*?)\\)?$' '$1 $2' |
40        string split ' ' -n |
41        string trim -c ','
42end
43
44# The default subcommand is 'prompt'
45set -l condition "not __fish_seen_subcommand_from $subcmds || __fish_seen_subcommand_from prompt"
46complete -c llm -n $condition -s s -l system -d "System prompt to use" -r
47complete -c llm -n $condition -s m -l model -d "Model to use" -xa "(__fish_llm_models)"
48complete -c llm -n $condition -s a -l attachment -d "Attachment to use" -ra-
49complete -c llm -n $condition -l at -d "Attachment type" -r
50complete -c llm -n $condition -l attachment-type -d "Attachment type" -r
51complete -c llm -n $condition -s n -l no-log -d "Don't log to db" -x
52complete -c llm -n $condition -s l -l log -d "Log prompt/reply to db" -x
53complete -c llm -n $condition -s c -l continue -d "Continue most recent conversation" -x
54complete -c llm -n $condition -l key -d "API key to use" -r
55complete -c llm -n $condition -l save -d "Save prompt as template with name" -x
56
57# llm aliases
58set -l condition "__fish_seen_subcommand_from aliases"
59complete -c llm -n $condition -n '__fish_is_nth_token 2' -xa list -d "List current aliases" -x
60complete -c llm -n $condition -n '__fish_is_nth_token 2' -xa path -d "Print path of llm's aliases.json" -x
61complete -c llm -n $condition -n '__fish_is_nth_token 2' -xa remove -d "Remove an llm alias" -r
62complete -c llm -n $condition -n '__fish_is_nth_token 2' -xa set -d "Set an alias for a model" -r
63complete -c llm -n $condition -n '__fish_is_nth_token 4' -xa "(__fish_llm_models)" -d "Alias target model"
64
65# llm chat
66set -l condition "__fish_seen_subcommand_from chat"
67complete -c llm -n $condition -s s -l system -d "System prompt to use" -r
68complete -c llm -n $condition -s m -l model -d "Model to use" -xa "(__fish_llm_models)"
69complete -c llm -n $condition -l cid -d "Continue conversation with given id" -x
70complete -c llm -n $condition -l conversation -d "Continue conversation with given id" -x
71complete -c llm -n $condition -s t -l template -d "Template to use" -x
72complete -c llm -n $condition -s p -l param -d "Set template parameter to value" -x
73complete -c llm -n $condition -s o -l option -d "Set key/value option for model" -x
74complete -c llm -n $condition -l no-stream -d "Do not stream output" -x
75complete -c llm -n $condition -l key -d "API key to use" -x
76
77# llm collections
78set -l condition "__fish_seen_subcommand_from collections"
79complete -c llm -n $condition -xa list -d "List collections" -x
80complete -c llm -n $condition -xa delete -d "Delete specified collection" -x
81complete -c llm -n $condition -xa path -d "Print path to embeddings database" -x
82
83# llm embed
84set -l condition "__fish_seen_subcommand_from embed"
85complete -c llm -n $condition -s i -l input -d "File to embed" -r
86complete -c llm -n $condition -s m -l model -d "Model to use" -xa "(__fish_embedding_models)"
87complete -c llm -n $condition -l store -d "Store the text itself in the db" -x
88complete -c llm -n $condition -s d -l database -d "Path to db to use" -r
89complete -c llm -n $condition -s c -l content -d "Text content to embed" -x
90complete -c llm -n $condition -l binary -d "Treat input as binary" -x
91complete -c llm -n $condition -l metadata -d "JSON object metadata to store" -x
92complete -c llm -n $condition -s f -l format -d "Output format" -xa "json blob base64 hex"
93
94# llm embed-models
95set -l condition "__fish_seen_subcommand_from embed-models"
96complete -c llm -n $condition -xa list -d "List available embedding models" -x
97complete -c llm -n $condition -xa default -d "Show or set default embedding model" -x
98
99# llm embed-multi
100set -l condition "__fish_seen_subcommand_from embed-multi"
101complete -c llm -n $condition -l format -xa "json csv tsv nl" -d "Format of input (default: auto-detected)"
102complete -c llm -n $condition -l files -r -d "Embed files in DIR matching GLOB"
103complete -c llm -n $condition -l encoding -r -d "Encoding to use when reading input"
104complete -c llm -n $condition -l binary -d "Treat input as binary"
105complete -c llm -n $condition -l sql -x -d "Read input using this SQL query"
106complete -c llm -n $condition -l attach -x -d "Attach db ALIAS from PATH"
107complete -c llm -n $condition -l batch-size -x -d "Batch size to use for embeddings"
108complete -c llm -n $condition -l prefix -x -d "Prefix to add to the IDs"
109complete -c llm -n $condition -s m -l model -d "Embedding model to use" -xa "(__fish_embedding_models)"
110complete -c llm -n $condition -l store -d "Store the text itself in the db"
111complete -c llm -n $condition -s d -l database -d "Path to db to use"
112
113# llm install
114set -l condition "__fish_seen_subcommand_from install"
115complete -c llm -n $condition -s U -l upgrade -d "Upgrade packages to latest version" -x
116complete -c llm -n $condition -s e -l editable -d "Install project in editable mode from PATH" -r
117complete -c llm -n $condition -l force-reinstall -d "Reinstall all packages, even if up-to-date" -x
118complete -c llm -n $condition -l no-cache-dir -d "Disable cache" -x
119
120# llm keys
121set -l condition "__fish_seen_subcommand_from keys"
122complete -c llm -n $condition -xa list -d "List names of all stored keys"
123complete -c llm -n $condition -xa get -d "Print saved key"
124complete -c llm -n $condition -xa path -d "Print path of llm's keys.json"
125complete -c llm -n $condition -xa set -d "Save a key in llm's keys.json"
126
127# llm logs
128set -l condition "__fish_seen_subcommand_from logs"
129complete -c llm -n $condition -xa list -d "List recent prompts and responses"
130complete -c llm -n $condition -xa off -d "Turn off logging"
131complete -c llm -n $condition -xa on -d "Turn on logging"
132complete -c llm -n $condition -xa path -d "Print path to llm's logs.db"
133complete -c llm -n $condition -xa status -d "Show current status of db logging"
134
135# llm models
136set -l condition "__fish_seen_subcommand_from models"
137complete -c llm -n $condition -xa list -d "List available models" -x
138complete -c llm -n $condition -xa default -d "Show or set default model" -x
139
140# llm plugins
141set -l condition "__fish_seen_subcommand_from plugins"
142complete -c llm -n $condition -l all -d "Include built-in/default plugins" -x