chat

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCmdInfo

func NewCmdInfo(f util.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command

func RunOnce

func RunOnce(client *HivemindClient, message string, out func(string)) error

RunOnce performs a single chat request (non-interactive mode) with streaming output to stdout.

func RunTUI

func RunTUI(client *HivemindClient) error

RunTUI starts the interactive chat TUI using direct terminal output. This approach avoids alt-screen mode so that text can be freely selected and copied.

Types

type ChatMessage

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

ChatMessage is a single message in the OpenAI Chat Completions format.

type ChatOptions

type ChatOptions struct {
	ServerAddr string
	Session    string
	Model      string

	genericclioptions.IOStreams
	// contains filtered or unexported fields
}

func NewChatOptions

func NewChatOptions(f util.Factory, ioStreams genericclioptions.IOStreams) *ChatOptions

func (*ChatOptions) Complete

func (o *ChatOptions) Complete(args []string) error

func (*ChatOptions) Run

func (o *ChatOptions) Run(ctx context.Context, args []string) error

type HivemindClient

type HivemindClient struct {
	BaseURL    string
	SessionKey string
	Model      string
	HTTPClient *http.Client
}

HivemindClient is the HTTP client for hivemind /v1/chat/completions.

func NewHivemindClient

func NewHivemindClient(baseURL, sessionKey, model string, httpClient *http.Client) *HivemindClient

NewHivemindClient creates a new client.

func (*HivemindClient) Chat

func (c *HivemindClient) Chat(ctx context.Context, messages []ChatMessage) (string, error)

Chat sends messages and returns the full response (non-streaming).

func (*HivemindClient) ChatStream

func (c *HivemindClient) ChatStream(ctx context.Context, messages []ChatMessage, cb StreamCallback, toolCb ToolCallCallback) (string, error)

ChatStream sends messages and streams the response, calling cb for each delta. toolCb is called when a tool call is detected (may be nil). Returns the full assistant reply when done.

type StreamCallback

type StreamCallback func(delta string)

StreamCallback is called for each text delta during streaming.

type TeamHTTPClient added in v0.2.0

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

TeamHTTPClient implements command.TeamAPI by calling the Hivemind /v1/teams HTTP API.

func NewTeamHTTPClient added in v0.2.0

func NewTeamHTTPClient(baseURL, sessionKey string, httpClient *http.Client) *TeamHTTPClient

NewTeamHTTPClient creates a new TeamHTTPClient.

func (*TeamHTTPClient) Broadcast added in v0.2.0

func (c *TeamHTTPClient) Broadcast(ctx context.Context, teamID, content string) error

Broadcast implements command.TeamAPI.

func (*TeamHTTPClient) CreateTeam added in v0.2.0

CreateTeam implements command.TeamAPI.

func (*TeamHTTPClient) DissolveTeam added in v0.2.0

func (c *TeamHTTPClient) DissolveTeam(ctx context.Context, teamID string) error

DissolveTeam implements command.TeamAPI.

func (*TeamHTTPClient) GetTeam added in v0.2.0

func (c *TeamHTTPClient) GetTeam(ctx context.Context, teamID string) (*command.TeamState, error)

GetTeam implements command.TeamAPI.

func (*TeamHTTPClient) ListTemplates added in v0.2.0

func (c *TeamHTTPClient) ListTemplates(ctx context.Context) ([]command.TemplateInfo, error)

ListTemplates implements command.TeamAPI.

func (*TeamHTTPClient) SendMessage added in v0.2.0

func (c *TeamHTTPClient) SendMessage(ctx context.Context, teamID, recipientLabel, content string) error

SendMessage implements command.TeamAPI.

type ToolCallCallback

type ToolCallCallback func(name string)

ToolCallCallback is called when a tool call is detected in the stream. name is the tool function name, arguments is the JSON arguments string.

Jump to

Keyboard shortcuts

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