hello

command
v2.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Hello World Example

The simplest SDK example - open a conversation and send a message.

What You'll Learn

  • Opening a conversation from a pack file with sdk.Open()
  • Setting template variables with SetVar()
  • Sending messages with Send()
  • Multi-turn conversation context

Prerequisites

  • Go 1.26+
  • An API key for one of: OpenAI, Anthropic, or Google

Running the Example

The pack does not name a provider — the SDK detects one from the environment, so any of these works:

export OPENAI_API_KEY=your-key       # uses gpt-4o
# or
export ANTHROPIC_API_KEY=your-key
# or
export GOOGLE_API_KEY=your-key

go run .

Code Overview

// Open a conversation from a pack file
conv, err := sdk.Open("./hello.pack.json", "chat")
if err != nil {
    log.Fatal(err)
}
defer conv.Close()

// Set template variables (substituted in system prompt)
conv.SetVar("user_name", "World")

// Send a message and get a response
ctx := context.Background()
resp, err := conv.Send(ctx, "Say hello!")
fmt.Println(resp.Text())

// Context is maintained across turns
resp, _ = conv.Send(ctx, "What's my name?")
fmt.Println(resp.Text())  // Remembers "World"

Pack File Structure

The hello.pack.json defines:

  • Prompt: A friendly assistant with {{user_name}} template variable

It deliberately does not pin a provider, so the example runs against whichever of OpenAI / Anthropic / Google you have a key for.

{
  "prompts": {
    "chat": {
      "system_template": "You are a friendly assistant. The user's name is {{user_name}}."
    }
  }
}

Key Concepts

  1. Pack-First Design - All configuration lives in the pack file
  2. Template Variables - Use {{variable}} in prompts, set with SetVar()
  3. Conversation Context - Messages are remembered across Send() calls
  4. Resource Cleanup - Always defer conv.Close()

Next Steps

Documentation

Overview

Package main demonstrates the simplest PromptKit SDK usage.

This example shows:

  • Opening a conversation from a pack file
  • Sending a simple message
  • Reading the response

Run with:

export OPENAI_API_KEY=your-key
go run .

Jump to

Keyboard shortcuts

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