claude

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 6 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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseSystemPrompt

func ParseSystemPrompt(raw json.RawMessage) (string, error)

Types

type ClaudeRequest

type ClaudeRequest struct {
	Model              string          `json:"model"`
	Messages           []Message       `json:"messages"`
	System             json.RawMessage `json:"system,omitempty"`
	Tools              []Tool          `json:"tools,omitempty"`
	ToolChoice         json.RawMessage `json:"tool_choice,omitempty"`
	Stream             bool            `json:"stream"`
	MaxTokens          *int            `json:"max_tokens,omitempty"`
	StopSequences      []string        `json:"stop_sequences,omitempty"`
	Temperature        *float64        `json:"temperature,omitempty"`
	TopP               *float64        `json:"top_p,omitempty"`
	TopK               *int            `json:"top_k,omitempty"`
	Thinking           *ThinkingConfig `json:"thinking,omitempty"`
	OutputConfig       *OutputConfig   `json:"output_config,omitempty"`
	Metadata           *Metadata       `json:"metadata,omitempty"`
	ConversationID     string          `json:"conversation_id,omitempty"`
	PreviousResponseID string          `json:"previous_response_id,omitempty"`
}

type ClaudeResponse

type ClaudeResponse struct {
	ID             string         `json:"id"`
	Type           string         `json:"type"`
	Role           string         `json:"role"`
	Model          string         `json:"model"`
	Content        []ContentBlock `json:"content"`
	StopReason     string         `json:"stop_reason"`
	StopSequence   *string        `json:"stop_sequence,omitempty"`
	Usage          *Usage         `json:"usage,omitempty"`
	ConversationID string         `json:"conversation_id,omitempty"`
}

type ContentBlock

type ContentBlock struct {
	Type      string                  `json:"type"`
	Text      string                  `json:"text,omitempty"`
	Thinking  string                  `json:"thinking,omitempty"`
	Signature string                  `json:"signature,omitempty"`
	ID        string                  `json:"id,omitempty"`
	Name      string                  `json:"name,omitempty"`
	Input     *map[string]interface{} `json:"input,omitempty"`
	ToolUseID string                  `json:"tool_use_id,omitempty"`
	Content   json.RawMessage         `json:"content,omitempty"`
	IsError   *bool                   `json:"is_error,omitempty"`
	Source    *ImageSource            `json:"source,omitempty"`
	Data      string                  `json:"data,omitempty"`
}

func ParseMessageContent

func ParseMessageContent(raw json.RawMessage) ([]ContentBlock, string, error)

type ImageSource

type ImageSource struct {
	Type      string `json:"type"`
	MediaType string `json:"media_type"`
	Data      string `json:"data"`
}

type Message

type Message struct {
	Role    string          `json:"role"`
	Content json.RawMessage `json:"content"`
}

type Metadata

type Metadata struct {
	UserID string `json:"user_id,omitempty"`
}

type OutputConfig

type OutputConfig struct {
	Effort string `json:"effort,omitempty"`
}

OutputConfig 表示 Claude 输出强度配置

type StreamProcessor

type StreamProcessor struct {
	// contains filtered or unexported fields
}

StreamProcessor 将规范事件编码为 Claude SSE

func NewStreamProcessor

func NewStreamProcessor(model string, writer io.Writer, messageIDs ...string) *StreamProcessor

NewStreamProcessor 创建 Claude SSE 编码器

func (*StreamProcessor) EmitError

func (p *StreamProcessor) EmitError(err error) error

EmitError 输出 Claude 流式错误

func (*StreamProcessor) EmitThinking

func (p *StreamProcessor) EmitThinking(thinking string, signature string) error

EmitThinking 输出带代理签名的完整思考块

func (*StreamProcessor) EmitToolCall

func (p *StreamProcessor) EmitToolCall(id string, name string, arguments json.RawMessage) error

EmitToolCall 输出完整 Claude 工具调用块

func (*StreamProcessor) Finish

func (p *StreamProcessor) Finish(stopReason string) error

Finish 完成 Claude SSE 消息

func (*StreamProcessor) FinishThinking

func (p *StreamProcessor) FinishThinking(signature string) error

FinishThinking 完成当前思考块并输出签名

func (*StreamProcessor) MessageID

func (p *StreamProcessor) MessageID() string

MessageID 返回当前 Claude 消息标识

func (*StreamProcessor) ProcessEvent

func (p *StreamProcessor) ProcessEvent(event gemini.Event) error

ProcessEvent 消费一个 Gemini 规范事件

func (*StreamProcessor) SetConversationID

func (p *StreamProcessor) SetConversationID(conversationID string)

SetConversationID 设置最终消息携带的显式会话标识

func (*StreamProcessor) SetModel

func (p *StreamProcessor) SetModel(model string)

SetModel 设置校验后的实际模型

type StreamingState

type StreamingState struct {
	MessageID        string
	Model            string
	MessageStartSent bool
	MessageStopSent  bool
	BlockIndex       int
	CurrentBlockType string
	Usage            *gemini.Usage
	ConversationID   string
}

StreamingState 保存 Claude SSE 的输出状态

func NewStreamingState

func NewStreamingState(model string) *StreamingState

NewStreamingState 创建 Claude SSE 状态

type ThinkingConfig

type ThinkingConfig struct {
	Type         string `json:"type"`
	BudgetTokens *int   `json:"budget_tokens,omitempty"`
}

type Tool

type Tool struct {
	Type        *string         `json:"type,omitempty"`
	Name        *string         `json:"name,omitempty"`
	Description *string         `json:"description,omitempty"`
	InputSchema json.RawMessage `json:"input_schema,omitempty"`
}

func (Tool) IsWebSearch

func (t Tool) IsWebSearch() bool

type Usage

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

Jump to

Keyboard shortcuts

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