llm  by ahyatt

Emacs package for LLM interaction, abstracting model choice

created 2 years ago
324 stars

Top 85.2% on sourcepulse

GitHubView on GitHub
Project Summary

This Emacs Lisp package provides a unified interface for interacting with various Large Language Models (LLMs), abstracting away differences between providers like OpenAI, Azure, Gemini, Claude, and local models via Ollama or llama.cpp. It enables Emacs users to leverage LLMs for chat, tool use, and embeddings, offering flexibility in choosing between paid APIs and free local models.

How It Works

The library uses a provider-based architecture where specific modules (e.g., llm-openai, llm-ollama) create provider objects that abstract LLM interactions. These providers handle features like chat (synchronous, asynchronous, streaming), multi-modal input (images), tool use (calling Elisp functions), and embeddings. The core llm package provides generic functions that operate on these provider objects, ensuring client code remains provider-agnostic.

Quick Start & Requirements

  • Installation: Typically installed as a dependency of other Emacs packages. To use directly, require the relevant provider module (e.g., (require 'llm-openai)).
  • Configuration: Set provider-specific variables, often involving API keys or model names, e.g., (setq llm-refactoring-provider (make-llm-openai :key "YOUR_API_KEY")). API keys can be managed securely using auth-source.
  • Dependencies: Emacs Lisp environment. Specific LLM providers may require external services or local installations (e.g., Ollama, llama.cpp).
  • Documentation: https://github.com/ahyatt/llm

Highlighted Details

  • Supports chat, embeddings, tool use, and media input (alpha).
  • Offers synchronous, asynchronous, and streaming responses.
  • Integrates with popular Emacs packages like ellama, magit-gptcommit, and ekg.
  • Provides a flexible prompt construction system with templating and context management.

Maintenance & Community

  • Developed by ahyatt.
  • Contributions are welcome via pull requests. Major providers require FSF papers due to GNU ELPA inclusion; alternative providers can be hosted on other archives like MELPA.
  • Discussions: https://github.com/ahyatt/llm/discussions

Licensing & Compatibility

  • Licensed under GPLv3.
  • As part of GNU ELPA, it aims to promote free software, with warnings issued for non-free LLM usage (configurable).

Limitations & Caveats

  • Media input functionality is currently alpha quality.
  • Tool use is in beta quality, with potential compatibility issues between providers (e.g., type handling differences).
  • The library warns when using non-free LLMs, which is the default behavior for most supported providers.
Health Check
Last commit

2 weeks ago

Responsiveness

1 day

Pull Requests (30d)
3
Issues (30d)
3
Star History
27 stars in the last 90 days

Explore Similar Projects

Starred by Peter Norvig Peter Norvig(Author of Artificial Intelligence: A Modern Approach; Research Director at Google), Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), and
2 more.

aisuite by andrewyng

0.2%
12k
Unified interface for multiple generative AI providers
created 1 year ago
updated 3 days ago
Feedback? Help us improve.