agents

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentCardToJSONString added in v0.0.7

func AgentCardToJSONString(agentCard AgentCard) (string, error)

func DisableLogging added in v0.0.5

func DisableLogging()

func EnableLogging added in v0.0.5

func EnableLogging(level LogLevel)

func GetBytesBody added in v0.0.1

func GetBytesBody(request *http.Request) []byte

func SetGlobalLogger added in v0.0.5

func SetGlobalLogger(logger *Logger)

func TaskRequestToJSONString added in v0.0.7

func TaskRequestToJSONString(taskRequest TaskRequest) (string, error)

func TaskResponseToJSONString added in v0.0.7

func TaskResponseToJSONString(taskResponse TaskResponse) (string, error)

Types

type A2AServerConfig added in v0.0.7

type A2AServerConfig struct {
	Port string
}

type AfterAlternativeToolsCompletionHandler added in v0.0.5

type AfterAlternativeToolsCompletionHandler func(*AlternativeToolsCompletionContext)

Handler types for before and after completion events

type AfterChatCompletionHandler added in v0.0.5

type AfterChatCompletionHandler func(*ChatCompletionContext)

Handler types for before and after completion events

type AfterChatCompletionStreamHandler added in v0.0.5

type AfterChatCompletionStreamHandler func(*ChatCompletionStreamContext)

Handler types for before and after completion events

type AfterToolsCompletionHandler added in v0.0.5

type AfterToolsCompletionHandler func(*ToolsCompletionContext)

Handler types for before and after completion events

type Agent

type Agent struct {
	Name            string
	Params          openai.ChatCompletionNewParams
	EmbeddingParams openai.EmbeddingNewParams

	//Store           rag.MemoryVectorStore
	Store rag.VectorStore

	Metadata map[string]any
	// contains filtered or unexported fields
}

func NewAgent

func NewAgent(name string, options ...AgentOption) (*Agent, error)

NewAgent creates a new Agent instance with the provided options. It applies all the options to the Agent and returns it. If any option sets an error, it returns the error instead of the Agent. The Agent can be configured with various options such as DMR client, parameters, tools, and memory.

func (*Agent) A2AServer added in v0.0.7

func (agent *Agent) A2AServer() *http.ServeMux

A2AServer returns the A2A server mux

func (*Agent) A2AServerConfig added in v0.0.7

func (agent *Agent) A2AServerConfig() A2AServerConfig

func (*Agent) AddAssistantMessage added in v0.0.5

func (agent *Agent) AddAssistantMessage(content string)

func (*Agent) AddSystemMessage added in v0.0.5

func (agent *Agent) AddSystemMessage(content string)

func (*Agent) AddTool added in v0.0.5

func (agent *Agent) AddTool(tool openai.ChatCompletionToolParam)

func (*Agent) AddToolMessage added in v0.0.6

func (agent *Agent) AddToolMessage(toolCallID, content string)

func (*Agent) AddToolToMCPServer

func (agent *Agent) AddToolToMCPServer(tool mcp.Tool, handler server.ToolHandlerFunc)

func (*Agent) AddTools added in v0.0.5

func (agent *Agent) AddTools(tools []openai.ChatCompletionToolParam)

func (*Agent) AddUserMessage added in v0.0.5

func (agent *Agent) AddUserMessage(content string)

func (*Agent) AlternativeToolsCompletion added in v0.0.9

func (agent *Agent) AlternativeToolsCompletion(ctx context.Context) ([]openai.ChatCompletionMessageToolCall, error)

NOTE: this is subject to change in the future, as we are still experimenting with the best way to handle tool calls detection.

func (*Agent) ChatCompletion

func (agent *Agent) ChatCompletion(ctx context.Context) (string, error)

ChatCompletion handles the chat completion request using the DMR client. It sends the parameters set in the Agent and returns the response content or an error. It is a synchronous operation that waits for the completion to finish.

func (*Agent) ChatCompletionStream

func (agent *Agent) ChatCompletionStream(ctx context.Context, callBack func(self *Agent, content string, err error) error) (string, error)

ChatCompletionStream handles the chat completion request using the DMR client in a streaming manner. It takes a callback function that is called for each chunk of content received. The callback function receives the Agent instance, the content of the chunk, and any error that occurred. It returns the accumulated response content and any error that occurred during the streaming process. The callback function should return an error if it wants to stop the streaming process.

