Skip to content

NeaByteLab/Ollama-API-Tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Ollama API Tools

Auto-execution CLI tool for LLM-powered task automation using local Ollama processing.

CLI Preview

🎯 Purpose

This project enables automatic tool execution using local LLM processing. The LLM automatically:

  • Analyzes user requests and determines required tools
  • Executes tools automatically without manual intervention
  • Continues conversation with tool results
  • Handles simple tasks through focused tool usage

✨ Features

  • Auto-Execution: LLM automatically selects and executes tools
  • Local AI Processing: Uses Ollama for 100% local AI processing
  • Tool-Based Architecture: 8 specialized tools for automation
  • Interactive CLI: Inquirer-based command line interface
  • Context Management: Persistent conversation history and session management
  • Intelligent Tool Selection: LLM chooses appropriate tools automatically

πŸ› οΈ Tools Available

Tool Description Auto-Execution
BashTool Execute bash commands securely βœ… Automatic
GrepTool Search files with regex patterns βœ… Automatic
GlobTool Find files using glob patterns βœ… Automatic
ReadTool Read file contents βœ… Automatic
EditTool Edit existing files βœ… Automatic
WriteTool Create new files (restricted) βœ… Automatic
LSTool List directory contents βœ… Automatic
WebFetchTool Fetch web content βœ… Automatic

πŸ“¦ Installation

# Clone the repository
git clone https://github.com/NeaByteLab/Ollama-API-Tools
cd Ollama-API-Tools

# Install dependencies
npm install

# Install Ollama (if not already installed)
# Visit: https://ollama.ai or https://ollama.com

βš™οΈ Prerequisites

  • Node.js 18+
  • Ollama running locally
  • Granite 3.2:8b model (or compatible model)

πŸš€ Usage

Start Auto-Execution Session

npm start
# or
node CLI.js

Show System Information

node CLI.js info

⚑ How Auto-Execution Works

  1. User Input: You describe what you want
  2. LLM Analysis: LLM analyzes request and selects tools
  3. Auto-Execution: Tools execute automatically
  4. Result Processing: Results are added to conversation
  5. Continued Conversation: LLM responds with results

βš™οΈ Configuration

Default Model

Edit CLI.js line 40 to change the default model:

const defaultModel = 'granite3.2:8b' // Change this

Available Models

  • granite3.2:8b (default)
  • qwen2.5-coder:7b
  • llama3.2:8b
  • Any Ollama-compatible model

πŸ“ Auto-Execution Examples

File Operations

# List directory contents
You: list files in current directory

# Read file contents  
You: read package.json

# Search for patterns
You: find all files containing "import"

# Edit files
You: add a comment to the main function

πŸ”§ System Operations

# Check running services
You: check if redis is running

# Execute commands
You: run npm install

# System information
You: show system info

🌐 Web Operations

# Fetch web content
You: get content from https://example.com

πŸ”„ Simple Workflows

# Basic file operations
You: read package.json and show dependencies

# Simple search
You: find all files containing "import" in src folder

🎯 Auto-Execution Features

  • Intelligent Tool Selection: LLM automatically chooses appropriate tools
  • Single Tool Execution: Simple, focused tool usage per request
  • Error Handling: Automatic error reporting and fallback
  • Context Awareness: Maintains conversation context across tool executions
  • Result Integration: Tool results automatically feed back into conversation

πŸ› οΈ Development

Project Structure

Ollama-API-Tools/
β”œβ”€β”€ CLI.js              # Main CLI application with auto-execution
β”œβ”€β”€ package.json        # Dependencies and scripts
β”œβ”€β”€ prompt/            # AI prompt configurations
β”‚   β”œβ”€β”€ prompt.txt     # Main system prompt
β”‚   └── message.json   # Message templates
β”œβ”€β”€ tools/             # Tool implementations
β”‚   β”œβ”€β”€ Registry.js    # Tool registry
β”‚   β”œβ”€β”€ BashTool.js    # Command execution
β”‚   β”œβ”€β”€ ReadTool.js    # File reading
β”‚   └── ...           # Other tools
β”œβ”€β”€ services/          # Service layer
β”‚   └── Provider.js    # Ollama API integration
β”œβ”€β”€ utils/             # Utilities
β”‚   └── Context.js     # Session management
└── tests/             # Test files
    └── TestTools.js   # Tool testing

βž• Adding New Tools

  1. Create tool file in tools/ directory
  2. Implement tool class with execute() method
  3. Add to Registry.js exports
  4. Update prompt.txt tool list

πŸ§ͺ Testing

npm test
# or
node tests/TestTools.js

πŸ”§ Troubleshooting

Common Issues

Ollama not running

# Start Ollama
ollama serve

Model not found

# Pull model
ollama pull granite3.2:8b

Tool execution errors

  • Check file permissions
  • Verify tool dependencies
  • Review error messages in console

Auto-execution not working

  • Check LLM model compatibility
  • Verify tool schema definitions
  • Review prompt configuration

πŸ“„ License

MIT License - NeaByteLab

About

Node.js CLI with auto-execution capabilities using local Ollama models for intelligent tool selection and automation

Topics

Resources

License

Stars

Watchers

Forks

Contributors