Slim
Slim - Lightweight client for local LLM inference
Provides a simple interface to Ollama for running small language models. Designed for specialized tasks like classification, annotation, and extraction.
Usage
require "slim"
client = Slim::Client.new
# Simple completion
response = client.generate("llama3.2:3b", "Classify this as question or statement: How are you?")
puts response.text
# Streaming
client.generate("llama3.2:3b", prompt) do |chunk|
print chunk
end
# Chat format
messages = [
Slim::Message.new("system", "You are a classifier."),
Slim::Message.new("user", "Is this a question? Hello world"),
]
response = client.chat("llama3.2:3b", messages)
Constants
DEFAULT_HOST = "http://localhost:11434"
Default Ollama endpoint
VERSION = "0.1.0"