Documentation
¶
Overview ¶
Package interop converts between prompt-diff's .prompt format and the JSON prompt-template shapes used by LangChain and LlamaIndex, so prompts authored in (or exported from) those frameworks can be diffed, evaluated, and compressed through prompt-diff too.
Both frameworks serialize templates as an f-string body ("{var}") rather than prompt-diff's "{{ var }}" — conversion rewrites between the two. This targets the common single-template save/load shape (LangChain's PromptTemplate.save()/load_prompt(), LlamaIndex's PromptTemplate); it does not cover multi-message ChatPromptTemplate or provider-specific schema variants, since those aren't a single stable JSON shape across versions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromLangChain ¶
FromLangChain parses LangChain's PromptTemplate JSON shape into a prompt-diff template.
Types ¶
type LangChain ¶
type LangChain struct {
InputVariables []string `json:"input_variables"`
Template string `json:"template"`
TemplateFormat string `json:"template_format,omitempty"`
Type string `json:"_type,omitempty"`
}
LangChain is the PromptTemplate.save()/load_prompt() JSON shape.
func ToLangChain ¶
ToLangChain converts a prompt-diff template to LangChain's PromptTemplate JSON shape.
type LlamaIndex ¶
type LlamaIndex struct {
Template string `json:"template"`
TemplateVars []string `json:"template_vars"`
}
LlamaIndex is the PromptTemplate JSON shape (template + declared vars).
func ToLlamaIndex ¶
func ToLlamaIndex(t *prompt.Template) LlamaIndex
ToLlamaIndex converts a prompt-diff template to LlamaIndex's PromptTemplate JSON shape.