code.oscarkilo.com/klex-git/api/messages.go

..
api.go
datasets.go
f.go
funcs.go
messages.go
pipelines.go
worker.go
package api

type ChatMessage struct {
  Role    string         `json:"role"`
  Content []ContentBlock `json:"content"`
}

// MessageRequest is generalizes across OpenAI, Anthropic, etc.
type MessagesRequest struct {
  Model       string        `json:"model"`
  Messages    []ChatMessage `json:"messages"`
  MaxTokens   int           `json:"max_tokens"`
  System      string        `json:"system,omitempty"`
  Temperature float64       `json:"temperature"`
  Tools       []Tool        `json:"tools,omitempty"`
}

type ContentBlock struct {
  // Type is "text", "image", "tool_use", or "tool_result".
  Type string           `json:"type"`

  // Text is for Type="text"
  Text string           `json:"text,omitempty"`

  // Source is for Type="image"
  Source *ContentSource `json:"source,omitempty"`

  // Id, Name, and Input are for Type="tool_use".
  ID     string         `json:"id,omitempty"`
  Name   string         `json:"name,omitempty"`
  Input  interface{}    `json:"input,omitempty"`
  Output string         `json:"output,omitempty"`
}

type ContentSource struct {
  // Type can only be "base64".
  Type string `json:"type"`

  // MediaType can be one of:
  // - "image/jpeg",
  // - "image/png",
  // - "image/gif", or
  // - "image/webp".
  MediaType string `json:"media_type,omitempty"`

  Data string `json:"data,omitempty"`
}

type Usage struct {
  InputTokens               int  `json:"input_tokens,omitempty"`
  CacheCreationInputTokens  *int `json:"cache_creation_input_tokens,omitempty"`
  CacheReadInputTokens      *int `json:"cache_read_input_tokens,omitempty"`
  OutputTokens              int  `json:"output_tokens,omitempty"`
}

type ErrorResponse struct {
  Type    string `json:"type"`
  Message string `json:"message"`
}

type MessagesResponse struct {
  Id           string         `json:"id"`
  Type         string         `json:"type"`
  Role         string         `json:"role"`
  Content      []ContentBlock `json:"content"`
  Model        string         `json:"model"`
  StopReason   *string        `json:"stop_reason,omitempty"`
  StopSequence *string        `json:"stop_sequence,omitempty"`
  Usage        Usage          `json:"usage"`
  Error        *ErrorResponse `json:"error,omitempty"`
}

type Tool struct {
  Type     string        `json:"type"`
  Function *ToolFunction `json:"function"`
}

type ToolFunction struct {
  Name        string      `json:"name"`
  Description string      `json:"description"`
  InputSchema interface{} `json:"input_schema"`
}