func (*Agent) ClearMessages added in v0.0.6

func (agent *Agent) ClearMessages()

func (*Agent) CreateAndSaveEmbeddingFromChunks added in v0.0.3

func (agent *Agent) CreateAndSaveEmbeddingFromChunks(ctx context.Context, chunks []string) ([]rag.VectorRecord, error)

CreateAndSaveEmbeddingFromChunks creates embeddings from the provided text chunks and saves them to the memory vector store. It returns a slice of saved vector records and an error if any occurred. Each chunk is processed individually, creating an embedding and saving it as a vector record. This method is useful when you have multiple text chunks and want to create and save embeddings for each of them. It does not require a recordId; each vector record will be saved with a new UUID generated by the Store.Save method. If any chunk fails to create an embedding or save, the method returns an error immediately.

func (*Agent) CreateAndSaveEmbeddingFromText added in v0.0.3

func (agent *Agent) CreateAndSaveEmbeddingFromText(ctx context.Context, text string, recordId ...string) (rag.VectorRecord, error)

CreateAndSaveEmbeddingFromText creates an embedding from the provided text and saves it to the memory vector store. It returns the saved vector record and an error if any occurred. If a recordId is provided, it will be used as the ID for the vector record; otherwise, a new UUID will be generated. The text is used as the prompt for the vector record.

func (*Agent) CreateEmbeddingFromText added in v0.0.3

func (agent *Agent) CreateEmbeddingFromText(ctx context.Context, text string) (openai.Embedding, error)

CreateEmbeddingFromText creates an embedding from the provided text using the OpenAI API. It returns the embedding and an error if any occurred. If the text is empty, it returns an empty embedding and no error.

func (*Agent) ExecuteMCPStdioToolCalls

func (agent *Agent) ExecuteMCPStdioToolCalls(ctx context.Context, detectedtToolCalls []openai.ChatCompletionMessageToolCall) ([]string, error)

TODO: check what will happend if the tool does not xist ExecuteMCPStdioToolCalls executes the tool calls detected by the Agent using the MCP STDIO client.

func (*Agent) ExecuteMCPStreamableHTTPToolCalls

func (agent *Agent) ExecuteMCPStreamableHTTPToolCalls(ctx context.Context, detectedtToolCalls []openai.ChatCompletionMessageToolCall) ([]string, error)

ExecuteMCPStreamableHTTPToolCalls executes the tool calls detected by the Agent using the MCP Streamable HTTP client.

func (*Agent) ExecuteToolCalls

func (agent *Agent) ExecuteToolCalls(detectedtToolCalls []openai.ChatCompletionMessageToolCall, toolsImpl map[string]func(any) (any, error)) ([]string, error)

ExecuteToolCalls executes the tool calls detected by the Agent. QUESTION: Should I return []any instead of []string?

func (*Agent) GetLastAssistantMessage added in v0.0.6

func (agent *Agent) GetLastAssistantMessage() *openai.ChatCompletionMessageParamUnion

func (*Agent) GetLastAssistantMessageContent added in v0.0.6

func (agent *Agent) GetLastAssistantMessageContent() (string, error)

func (*Agent) GetLastUserMessage added in v0.0.6

func (agent *Agent) GetLastUserMessage() *openai.ChatCompletionMessageParamUnion

func (*Agent) GetLastUserMessageContent added in v0.0.6

func (agent *Agent) GetLastUserMessageContent() (string, error)

func (*Agent) GetMessages added in v0.0.6

func (agent *Agent) GetMessages() []openai.ChatCompletionMessageParamUnion

func (*Agent) HttpServer added in v0.0.6

func (agent *Agent) HttpServer() *http.ServeMux

func (*Agent) HttpServerConfig added in v0.0.7

func (agent *Agent) HttpServerConfig() HTTPServerConfig

func (*Agent) LoadMemoryVectorStore added in v0.0.3

func (agent *Agent) LoadMemoryVectorStore() error

LoadMemoryVectorStore loads the memory vector store from a JSON file. It reads the file, unmarshals the JSON into a MemoryVectorStore, and assigns it to the agent's Store.

func (*Agent) MCPServerConfig added in v0.0.7

func (agent *Agent) MCPServerConfig() MCPServerConfig

func (*Agent) OldAlternativeToolsCompletion added in v0.0.9

func (agent *Agent) OldAlternativeToolsCompletion(ctx context.Context) ([]openai.ChatCompletionMessageToolCall, error)

IMPORTANT: NOTE: I keep this file for reference, but I will not use it anymore. TODO: Remove this file in the future.

func (*Agent) PersistMemoryVectorStore added in v0.0.3

func (agent *Agent) PersistMemoryVectorStore() error

PersistMemoryVectorStore persists the memory vector store to a JSON file. It marshals the store to JSON and writes it to the specified file path.

func (*Agent) PingAgent added in v0.0.7

func (agent *Agent) PingAgent(agentBaseURL string) (AgentCard, error)

func (*Agent) Prompt added in v0.0.8

func (agent *Agent) Prompt(config PromptConfig) error

Prompt starts an interactive TUI that allows users to chat with the agent config allows configuration of the prompt behavior (streaming vs non-streaming) Returns an error if the TUI cannot be started

func (*Agent) RAGMemorySearchSimilaritiesWith

func (agent *Agent) RAGMemorySearchSimilaritiesWith(ctx context.Context, embedding openai.EmbeddingNewParamsInputUnion, limit float64) ([]string, error)

RAGMemorySearchSimilaritiesWith searches for similar records in the RAG memory using the provided embedding. It creates an embedding from the input and searches for records with cosine similarity above the specified limit. It returns a slice of strings containing the prompts of the similar records and an error if any occurred. If no similar records are found, it returns an empty slice. It requires the DMR client to be initialized and the embedding parameters to be set in the Agent. The limit parameter specifies the minimum cosine similarity score for a record to be considered similar. It returns an error if the embedding creation fails or if the search operation fails.

func (*Agent) RAGMemorySearchSimilaritiesWithText

func (agent *Agent) RAGMemorySearchSimilaritiesWithText(ctx context.Context, text string, limit float64) ([]string, error)

RAGMemorySearchSimilaritiesWithText searches for similar records in the RAG memory using the provided text. It creates an embedding from the text and searches for records with cosine similarity above the specified limit. It returns a slice of strings containing the prompts of the similar records and an error if any occurred. If no similar records are found, it returns an empty slice. It requires the DMR client to be initialized and the embedding parameters to be set in the Agent. The limit parameter specifies the minimum cosine similarity score for a record to be considered similar. It returns an error if the embedding creation fails or if the search operation fails.

func (*Agent) RemoveLastAssistantMessage added in v0.0.6

func (agent *Agent) RemoveLastAssistantMessage()

func (*Agent) RemoveLastUserMessage added in v0.0.6

func (agent *Agent) RemoveLastUserMessage()

func (*Agent) RemoveMessage added in v0.0.6

func (agent *Agent) RemoveMessage(index int)

func (*Agent) ResetMemoryVectorStore added in v0.0.3

func (agent *Agent) ResetMemoryVectorStore() error

ResetMemoryVectorStore resets the agent's vector store to a new empty MemoryVectorStore. It clears the existing records and persists the empty store to the file. This is useful for clearing the memory and starting fresh without any records.

func (*Agent) SaveEmbedding added in v0.0.3

func (agent *Agent) SaveEmbedding(text string, embedding openai.Embedding, recordId ...string) (rag.VectorRecord, error)

SaveEmbedding saves the provided embedding to the memory vector store. It returns the saved vector record and an error if any occurred. If a recordId is provided, it will be used as the ID for the vector record; otherwise, a new UUID will be generated. The text is used as the prompt for the vector record. This method is useful when you already have an embedding and want to save it without creating a new one.

func (*Agent) SendToAgent added in v0.0.7

func (agent *Agent) SendToAgent(agentBaseURL string, taskRequest TaskRequest) (TaskResponse, error)

func (*Agent) SetMaxTokens added in v0.0.5

func (agent *Agent) SetMaxTokens(maxTokens int64)

func (*Agent) SetModel added in v0.0.5

func (agent *Agent) SetModel(model string)

func (*Agent) SetTemperature added in v0.0.5

func (agent *Agent) SetTemperature(temperature float64)

func (*Agent) StartA2AServer added in v0.0.7

func (agent *Agent) StartA2AServer() error

func (*Agent) StartHttpServer added in v0.0.1

func (agent *Agent) StartHttpServer() error

func (*Agent) StartMCPHttpServer

func (agent *Agent) StartMCPHttpServer() error

