models

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RoleUser represents a user message. A message with this role would only contain text or resource content.
	RoleUser Role = "user"
	// RoleAssistant represents an assistant message. A message with this role would contain
	// all types of content but resource.
	RoleAssistant Role = "assistant"

	// ContentTypeText represents text content.
	ContentTypeText ContentType = "text"
	// ContentTypeResource represents a resource content.
	ContentTypeResource ContentType = "resource"
	// ContentTypeCallTool represents a call to a tool.
	ContentTypeCallTool ContentType = "call_tool"
	// ContentTypeToolResult represents the result of a tool call.
	ContentTypeToolResult ContentType = "tool_result"
)

Variables

This section is empty.

Functions

func RenderContents

func RenderContents(contents []Content) (string, error)

RenderContents renders contents into a markdown string.

Types

type Chat

type Chat struct {
	ID    string
	Title string
}

Chat represents a conversation container in the chat system. It provides basic identification and labeling capabilities for organizing message threads.

type Content

type Content struct {
	Type ContentType

	// Text would be filled if Type is ContentTypeText.
	Text string

	// ResourceContents would be filled if Type is ContentTypeResource.
	ResourceContents []mcp.ResourceContents

	// ToolName would be filled if Type is ContentTypeCallTool.
	ToolName string
	// ToolInput would be filled if Type is ContentTypeCallTool.
	ToolInput json.RawMessage

	// ToolResult would be filled if Type is ContentTypeToolResult. The value would be either tool result or error.
	ToolResult json.RawMessage

	// CallToolID would be filled if Type is ContentTypeCallTool or ContentTypeToolResult.
	CallToolID string
	// CallToolFailed is a flag indicating if the call tool failed.
	// This flag would be set to true if the call tool failed and Type is ContentTypeToolResult.
	CallToolFailed bool
}

Content is a message content with its type.

func (Content) String

func (c Content) String() string

String returns a string representation of the Content.

The reason for this function is to make sure the json.RawMessage fields of c is rendered as a string, make it easier to debug.

type ContentType

type ContentType string

ContentType represents the type of content in messages.

type Message

type Message struct {
	ID        string
	Role      Role
	Contents  []Content
	Timestamp time.Time
}

Message represents an individual communication entry within a chat. It contains the core components of a chat message including its unique identifier, the participant's role, the actual content, and the precise time when the message was created.

type Role

type Role string

Role represents the role of a message participant.

Jump to

Keyboard shortcuts

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