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

Aperta
#349 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Tranquilla
Stack tecnologico
python

Direzione di ricerca

Inizia leggendo chatlas/_interpolate.py e chatlas/_chat.py, in particolare interpolate(), chat_structured(), set_model_params() e i metodi degli strumenti. Risolvi le questioni aperte relative all'ambito della serializzazione e al punto di ingresso per la creazione, quindi verifica che un Profile possa mantenere il proprio system_prompt, data_model e params tramite un round-trip e creare un Chat con interpolazione. Il raggruppamento degli strumenti è al di fuori dei criteri iniziali di completamento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
179
Fork
32
Merge medio
1g 3h
PR unite (30g)
10

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di posit-dev/chatlas

Tutte le issue di posit-dev/chatlas

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.