interop

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 5 Imported by: 0

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

func FromLangChain(data []byte) (*prompt.Template, error)

FromLangChain parses LangChain's PromptTemplate JSON shape into a prompt-diff template.

func FromLlamaIndex

func FromLlamaIndex(data []byte) (*prompt.Template, error)

FromLlamaIndex parses LlamaIndex'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

func ToLangChain(t *prompt.Template) LangChain

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL