Prompt "profiles": serializable bundles of system prompt + tools + schema

Đang mở
#349 0 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 1 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
Cần làm rõ
Mức độ hoạt động
Ít trao đổi
Công nghệ
python
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Bắt đầu bằng cách đọc chatlas/_interpolate.py và chatlas/_chat.py, đặc biệt là interpolate(), chat_structured(), set_model_params() và các phương thức công cụ. Giải quyết các câu hỏi còn bỏ ngỏ về phạm vi tuần tự hóa và điểm bắt đầu của việc tạo, sau đó xác minh rằng một Profile có thể giữ nguyên system_prompt, data_model và params qua một round-trip, đồng thời tạo một Chat với nội suy. Việc đóng gói công cụ nằm ngoài các tiêu chí hoàn thành ban đầu.

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

Mô tả

ai-triage:needs-review enhancement

Motivation

Simon Willison's llm has templates: YAML bundles of system prompt, prompt fragments, model options, tools, and schemas, invoked via llm -t name. This lets users package up a reusable "agent config" and share it as a file. chatlas has the pieces (interpolate()/interpolate_file() in chatlas/_interpolate.py, register_tool()/set_tools() and chat_structured(data_model=...) in chatlas/_chat.py, set_model_params()), but nothing that bundles them into one serializable, shareable unit. Pydantic AI has a related but narrower idea in reusable Agent instances, though those aren't declaratively serializable either.

Proposed approach

Introduce a Profile object — a thin, serializable bundle of the inputs to a Chat, not a new execution engine:

from chatlas import Profile, ChatOpenAI

profile = Profile(
    system_prompt="You are a terse SQL assistant.\n{{ extra_instructions }}",  # interpolate() template
    data_model="myapp.schemas.SqlAnswer",  # optional, import-path string
    params={"temperature": 0.2},
)

chat = profile.create_chat(ChatOpenAI, variables={"extra_instructions": "Always cite the table."})
  • Profile.from_yaml(path) / Profile.to_yaml(path) (or TOML) for round-tripping.
  • system_prompt is rendered through interpolate() at create_chat() time, so the same template mechanics/variable-inference already in _interpolate.py apply.
  • data_model and params map directly onto chat_structured(data_model=...) and set_model_params().
  • Tools are the hard part. Functions aren't YAML-serializable. Two honest options: (a) store an import path string ("myapp.tools:lookup_price") resolved via importlib at load time — simple, but ties the profile to code being importable in the same environment; (b) require a small in-app registry mapping names to callables that the profile references by name only. Given this complexity, the proposal is to ship the non-tool subset first (system prompt + data_model + params, dumpable/loadable), and treat tool bundling as a stretch goal / separate follow-up once the serialization approach is validated with users.

Alternatives / prior art

  • ellmer has interpolate() (string-only) and no bundling concept beyond that — this would be new territory for both projects, so getting the design right in chatlas first and porting later (as usual) seems reasonable.
  • Do nothing: users keep hand-rolling a dict/module of prompt+schema+params, which works but isn't shareable as a file the way llm's templates are.
  • A pure-YAML "recipe" that only ever produces kwargs for ChatAuto(**kwargs) (no new class) is a lighter-weight alternative worth considering.

Open questions

  • Is create_chat() the right entry point, or should this be a Chat*(profile=...) constructor kwarg instead (per the original ask)?
  • YAML vs TOML vs both?
  • Should Profile also carry the provider/model string (à la ChatAuto's "provider/model"), or stay provider-agnostic and let the caller pick the Chat* class?

Drafted from a competitive review of llm / Pydantic AI / LangChain / LiteLLM (July 2026); filed via Claude Code on behalf of @cpsievert.

Ngôn ngữ chính
Python
Star
179
Fork
32
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
10

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 posit-dev/chatlas

Tất cả issue của posit-dev/chatlas

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.