This directory contains the Go implementation of sqirvy-cli, a command-line tool for interacting with various Large Language Models (LLMs).
The Go version of sqirvy-cli provides a native executable for querying LLMs from the terminal. It leverages several popular Go libraries to offer a robust and efficient command-line experience.
- Native Executable: Compiles to a single binary for easy distribution and execution.
- Multi-Provider Support: Interacts with Anthropic, Google Gemini, OpenAI, and Llama models via the
langchaingolibrary. - Structured Commands: Uses the
cobralibrary for a clear command structure:query: Sends arbitrary prompts (default command).plan: Requests the LLM to generate a plan.code: Asks the LLM to generate source code.review: Instructs the LLM to review code or text.models: Lists supported models and their providers.
- Flexible Input: Reads prompts from:
- Standard Input (stdin) for easy piping.
- File paths.
- URLs (content is scraped using the
collylibrary).
- Configuration:
- Command-line flags (
-mfor model,-tfor temperature) managed bycobra. - Environment variables for API keys (
ANTHROPIC_API_KEY,GEMINI_API_KEY,OPENAI_API_KEY,LLAMA_API_KEY) and base URLs (OPENAI_BASE_URL,LLAMA_BASE_URL). - Optional configuration file support via
viper(default:$HOME/.config/sqirvy-cli/config.yaml).
- Command-line flags (
- System Prompts: Uses embedded
.mdfiles for command-specific system prompts (query.md,plan.md,code.md,review.md). - Modular Design:
cmd/sqirvy-cli: Contains the main application logic, command definitions (cobra), and prompt reading/processing.pkg/sqirvy: Implements the core LLM interaction logic, defining theClientinterface and provider-specific implementations (Anthropic, Gemini, OpenAI, Llama) usinglangchaingo. Manages model-provider mapping and token limits.pkg/util: Provides utility functions for file reading (files.go) and web scraping (scraper.go).
You can build the executable using the standard Go toolchain:
cd go/cmd/sqirvy-cli
go build -o sqirvy-cli main.goAlternatively, use the provided Makefiles:
make build # Builds the binary in the project rootor
cd go
make build # Builds the binary in go/bin/Once built, you can run the tool from your terminal:
# Basic query using default model and temperature
echo "What is the capital of France?" | ./sqirvy-cli
# Specify model and temperature, providing a file
./sqirvy-cli -m claude-sonnet-4-20250514 -t 0.7 query my_prompt.txt
# Generate a plan from stdin
cat requirements.txt | ./sqirvy-cli plan -m gpt-4o
# Generate code based on a plan file and a URL
./sqirvy-cli code -m gemini-1.5-pro plan.md https://example.com/api-spec
# List available models
./sqirvy-cli modelsRemember to set the required API key environment variables for the models you intend to use.
Unit tests are included in the pkg/sqirvy and pkg/util directories. Run tests using:
cd go
make testOr run tests for specific packages:
cd go/pkg/sqirvy
go test ./...
cd go/pkg/util
go test ./...Note: Some tests in pkg/sqirvy require API keys to be set in the environment and will be skipped otherwise.