chat

package
v0.1.0-preview Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package chat exposes multi-provider AI chat — the same surface `vxcli chat` ships. Provider routing dispatches to Anthropic / OpenAI / Google / OpenClaw using credentials stored under /api/v2/setup/ai-*.

The platform handler at POST /api/v2/chat/send accepts a provider key and forwards the request, so SDK consumers don't need to vendor each provider's client. Streaming via Server-Sent Events is documented in BIG_PLAN.md M3 (followup); v0.1 is one-shot only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	T              *transport.Transport
	NodeURL        string
	AuthedUsername string
}

Client is the entry point. Construct via:

c.Chat()

func (*Client) Quick

func (c *Client) Quick(ctx context.Context, provider Provider, model, question string) (string, error)

Quick is a one-shot helper: ask a single question, get a string back. Useful for scripts that don't care about token counts or alternate completions.

func (*Client) Send

func (c *Client) Send(ctx context.Context, in SendInput) (*SendOutput, error)

Send issues a one-shot chat completion request. The platform routes to the configured provider using credentials stored in your workspace Vault.

Endpoint: POST /api/v2/chat/send

type Message

type Message struct {
	Role    string `json:"role"` // system | user | assistant
	Content string `json:"content"`
}

Message is one entry in a chat conversation.

type Provider

type Provider string

Provider names that the platform's chat router recognizes. Match the AI credential keys under /api/v2/setup/ai-<provider>-credentials.

const (
	ProviderAnthropic  Provider = "anthropic"
	ProviderOpenAI     Provider = "openai"
	ProviderGoogle     Provider = "google"
	ProviderOpenClaw   Provider = "openclaw"
	ProviderDeepseek   Provider = "deepseek"
	ProviderQwen       Provider = "qwen"
	ProviderGroq       Provider = "groq"
	ProviderMistral    Provider = "mistral"
	ProviderPerplexity Provider = "perplexity"
	ProviderHF         Provider = "huggingface"
	ProviderOllama     Provider = "ollama"
	ProviderHermes     Provider = "hermes"
)

type SendInput

type SendInput struct {
	Provider     Provider
	Model        string
	Messages     []Message
	SystemPrompt string  // optional convenience; prepended as a system message
	Temperature  float64 // 0–1; default 0.7 server-side if zero
	MaxTokens    int     // 0 = provider default
}

SendInput is the request shape for one-shot chat completion.

type SendOutput

type SendOutput struct {
	Completion   string                 `json:"completion"`
	Provider     string                 `json:"provider,omitempty"`
	Model        string                 `json:"model,omitempty"`
	InputTokens  int                    `json:"input_tokens,omitempty"`
	OutputTokens int                    `json:"output_tokens,omitempty"`
	Raw          map[string]interface{} `json:"-"`
}

SendOutput is the response envelope.

Jump to

Keyboard shortcuts

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