安装本地大模型(win版)
第一步:安装ollama
`https://ollama.com/download`
第二步:在ollama 官网搜索
`https://ollama.com/`

第三步:在终端执行部署
- 根据电脑配置安装对应的模型
ollama run gemma2:2b

Linux安装ShellGPT
第一步:ShellGPT 配置
现在,当我们运行 Ollama 后端时,我们需要配置 ShellGPT 以使用它。为了与本地 LLM 后端通信,ShellGPT 利用 LiteLLM[1]。要安装它,请运行:
`[root@localhost ~]# pip install shell-gpt --break-system-packages`
第二步:编辑.sgptrc配置文件
vi ~/.config/shell_gpt/.sgptrc
,加入以下选项
vi ~/.config/shell_gpt/.sgptrc #编辑shell-gpt配置文件
DEFAULT_MODEL=ollama/gemma2:9b #制定要使用的模型
OPENAI_USE_FUNCTIONS=false
SHOW_FUNCTIONS_OUTPUT=false
API_BASE_URL=http://192.168.79.249:11434 #设置本地服务器ip地址
现在您可以将 ShellGPT 与 Ollama 后端一起使用。
如下例所示:
[root@localhost ~]# cat ~/.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=ollama/deepseek-r1:32b
DEFAULT_COLOR=magenta
ROLE_STORAGE_PATH=/root/.config/shell_gpt/roles
DEFAULT_EXECUTE_SHELL_CMD=false
DISABLE_STREAMING=false
CODE_THEME=dracula
OPENAI_FUNCTIONS_PATH=/root/.config/shell_gpt/functions
OPENAI_USE_FUNCTIONS=false
SHOW_FUNCTIONS_OUTPUT=false
API_BASE_URL=http://10.0.0.1:11434
PRETTIFY_MARKDOWN=true
USE_LITELLM=true
SHELL_INTERACTION=true
OS_NAME=auto
SHELL_NAME=auto
OPENAI_API_KEY=123
初始化ShellGPT
初始API Key的時候隨便填個字串
[root@localhost ~]# sgpt
ShellGPT 功能测试
shellgpt语法列表
╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────╮
│ prompt [PROMPT] The prompt to generate completions for. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --model TEXT Large language model to use. [default: gpt-4o] │
│ --temperature FLOAT RANGE [0.0<=x<=2.0] Randomness of generated output. [default: 0.0] │
│ --top-p FLOAT RANGE [0.0<=x<=1.0] Limits highest probable tokens (words). [default: 1.0] │
│ --md --no-md Prettify markdown output. [default: md] │
│ --editor Open $EDITOR to provide a prompt. [default: no-editor] │
│ --cache Cache completion results. [default: cache] │
│ --version Show version. │
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Assistance Options ─────────────────────────────────────────────────────────────────────────────────────╮
│ --shell -s Generate and execute shell commands. │
│ --interaction --no-interaction Interactive mode for --shell option. [default: interaction] │
│ --describe-shell -d Describe a shell command. │
│ --code -c Generate only code. │
│ --functions --no-functions Allow function calls. [default: functions] │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Chat Options ───────────────────────────────────────────────────────────────────────────────────────────╮
│ --chat TEXT Follow conversation with id, use "temp" for quick session. [default: None] │
│ --repl TEXT Start a REPL (Read–eval–print loop) session. [default: None] │
│ --show-chat TEXT Show all messages from provided chat id. [default: None] │
│ --list-chats -lc List all existing chat ids. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Role Options ───────────────────────────────────────────────────────────────────────────────────────────╮
│ --role TEXT System role for GPT model. [default: None] │
│ --create-role TEXT Create role. [default: None] │
│ --show-role TEXT Show role. [default: None] │
│ --list-roles -lr List roles. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯
1. 通用功能
root@localhost ~]# sgpt "你是谁"
我是ShellGPT,一个专注于编程和系统管理的AI助手,运行在Linux/ openEuler 24.03环境下,使用bash shell。我擅长帮助用户处理命令行任务、解决系统问题以及提供相关建议。如果需要更详细的信息或有其他问题,请随时告诉我!
2. Shell 命令
[root@localhost ~]# sgpt -s "查看当前目录"
<think>
好的,我现在需要帮用户生成一个bash命令。用户的要求是“查看当前目录”。首先,我得理解这个指令的具体含义。
在Linux系统中,“查看当前目录”通常指的是显示当前所在的目录路径。最常用的命令应该是`pwd`,它会输出绝对路径,比如 `/home/user` 这样的结果。这个命令简单直接,符合用户的需求。
接下来,我要考虑是否需要其他命令。例如,如果用户想列出目录中的文件和子目录,可能会用到`ls`。但根据用户的描述,“查看当前目录”更倾向于显示路径而不是内容,所以`pwd`是更合适的选择。
另外,用户可能没有详细说明,但有时候他们可能希望同时看到目录结构或者更多的信息。不过在这种情况下,保持简单明了更好,避免多余的输出让用户困惑。
最后,确保命令在openEuler 24.03 (LTS-SP1)系统上有效。`pwd`是一个基本的shell内置命令,在所有Linux发行版中都适用,包括openEuler,所以没有问题。
综上所述,最合适的命令就是`pwd`。
</think>
pwd
[E]xecute, [D]escribe, [A]bort: e #按e直接执行命令
3. 生成代码
`[root@localhost ~]# sgpt -c "写一个shell脚本,要求获取cpu核数线程,内存大小,磁盘大小,网络带宽"`
4. 列出所有对话
`[root@localhost ~]# sgpt --list-chats`
5. 查看对话信息
`[root@localhost ~]#sgpt --show-chat <会话路径>`
6. 启动交互式
[root@localhost ~]# sgpt --repl temp
Entering REPL mode, press Ctrl+C to exit.
>>>
链接:https://blog.csdn.net/weixin_74814027/article/details/145933302?spm=1001.2014.3001.5502
(版权归原作者所有,侵删)
文末福利
就目前来说,传统运维冲击年薪30W+的转型方向就是SRE&DevOps岗位。
为了帮助大家早日摆脱繁琐的基层运维工作,给大家整理了一套高级运维工程师必备技能资料包,内容有多详实丰富看下图!
共有 20 个模块

1.38张最全工程师技能图谱

2.面试大礼包

3.Linux书籍

4.go书籍

······
6.自动化运维工具

18.消息队列合集

以上所有资料获取请扫码
备注:最新运维资料

100%免费领取
(后台不再回复,扫码一键领取)
本文链接:https://www.yunweipai.com/47229.html
网友评论comments