instructor_ex  by thmsmlr

Elixir library for structured LLM outputs

Created 1 year ago
747 stars

Top 46.4% on SourcePulse

GitHubView on GitHub
Project Summary

This Elixir library, instructor_ex, enables structured data output from Large Language Models (LLMs) by leveraging Ecto schemas. It targets Elixir developers seeking to integrate LLM capabilities into their applications, providing a robust way to ensure LLM responses are not only correctly formatted but also semantically valid through Ecto's validation system.

How It Works

The library acts as a spiritual port of the Python Instructor library, abstracting the complexity of JSON schema generation. Instead, it uses Elixir's Ecto schemas, including @llm_doc attributes for LLM descriptions and validate_changeset/1 functions for validation rules. The use Instructor macro integrates these schemas, allowing Instructor.chat_completion/1 to request structured responses directly mapped to Ecto schemas. The max_retries parameter facilitates automatic iterative correction of LLM output based on validation failures.

Quick Start & Requirements

Highlighted Details

  • Supports OpenAI, Anthropic, Groq, Ollama, Gemini, vLLM, and llama.cpp.
  • Leverages Ecto schemas and validations for LLM output structuring and validation.
  • Automatic retries for correcting LLM output based on Ecto changeset validations.
  • Eliminates the need for manual JSON schema definition.

Maintenance & Community

  • Project appears to be maintained by a single author, thmsmlr.
  • No explicit community links (Discord/Slack) or roadmap are provided in the README.

Licensing & Compatibility

  • The README does not explicitly state a license. Based on typical open-source Elixir projects, it is likely MIT or Apache 2.0, but this requires verification.
  • Compatible with Elixir applications. Commercial use depends on the underlying LLM provider's terms and the project's license.

Limitations & Caveats

The library is in its early stages (v0.1.0), indicating potential for breaking changes and missing features. The lack of explicit licensing information could be a concern for commercial adoption.

Health Check
Last Commit

3 months ago

Responsiveness

1+ week

Pull Requests (30d)
0
Issues (30d)
0
Star History
7 stars in the last 30 days

Explore Similar Projects

Starred by Marc Klingen Marc Klingen(Cofounder of Langfuse), John Resig John Resig(Author of jQuery; Chief Software Architect at Khan Academy), and
2 more.

zod-gpt by dzhng

0%
625
SDK for structured JSON output from LLMs, validated via Zod schemas
Created 2 years ago
Updated 1 year ago
Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Kevin Hou Kevin Hou(Head of Product Engineering at Windsurf), and
6 more.

TypeChat by microsoft

0.1%
9k
Library for building natural language interfaces using types
Created 2 years ago
Updated 2 months ago
Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Jerry Liu Jerry Liu(Cofounder of LlamaIndex), and
1 more.

sparrow by katanaml

0.1%
5k
Data processing & instruction calling tool using ML, LLM, and Vision LLM
Created 3 years ago
Updated 1 day ago
Feedback? Help us improve.