Dsxir.Primitives.History (dsxir v0.1.0)

Copy Markdown

Multi-turn conversation value type. Bind one to a signature input field whose Zoi type is Dsxir.Primitives.History; the chat adapter materializes the conversation into the prompt sequence.

Distinct from Dsxir.History (the inspect_history developer tool). The name overlap mirrors DSPy's dspy.History (the value type) and dspy.inspect_history (the debug helper).

Entries are plain maps to keep the struct cheap and serializable:

%Dsxir.Primitives.History{
  messages: [
    %{role: :user, content: "What is the capital of France?"},
    %{role: :assistant, content: "Paris."}
  ]
}

Summary

Functions

Build a new conversation, optionally seeded with messages.

Append a message with the given role and content to the conversation.

Materialize as a list of %Sycophant.Message{} for adapter consumption.

Types

message()

@type message() :: %{role: role(), content: String.t()}

role()

@type role() :: :system | :user | :assistant

t()

@type t() :: %Dsxir.Primitives.History{messages: [message()]}

Functions

new(messages \\ [])

@spec new([message()]) :: t()

Build a new conversation, optionally seeded with messages.

push(h, role, content)

@spec push(t(), role(), String.t()) :: t()

Append a message with the given role and content to the conversation.

to_messages(history)

@spec to_messages(t()) :: [Sycophant.Message.t()]

Materialize as a list of %Sycophant.Message{} for adapter consumption.