inlama

package module
v0.0.0-...-ff67db9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 12 Imported by: 0

README

inLama

A powerful CLI tool that seamlessly integrates Large Language Models (LLMs) into your command-line workflow, enabling intelligent text processing through simple Unix-style pipes.

Description

inLama bridges the gap between traditional command-line tools and modern AI capabilities by:

  • Allowing direct piping of text into LLMs for processing
  • Supporting both one-shot and continuous streaming modes
  • Providing customizable system prompts for specific use cases
  • Integrating smoothly with existing shell tools and workflows

Perfect for developers, system administrators, and anyone who needs to analyze, summarize, or process text data directly from the command line.

Installation

Prerequisites
  • Go 1.16 or higher
  • Running Ollama server (default: http://localhost:11434)
  • Make (optional, for using Makefile commands)
Quick Install
# Clone the repository
git clone https://github.com/NishantJoshi00/inlama.git
cd inlama

# Build and install
make install

# If you encounter permission issues
sudo make install
Manual Build
# Build only
make build

# The binary will be available in bin/inlama

Usage

Basic Commands
# Process a file
cat logs.txt | inlama

# Stream processing (continuous monitoring)
tail -f /var/log/syslog | inlama -f

# Custom system prompt
echo "Hello World" | inlama -p "Translate this text to French"

# Use a different model
cat article.txt | inlama -m gpt4
Shell Completion

Set up shell completion for enhanced usability:

# Bash
source <(inlama --completion bash)

# Zsh
source <(inlama --completion zsh)

# Fish
inlama --completion fish | source
Configuration Options
  • -f, --follow: Enable streaming mode for continuous input
  • -p, --prompt: Set custom system prompt
  • -b, --buffer-time: Set buffer time for streaming (seconds)
  • -u, --url: Set custom Ollama server URL
  • -m, --model: Specify LLM model to use
  • --completion: Generate shell completion scripts
Environment Variables
CONFIG_FILE=/path/to/config.toml inlama

Features

  • Unix-Style Piping: Seamlessly integrates with standard Unix pipes and filters
  • Streaming Support: Real-time processing of continuous data streams
  • Flexible Configuration:
    • Custom system prompts for specialized tasks
    • Configurable buffer times for streaming
    • Support for different LLM models
  • Smart Context Management: Maintains conversation context in streaming mode
  • Shell Integration:
    • Comprehensive shell completion support
    • Compatible with bash, zsh, and fish shells
  • Configuration File Support: TOML-based configuration for persistent settings

Contributing Guidelines

  1. Issue First: Create or find an issue before starting work
  2. Issue Tags: Use descriptive tags:
    • [BUG] for bug reports
    • [FEATURE] for feature requests
    • [DOCS] for documentation improvements
  3. Testing: Ensure your changes don't break existing functionality
  4. Code Style: Follow Go standard formatting guidelines
  5. Documentation: Update relevant documentation for any changes

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IoHandler

func IoHandler(response chan string, stream io.Writer, wg *sync.WaitGroup)

func OneshotHandler

func OneshotHandler(config Cli)

func OneshotReadStdin

func OneshotReadStdin() ([]string, error)

func SendRequest

func SendRequest(request OllamaRequest, config Cli, chunks chan string) ([]int, error)

func StreamHandler

func StreamHandler(config Cli)

func StreamReadStdin

func StreamReadStdin(dataChan chan string) error

Types

type Cli

type Cli struct {
	Stream       bool     // Stream input to model
	SystemPrompt string   // System prompt for model
	BufferTime   int      // Buffer time for streaming input (in seconds)
	Url          string   // Url for model
	Model        string   // Model to use
	Presets      []string // Presets for system prompts
}

func Init

func Init() Cli

type OllamaRequest

type OllamaRequest struct {
	Model   string `json:"model"`
	Prompt  string `json:"prompt"`
	System  string `json:"system"`
	Context *[]int `json:"context"`
	Stream  bool   `json:"stream"`
}

func GenerateFirstRequest

func GenerateFirstRequest(body string, config Cli) OllamaRequest

func GenerateRequest

func GenerateRequest(body string, config Cli, context []int) OllamaRequest

type OllamaResponse

type OllamaResponse struct {
	Done     bool   `json:"done"`
	Response string `json:"response"`
	Context  []int  `json:"context"`
}

Directories

Path Synopsis
cmd
inlama command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL