Skip to content

Instantly share code, notes, and snippets.

View velotiotech's full-sized avatar

Velotio Technologies velotiotech

View GitHub Profile
ai_command_widget() {
local input="$READLINE_LINE"
local cmdout
cmdout=$(echo "$input" | node "$HOME/ai-shell-helper/main.js")
READLINE_LINE="$cmdout"
READLINE_POINT=${#READLINE_LINE}
}
# Bind Ctrl+G to the function
function ai-command-widget() {
alias ai-cmd='node $HOME/ai-shell-helper/main.js'
local input
input="$LBUFFER"
local cmdout
cmdout=$(echo "$input" | ai-cmd)
# Replace current buffer with AI-generated command
LBUFFER="$cmdout"
INFERENCE_MODE="<ollama|aws_bedrock>"
# For local inference
OLLAMA_URL="http://localhost:11434"
# For Bedrock inference
BEDROCK_FLOW_IDENTIFIER="<flow ID or ARN>"
BEDROCK_FLOW_ALIAS="<alias name or ARN>"
AWS_REGION="us-east-1"
INFERENCE_MODE="<ollama|aws_bedrock>"
# For local inference
OLLAMA_URL="http://localhost:11434"
# For Bedrock inference
BEDROCK_FLOW_IDENTIFIER="<flow ID or ARN>"
BEDROCK_FLOW_ALIAS="<alias name or ARN>"
AWS_REGION="us-east-1"
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Statement1",
"Effect": "Allow",
"Action": [
"bedrock:InvokeFlow"
],
"Resource": "<flow resource arn>"
curl -d @/tmp/payload.json -H 'Content-Type: application/json' 'http://localhost:11434/api/generate'
{
"model": "phi4:latest",
"prompt": "You are a linux system administrator and devops engineer assistant used in an automated system that parses your responses as raw JSON.\nSTRICT RULES:\n- Output MUST be only valid raw JSON. Do NOT include markdown, backticks, or formatting tags.\n- NO explanations, no introductory text, and no comments.\n- If no suitable command is found, output: {\"command\": \"\", \"notes\": \"no command found\", \"status\": \"error\"}\n- Output must always follow this exact schema:\n{\n \"command\": \"<actual Linux command here>\",\n \"notes\": \"<if applicable, add any notes to the command>\",\n \"status\": \"success/error\"\n}\n- Any deviation from this format will result in system error.\nRespond to the following user query as per the rules above:\nstart nginx container backed by alpine image",
"stream": false
}
{
"command": "docker run -d --name my-nginx -p 80:80 -p 443:443 -v /etc/nginx/conf.d:/etc/nginx/conf.d nginx:alpine",
"notes": "Replace 'my-nginx' with a suitable container name.",
"status": "success"
}
```
{
"command": "docker run -d --name my-nginx -p 80:80 -p 443:443 -v /etc/nginx/conf.d:/etc/nginx/conf.d nginx:alpine",  
"notes": "Replace 'my-nginx' with a suitable container name.",  
"status": "success"
}
```
```
You are a linux system administrator and devops engineer assistant used in an automated system that parses your responses as raw JSON.
STRICT RULES:
- Output MUST be only valid raw JSON. Do NOT include markdown, backticks, or formatting tags.
- NO explanations, no introductory text, and no comments.
- If no suitable command is found, output: {"command": "", "notes": "no command found", "status": "error"}
- Output must always follow this exact schema:
{
"command": "<actual Linux command here>",
"notes": "<if applicable, add any notes to the command>",