func (*Agent) ToolsCompletion

func (agent *Agent) ToolsCompletion(ctx context.Context) ([]openai.ChatCompletionMessageToolCall, error)

ToolsCompletion handles the tool calls completion request using the DMR client. It sends the parameters set in the Agent and returns the detected tool calls or an error. It is a synchronous operation that waits for the completion to finish.

type AgentCallbackContext added in v0.0.7

type AgentCallbackContext struct {
	CompletionContext
	TaskRequest  *TaskRequest  // Pointer to allow modification
	TaskResponse *TaskResponse // Pointer to allow modification
}

AgentCallbackContext provides specific context for agent callback handlers

type AgentCard added in v0.0.7

type AgentCard struct {
	Name         string           `json:"name"`
	Description  string           `json:"description"`
	URL          string           `json:"url"`
	Version      string           `json:"version"`
	Capabilities map[string]any   `json:"capabilities"`
	Skills       []map[string]any `json:"skills,omitempty"` // Optional, for storing skills related to the agent
}

AgentCard represents the metadata for this agent

type AgentMessage added in v0.0.7

type AgentMessage struct {
	Role      string     `json:"role,omitempty"`
	Parts     []TextPart `json:"parts"`
	MessageID string     `json:"messageId,omitempty"` // Optional, for storing message ID
	TaskID    string     `json:"taskId,omitempty"`    // Optional, for storing task ID
	ContextID string     `json:"contextId,omitempty"` // Optional, for storing context ID
}

Message represents a message structure

type AgentMessageParams added in v0.0.7

type AgentMessageParams struct {
	Message  AgentMessage   `json:"message"`
	MetaData map[string]any `json:"metadata,omitempty"` // Optional, for additional metadata
}

type AgentOption

type AgentOption func(*Agent)

func WithA2AServer added in v0.0.7

func WithA2AServer(a2aServerConfig A2AServerConfig) AgentOption

func WithAfterAlternativeToolsCompletion added in v0.0.5

func WithAfterAlternativeToolsCompletion(handler AfterAlternativeToolsCompletionHandler) AgentOption

WithAfterAlternativeToolsCompletion adds an after alternative tools completion handler

func WithAfterChatCompletion added in v0.0.5

func WithAfterChatCompletion(handler AfterChatCompletionHandler) AgentOption

WithAfterChatCompletion adds an after chat completion handler

func WithAfterChatCompletionStream added in v0.0.5

func WithAfterChatCompletionStream(handler AfterChatCompletionStreamHandler) AgentOption

WithAfterChatCompletionStream adds an after chat completion stream handler

func WithAfterToolsCompletion added in v0.0.5

func WithAfterToolsCompletion(handler AfterToolsCompletionHandler) AgentOption

WithAfterToolsCompletion adds an after tools completion handler

func WithAgentCallback added in v0.0.7

func WithAgentCallback(callback func(ctx *AgentCallbackContext) (TaskResponse, error)) AgentOption

func WithAgentCard added in v0.0.7

func WithAgentCard(agentCard AgentCard) AgentOption

func WithBeforeAlternativeToolsCompletion added in v0.0.5

func WithBeforeAlternativeToolsCompletion(handler BeforeAlternativeToolsCompletionHandler) AgentOption

WithBeforeAlternativeToolsCompletion adds a before alternative tools completion handler

func WithBeforeChatCompletion added in v0.0.5

func WithBeforeChatCompletion(handler BeforeChatCompletionHandler) AgentOption

WithBeforeChatCompletion adds a before chat completion handler

func WithBeforeChatCompletionStream added in v0.0.5

func WithBeforeChatCompletionStream(handler BeforeChatCompletionStreamHandler) AgentOption

WithBeforeChatCompletionStream adds a before chat completion stream handler

func WithBeforeToolsCompletion added in v0.0.5

func WithBeforeToolsCompletion(handler BeforeToolsCompletionHandler) AgentOption

WithBeforeToolsCompletion adds a before tools completion handler

func WithDMR

func WithDMR(baseURL string) AgentOption

func WithEmbeddingParams

func WithEmbeddingParams(embeddingParams openai.EmbeddingNewParams) AgentOption

WithEmbeddingParams sets the parameters for the Agent's embedding requests.

func WithHTTPServer added in v0.0.1

