Documentation
¶
Index ¶
Constants ¶
View Source
const (
User, Assistant MessageRole = "user", "assistant"
Opus, Sonnet, Haiku Model = "claude-3-opus-20240229", "claude-3-sonnet-20240229", "claude-3-haiku-20240307"
EndTurn, MaxTokens, StopSequence StopReason = "end_turn", "max_tokens", "stop_sequence"
Text, ToolUse, MessageResp, ToolResult ResponseType = "text", "tool_use", "message", "tool_result"
)
View Source
const MESSAGES_URL = "https://api.anthropic.com/v1/messages"
# CLAUDE API TYPES - String literals for api-specific values - Structs for interacting with the Messages API - Methods for interacting with the Messages API
View Source
const SYS_PROMPT = `` /* 914-byte string literal not displayed */
# CONVERSATION Functions and logic for managing the flow of conversation with Claude
Variables ¶
View Source
var ToolMap = map[string]useTool{}
Functions ¶
This section is empty.
Types ¶
type Content ¶
type Content struct {
Type ResponseType `json:"type"`
// text response
Text string `json:"text,omitempty"`
// tool_use response
Id string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Input map[string]any `json:"input,omitempty"`
// tool_response user response
ToolUseId string `json:"tool_use_id,omitempty"`
Content string `json:"content,omitempty"`
}
type Conversation ¶
type Conversation []Message
type Message ¶
type Message struct {
Role MessageRole `json:"role"`
Content []Content `json:"content"`
}
type MessageRole ¶
type MessageRole string
type Request ¶
type Request struct {
Model Model `json:"model"`
Messages Conversation `json:"messages"`
MaxTokens int `json:"max_tokens"`
System string `json:"system,omitempty"`
Tools []Tool `json:"tools,omitempty"`
}
type Response ¶
type Response struct {
ID string `json:"id"`
Type ResponseType `json:"type"`
Role MessageRole `json:"role"`
Content []Content `json:"content"`
Model Model `json:"model"`
StopReason StopReason `json:"stop_reason"`
StopSequence string `json:"stop_sequence"`
Usage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
} `json:"usage"`
}
type ResponseType ¶
type ResponseType string
type StopReason ¶
type StopReason string
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema inputSchema `json:"input_schema"`
}
# TOOLS Tools that Claude can use to take actions on the user's behalf They are specified in the `tools` directory as JSON files The name of each tool is mapped to a function
func LoadToolFromJSONFile ¶
func LoadToolsFromDirectory ¶
Click to show internal directories.
Click to hide internal directories.