Closed3

shell_gpt (sgpt) をためす

moriokamorioka

コマンドラインというかシェル上でLLMを利用するツール。シェル上で他のツールと組み合わせて使うことを想定しているので、パイプやリダイレクトとの相性がよいらしい。

A command-line productivity tool powered by AI large language models (LLM). This command-line tool offers streamlined generation of shell commands, code snippets, documentation, eliminating the need for external resources (like Google search). Supports Linux, macOS, Windows and compatible with all major Shells like PowerShell, CMD, Bash, Zsh, etc.

https://github.com/TheR1D/shell_gpt

moriokamorioka

使い始めるのは簡単。

pip install shell-gpt[litellm]  # ollamaモデルは litellm経由で。openaiモデルだけなら shell-gpt でよい
sgpt "What is the fibonacci sequence"
The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. The sequence
typically begins as follows:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...

In mathematical terms, the sequence is defined by the recurrence relation:

[ F(n) = F(n-1) + F(n-2) ]

with initial conditions:

[ F(0) = 0, \quad F(1) = 1 ]

The Fibonacci sequence appears in various natural phenomena and is used in computer algorithms, financial models, and more.

今のデフォルトモデルは "gpt-4o"らしい

https://github.com/TheR1D/shell_gpt/blob/aac2f5461b0d113dfdbfb6e926506c070d6afb52/sgpt/config.py#L25

moriokamorioka
/home/morioka/.config/shell_gpt/
├── .sgptrc
├── functions
└── roles
    ├── Code Generator.json
    ├── Shell Command Descriptor.json
    ├── Shell Command Generator.json
    └── ShellGPT.json

~/.config/shell_gpt/.sgptrc

CHAT_CACHE_PATH=/tmp/chat_cache
CACHE_PATH=/tmp/cache
CHAT_CACHE_LENGTH=100
CACHE_LENGTH=100
REQUEST_TIMEOUT=60
DEFAULT_MODEL=gpt-4o
DEFAULT_COLOR=magenta
ROLE_STORAGE_PATH=/home/morioka/.config/shell_gpt/roles
DEFAULT_EXECUTE_SHELL_CMD=false
DISABLE_STREAMING=false
CODE_THEME=dracula
OPENAI_FUNCTIONS_PATH=/home/morioka/.config/shell_gpt/functions
OPENAI_USE_FUNCTIONS=true
SHOW_FUNCTIONS_OUTPUT=false
API_BASE_URL=default
PRETTIFY_MARKDOWN=true
USE_LITELLM=false
SHELL_INTERACTION=true
OS_NAME=auto
SHELL_NAME=auto
このスクラップは2025/02/08にクローズされました