func WithHTTPServer(httpServerConfig HTTPServerConfig) AgentOption

WithHTTPServer configures the HTTP server for the agent. It sets up the server with default endpoints and port if not provided. The server handles POST requests for chat completions and streams. It also provides a mechanism to cancel ongoing completions via a DELETE request (commented out). The server uses the provided HTTPServerConfig to configure its behavior. If the StreamEndPoint or Endpoint is not specified, it defaults to "/api/chat-stream" and "/api/chat" respectively. The default port is set to "8888" if not specified.

func WithLogLevel added in v0.0.5

func WithLogLevel(level LogLevel) AgentOption

func WithLogger added in v0.0.5

func WithLogger(logger *Logger) AgentOption

func WithLogging added in v0.0.5

func WithLogging(level LogLevel, enabled bool) AgentOption

func WithLoggingDisabled added in v0.0.5

func WithLoggingDisabled() AgentOption

func WithLoggingEnabled added in v0.0.5

func WithLoggingEnabled() AgentOption

func WithMCPStdioClient

func WithMCPStdioClient(ctx context.Context, cmd string, options STDIOCommandOptions, envvars EnvVars) AgentOption

WithMCPSTDIOClient initializes the Agent with an MCP client using the provided command. It runs the command to connect to the MCP server and sets up the client transport. The command should be a valid command that can be executed in the environment where the agent runs. It returns an AgentOption that can be used to configure the agent.

func WithMCPStdioTools

func WithMCPStdioTools(ctx context.Context, toolsFilter []string) AgentOption

WithMCPStdioTools fetches the tools from the MCP server and sets them in the agent. It filters the tools based on the provided names and converts them to OpenAI format. It requires the MCP server to be running and accessible at the specified address. The tools are expected to be in the format defined by the MCP server. It returns an AgentOption that can be used to configure the agent. The tools are fetched using the MCP client and converted to OpenAI format. If no toolsFilter are specified, all available tools are used. If toolsFilter is specified, only the tools matching the filter are used. IMPORTANT: The tools are appended to the existing tools in the Agent's parameters.

func WithMCPStreamableHttpClient

func WithMCPStreamableHttpClient(ctx context.Context, mcpHttpServerUrl string, options StreamableHttpOptions) AgentOption

NOTE: this is subject to change

func WithMCPStreamableHttpServer

func WithMCPStreamableHttpServer(mcpServerConfig MCPServerConfig) AgentOption

func WithMCPStreamableHttpTools

func WithMCPStreamableHttpTools(ctx context.Context, toolsFilter []string) AgentOption

func WithMaxTokens added in v0.0.5

func WithMaxTokens(maxTokens int64) AgentOption

func WithMemoryVectorStore added in v0.0.3

func WithMemoryVectorStore(storeFilePath string) AgentOption

TODO: add args to save to file

func WithModel added in v0.0.5

func WithModel(model string) AgentOption

func WithOpenAI

func WithOpenAI(apiKey string) AgentOption

func WithOpenAIClient added in v0.0.5

func WithOpenAIClient(apiKey, baseURL string) AgentOption

func WithOpenAIURL

func WithOpenAIURL(baseURL string, apiKey string) AgentOption

func WithParams

func WithParams(params openai.ChatCompletionNewParams) AgentOption

WithParams sets the parameters for the Agent's chat completion requests.

func WithRAGMemory

func WithRAGMemory(ctx context.Context, chunks []string) AgentOption

WithRAGMemory initializes the Agent with a RAG memory using the provided chunks. It creates a MemoryVectorStore and saves the embeddings of the chunks into it. The chunks should be pre-processed text data that will be used for retrieval-augmented generation (RAG). It returns an AgentOption that can be used to configure the agent.

func WithSystemInstructions added in v0.0.5

func WithSystemInstructions(instructions string) AgentOption

func WithTemperature added in v0.0.5

func WithTemperature(temperature float64) AgentOption

func WithTools

func WithTools(tools []openai.ChatCompletionToolParam) AgentOption

WithTools sets the tools for the Agent's chat completion requests. It allows the Agent to use specific tools during the chat completion process. IMPORTANT: The tools are appended to the existing tools in the Agent's parameters.

type AlternativeToolsCompletionContext added in v0.0.5

type AlternativeToolsCompletionContext struct {
	CompletionContext
	ToolCalls *[]openai.ChatCompletionMessageToolCall // Pointer to allow modification
}

