In the Blades framework, Prompt is the core component for interacting with large language models (LLMs). It represents a sequence of messages exchanged between the user and the assistant, supporting multiple types of messages (system messages, user messages, assistant messages) as well as templating functionality, enabling developers to build dynamic and context-aware AI applications.
Blades supports multiple message types, each with a specific role:
// Message represents a single message in a conversation.type Message struct { ID string `json:"id"` Role Role `json:"role"` Parts []Part `json:"parts"` Author string `json:"author"` InvocationID string `json:"invocationId,omitempty"` Status Status `json:"status"` FinishReason string `json:"finishReason,omitempty"` TokenUsage TokenUsage `json:"tokenUsage,omitempty"` Metadata map[string]any `json:"metadata,omitempty"`}// TextPart is plain text content.type TextPart struct { Text string `json:"text"`}The most basic way to create a Prompt is by directly specifying the message content:
input := blades.UserMessage("What is the capital of France?")System instructions can be defined through the Agent:
model := openai.NewModel("gpt-5", openai.Config{ APIKey: os.Getenv("OPENAI_API_KEY"),})agent, err := blades.NewAgent( "Basic Agent", blades.WithModel(model), blades.WithInstruction("You are a helpful assistant that provides detailed and accurate information."),)model := openai.NewModel("gpt-5", openai.Config{ APIKey: os.Getenv("OPENAI_API_KEY"),})agent, err := blades.NewAgent( "Instructions Agent", blades.WithModel(model), blades.WithInstruction("Respond as a {{.style}}."),)if err != nil { log.Fatal(err)}// Create a new session with state variablessession := blades.NewSession(map[string]any{ "style": "robot",})input := blades.UserMessage("Tell me a joke.")runner := blades.NewRunner(agent, blades.WithSession(session))message, err := runner.Run(context.Background(), input)if err != nil { panic(err)}log.Println(session.State())log.Println(message.Text())