Urchin.Prompt (Urchin v0.2.0)

Copy Markdown View Source

A prompt definition advertised via prompts/list, plus helpers for building the PromptMessage list returned by prompts/get.

Mirrors the Prompt, PromptArgument and PromptMessage types from the schema.

Summary

Functions

Builds a PromptMessage with the assistant role.

Builds a PromptMessage with an explicit role ("user" or "assistant").

Builds a prompt from a keyword list or map of attributes.

Serializes the prompt to its JSON-RPC wire shape.

Builds a PromptMessage with the user role.

Types

t()

@type t() :: %Urchin.Prompt{
  arguments: [Urchin.Prompt.Argument.t()] | nil,
  description: String.t() | nil,
  icons: [map()] | nil,
  meta: map() | nil,
  name: String.t(),
  title: String.t() | nil
}

Functions

assistant_message(content)

@spec assistant_message(Urchin.Content.block()) :: map()

Builds a PromptMessage with the assistant role.

message(role, content)

@spec message(String.t(), Urchin.Content.block()) :: map()

Builds a PromptMessage with an explicit role ("user" or "assistant").

new(attrs)

@spec new(keyword() | map()) :: t()

Builds a prompt from a keyword list or map of attributes.

to_map(prompt)

@spec to_map(t()) :: map()

Serializes the prompt to its JSON-RPC wire shape.

user_message(content)

@spec user_message(Urchin.Content.block()) :: map()

Builds a PromptMessage with the user role.