Make backends extensible without editing core stdlib internals

Đang mở
#1,467 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Start by reading mellea/stdlib/session.py and mellea/stdlib/start_backend.py, then trace backend_name_to_class and _resolve_model_id_str. Decide how registration, typing, and model defaults should work; done means an external backend can be added without changing the core unions, built-in overloads remain precise, and the docs explain authoring and use.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area/backends help wanted needs-design p2

Problem

Adding a backend today requires editing core stdlib internals in several places at once:

  • the Literal[...] backend-name unions on start_session (mellea/stdlib/session.py) and start_backend (mellea/stdlib/start_backend.py)
  • the if/elif dispatch in backend_name_to_class
  • the backend→model-attr map in _resolve_model_id_str
  • a block of @overloads per backend in start_backend

That means every new provider (e.g. #1426) is a change to core union types and dispatch, and the ongoing maintenance (e.g. provider model catalogs drifting over time) falls on core maintainers. It doesn't scale, and it sets the bar too high for what is often just a provider-convenience wrapper.

Goal

A registration mechanism so a backend can be added from outside stdlib without editing the core union types or dispatch.

Scope / open questions

  • Registration API: how are backend names/aliases registered? A registry dict, a decorator, or Python entry points via pyproject.toml. Entry points would let providers ship backends in separate packages.
  • Typing: start_backend currently relies on Literal + @overload for precise return types. Decide the typing contract for dynamically-registered backends (likely a generic fallback overload, with precise overloads kept only for built-ins).
  • Model-id resolution: _resolve_model_id_str hardcodes a backend→attr map. A registered backend needs to declare its own model-attr / default-model behavior.
  • Docs: a short "writing a backend" guide, plus a note in the core docs on how to use said backends.

Acceptance

  • A new provider backend can be added with no edits to session.py / start_backend.py core unions.
  • Built-in backends keep their precise typed overloads.
  • Docs cover both authoring and using a contributed backend.
Ngôn ngữ chính
Python
Star
1.8k
Fork
161
Merge trung bình
4 ngày 3 giờ
Pull request đã merge (30 ngày)
45

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của generative-computing/mellea

Tất cả issue của generative-computing/mellea

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.