mirror of
https://github.com/mark3labs/kit.git
synced 2026-06-14 03:30:26 +00:00
82cbf1d457
Relocate SDK usage examples to the top-level examples directory alongside extension examples for better discoverability. Add README for the SDK examples directory.
42 lines
783 B
Go
42 lines
783 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
kit "github.com/mark3labs/kit/pkg/kit"
|
|
)
|
|
|
|
func main() {
|
|
ctx := context.Background()
|
|
|
|
// Create Kit with environment variable for API key
|
|
// Expects ANTHROPIC_API_KEY or appropriate provider key to be set
|
|
host, err := kit.New(ctx, &kit.Options{
|
|
Quiet: true, // Suppress debug output for scripting
|
|
})
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer func() { _ = host.Close() }()
|
|
|
|
// Process command line arguments
|
|
if len(os.Args) < 2 {
|
|
fmt.Println("Usage: go run main.go \"your prompt here\"")
|
|
os.Exit(1)
|
|
}
|
|
|
|
prompt := os.Args[1]
|
|
|
|
// Send prompt and get response
|
|
response, err := host.Prompt(ctx, prompt)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
// Output only the response (useful for piping)
|
|
fmt.Println(response)
|
|
}
|