instructor_ex  by thmsmlr

Elixir library for structured LLM outputs

created 1 year ago
734 stars

Top 48.1% 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

1 month ago

Responsiveness

Inactive

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

Explore Similar Projects

Starred by John Resig John Resig(Author of jQuery; Chief Software Architect at Khan Academy), Travis Fischer Travis Fischer(Founder of Agentic), and
1 more.

instructor-js by 567-labs

0%
738
Typescript tool for structured extraction from LLMs
created 1 year ago
updated 6 months ago
Feedback? Help us improve.