AlternativeToolsCompletionContext provides specific context for alternative tools completion handlers

type Artifact added in v0.0.7

type Artifact struct {
	ArtifactID string     `json:"artifactId"`
	Name       string     `json:"name"`
	Parts      []TextPart `json:"parts"` // Parts of the artifact, e.g., text, images, etc.
}

type BeforeAlternativeToolsCompletionHandler added in v0.0.5

type BeforeAlternativeToolsCompletionHandler func(*AlternativeToolsCompletionContext)

Alternative tools completion handlers

type BeforeChatCompletionHandler added in v0.0.5

type BeforeChatCompletionHandler func(*ChatCompletionContext)

Chat completion handlers

type BeforeChatCompletionStreamHandler added in v0.0.5

type BeforeChatCompletionStreamHandler func(*ChatCompletionStreamContext)

Chat completion stream handlers

type BeforeToolsCompletionHandler added in v0.0.5

type BeforeToolsCompletionHandler func(*ToolsCompletionContext)

Tools completion handlers

type ChatCompletionContext added in v0.0.5

type ChatCompletionContext struct {
	CompletionContext
	Response *string // Pointer to allow modification
}

ChatCompletionContext provides specific context for chat completion handlers

type ChatCompletionStreamContext added in v0.0.5

type ChatCompletionStreamContext struct {
	CompletionContext
	Response *string // Pointer to allow modification
	Callback func(self *Agent, content string, err error) error
}

ChatCompletionStreamContext provides specific context for streaming chat completion handlers

type CompletionContext added in v0.0.5

type CompletionContext struct {
	Agent     *Agent
	Context   context.Context
	StartTime time.Time
	Duration  time.Duration
	Error     error
}

CompletionContext provides context information for completion handlers

type CompletionHandlers added in v0.0.5

type CompletionHandlers struct {
	// Chat completion handlers
	BeforeChatCompletion []BeforeChatCompletionHandler
	AfterChatCompletion  []AfterChatCompletionHandler

	// Chat completion stream handlers
	BeforeChatCompletionStream []BeforeChatCompletionStreamHandler
	AfterChatCompletionStream  []AfterChatCompletionStreamHandler

	// Tools completion handlers
	BeforeToolsCompletion []BeforeToolsCompletionHandler
	AfterToolsCompletion  []AfterToolsCompletionHandler

	// Alternative tools completion handlers
	BeforeAlternativeToolsCompletion []BeforeAlternativeToolsCompletionHandler
	AfterAlternativeToolsCompletion  []AfterAlternativeToolsCompletionHandler
}

CompletionHandlers holds all completion handlers for an agent

func NewCompletionHandlers added in v0.0.5

func NewCompletionHandlers() *CompletionHandlers

NewCompletionHandlers creates a new CompletionHandlers instance

type EnvVars

type EnvVars []string

type HTTPServerConfig added in v0.0.1

type HTTPServerConfig struct {
	Port           string
	Endpoint       string
	StreamEndPoint string
}

type LogEntry added in v0.0.5

type LogEntry struct {
	Timestamp string                 `json:"timestamp"`
	Level     string                 `json:"level"`
	Type      string                 `json:"type"`
	AgentName string                 `json:"agent_name,omitempty"`
	Data      map[string]interface{} `json:"data,omitempty"`
	Message   string                 `json:"message,omitempty"`
	Error     string                 `json:"error,omitempty"`
}

type LogLevel added in v0.0.5

type LogLevel int
const (
	LogLevelOff LogLevel = iota
	LogLevelError
	LogLevelInfo
	LogLevelDebug
)

type Logger added in v0.0.5

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

func GetGlobalLogger added in v0.0.5

func GetGlobalLogger() *Logger

func NewLogger added in v0.0.5

func NewLogger(level LogLevel, enabled bool) *Logger

func (*Logger) IsEnabled added in v0.0.5

func (l *Logger) IsEnabled() bool

func (*Logger) LogAlternativeToolsCompletion added in v0.0.5

func (l *Logger) LogAlternativeToolsCompletion(agentName string, request openai.ChatCompletionNewParams, toolCalls []openai.ChatCompletionMessageToolCall, duration time.Duration, err error)

func (*Logger) LogChatCompletion added in v0.0.5

func (l *Logger) LogChatCompletion(agentName string, request openai.ChatCompletionNewParams, response string, duration time.Duration, err error)

func (*Logger) LogChatCompletionStream added in v0.0.5

func (l *Logger) LogChatCompletionStream(agentName string, request openai.ChatCompletionNewParams, response string, duration time.Duration, err error)

func (*Logger) LogError added in v0.0.5

func (l *Logger) LogError(agentName string, errorType string, message string, err error, context map[string]interface{})

func (*Logger) LogMCPToolExecution added in v0.0.5

func (l *Logger) LogMCPToolExecution(agentName string, toolName string, args map[string]any, response string, clientType string, duration time.Duration, err error)

func (*Logger) LogToolExecution added in v0.0.5

func (l *Logger) LogToolExecution(agentName string, toolName string, args map[string]any, response string, duration time.Duration, err error)

func (*Logger) LogToolsCompletion added in v0.0.5

func (l *Logger) LogToolsCompletion(agentName string, request openai.ChatCompletionNewParams, toolCalls []openai.ChatCompletionMessageToolCall, duration time.Duration, err error)

func (*Logger) SetEnabled added in v0.0.5

func (l *Logger) SetEnabled(enabled bool)

func (*Logger) SetLevel added in v0.0.5

func (l *Logger) SetLevel(level LogLevel)

type MCPServerConfig

type MCPServerConfig struct {
	Name     string
	Version  string
	Port     string
	Endpoint string
}

type PromptConfig added in v0.0.8

type PromptConfig struct {
	UseStreamCompletion        bool
	StartingMessage            string // Optional starting message (default: "🤖 Starting TUI for agent: {name}")
	ExplanationMessage         string // Optional explanation message (default: "Type your questions below. Use '/bye' to quit or Ctrl+C to interrupt completions.")
	PromptTitle                string // Optional prompt title (default: "💬 Chat with {name}")
	ThinkingPrompt             string // Optional thinking prompt (default: "🤔 ")
	InterruptInstructions      string // Optional interrupt instructions (default: "(Press Ctrl+C to interrupt)")
	CompletionInterruptMessage string // Optional completion interrupt message (default: "🚫 Completion was interrupted\n")
	GoodbyeMessage             string // Optional goodbye message (default: "👋 Goodbye!")
}

PromptConfig defines configuration options for the TUI prompt

type Result added in v0.0.7

type Result struct {
	ID        string         `json:"id"`
	ContextID string         `json:"contextId"`
	Status    TaskStatus     `json:"status"`
	Artifacts []Artifact     `json:"artifacts,omitempty"` // Optional, for storing artifacts related to the task
	History   []AgentMessage `json:"history,omitempty"`   // Optional, for storing message history related to the task
	Kind      string         `json:"kind"`                // Should be "task"
	Metadata  map[string]any `json:"metadata,omitempty"`  // Optional, for additional metadata
}

type STDIOCommandOptions

type STDIOCommandOptions []string

type StreamableHttpOptions

type StreamableHttpOptions []string

type TaskRequest added in v0.0.7

type TaskRequest struct {
	JSONRpcVersion string             `json:"jsonrpc"` // Should be "2.0"
	ID             string             `json:"id"`
	Params         AgentMessageParams `json:"params"`
	Method         string             `json:"method,omitempty"` // Optional, for specifying the method of the task
}

REF: https://google-a2a.github.io/A2A/specification/#92-basic-execution-synchronous-polling-style TaskRequest represents an incoming A2A task request

type TaskResponse added in v0.0.7

type TaskResponse struct {
	JSONRpcVersion string `json:"jsonrpc"` // Should be "2.0"
	ID             string `json:"id"`
	Result         Result `json:"result"` // The result of the task execution

}

TaskResponse represents the response task structure

type TaskStatus added in v0.0.7

type TaskStatus struct {
	State string `json:"state"`
}

TaskStatus represents the status of a task

type TextPart added in v0.0.7

type TextPart struct {
	Text string `json:"text"`
	Type string `json:"type"` // Should be "text" for text parts
}

TextPart represents a text part of a message

type ToolsCompletionContext added in v0.0.5

type ToolsCompletionContext struct {
	CompletionContext
	ToolCalls *[]openai.ChatCompletionMessageToolCall // Pointer to allow modification
}

ToolsCompletionContext provides specific context for tools completion handlers

Jump to

Keyboard shortcuts

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