types

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatResponse

type ChatResponse struct {
	Content   string     `json:"content"`
	ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}

type ContentPart

type ContentPart struct {
	Type     string    `json:"type"` // "text", "image_url", "video_url", "audio_url", "file"
	Text     string    `json:"text,omitempty"`
	ImageURL *MediaURL `json:"image_url,omitempty"`
	VideoURL *MediaURL `json:"video_url,omitempty"`
	AudioURL *MediaURL `json:"audio_url,omitempty"`
	File     *FileInfo `json:"file,omitempty"`
}

ContentPart represents a part of a multimodal message content

type FileInfo

type FileInfo struct {
	Name     string `json:"name,omitempty"`
	MimeType string `json:"mime_type,omitempty"`
	URL      string `json:"url,omitempty"`
	Size     int64  `json:"size,omitempty"`
}

FileInfo represents file metadata

type Function

type Function struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

type MediaURL

type MediaURL struct {
	URL    string `json:"url"`
	Detail string `json:"detail,omitempty"` // "auto", "low", "high" (for images)
}

MediaURL represents a URL with optional detail level (for images)

type Message

type Message struct {
	ID      string `json:"id,omitempty"`
	Role    string `json:"role"`
	Content string `json:"content"`
	// 多模态内容,非空时优先于 Content
	ContentParts []ContentPart `json:"content_parts,omitempty"`
	ChannelID    string        `json:"channel_id,omitempty"`
	From         string        `json:"from,omitempty"`
	ToolCalls    []ToolCall    `json:"tool_calls,omitempty"`
	ToolCallID   string        `json:"tool_call_id,omitempty"` // Required for tool role messages
}

type ToolCall

type ToolCall struct {
	ID        string                 `json:"id"`
	Name      string                 `json:"name"`
	Arguments map[string]interface{} `json:"arguments"`
	// 兼容旧代码
	Type     string   `json:"type,omitempty"`
	Function Function `json:"function,omitempty"`
}

func (*ToolCall) GetToolName added in v0.4.7

func (tc *ToolCall) GetToolName() string

GetToolName returns the tool name, trying Function.Name first, then falling back to Name. This handles inconsistencies across different providers where some set Function.Name and others set only the top-level Name field.

func (*ToolCall) Normalize added in v0.4.7

func (tc *ToolCall) Normalize()

Normalize ensures both Function.Name and Name are populated for consistency. After normalization, GetToolName() will return the correct value regardless of which field the provider originally set.

Jump to

Keyboard shortcuts

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