Documentation
¶
Overview ¶
Package smarter is the official Go SDK of the Smarter platform's api: the library that Go programs import to build software on their own Smarter installation, running locally or on Kubernetes, without customizing or forking the platform. It has the features of the Python SDK, smarter-python, which is the reference implementation of every Smarter SDK.
Getting started ¶
client, err := smarter.NewClient() // SMARTER_API_KEY, or the smarter cli's ~/.smarter/config.yaml
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
llmclient, err := client.LLMClients.Find(ctx, "customer_support")
if err != nil {
log.Fatal(err)
}
response, err := client.LLMClients.Prompt(ctx, llmclient.Ref(), smarter.Text("Where is my order #1234?"), nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(response.Text())
Configuration ¶
NewClient takes each value from the first of: its options (WithAPIKey, WithBaseURL, WithEnvironment, WithTimeout, WithMaxRetries, ...), the SMARTER_* environment variables, the smarter cli's configuration file, ~/.smarter/config.yaml, and the defaults, so a developer who has run smarter configure needs no other setup.
Resources ¶
The client's fields group the api's operations. Client.Manifests applies, validates, gets, describes, deletes, deploys and undeploys manifests of any kind, exactly as the cli does: it is the only way that the SDK writes resources. Each resource family, e.g. Client.Guardrails, reads its resources from the REST api (List, Retrieve, Find), applies, describes and deletes them through the manifest api, and has its own actions, e.g. GuardrailsService.Evaluate.
A Manifest is a resource's YAML document, whose Spec is a JSON object. ToSAM decodes one into its kind's generated struct, in the github.com/smarter-sh/smarter-golang/sam package.
Prompts, chats and streams ¶
LLMClientsService.Prompt prompts an LLMClient, LLMClientsService.Chat holds a multi-turn conversation that keeps its session, and LLMClientsService.Stream streams a prompt's progress (its LLM requests, tool calls and MCP calls) while it runs: see PromptStream. Prompts make billable requests to the LLMClient's provider.
Errors ¶
Every error that the SDK returns matches ErrSmarter with errors.Is. An api error is an *APIStatusError, which matches the sentinel of its status, e.g. ErrNotFound:
_, err := client.Manifests.Describe(ctx, "LLMClient", "no_such_client")
var status *smarter.APIStatusError
if errors.As(err, &status) && errors.Is(err, smarter.ErrNotFound) {
fmt.Println(status.StatusCode, status.Message, status.ErrorClass())
}
Infrastructure ¶
Deploy methods create real, possibly billable infrastructure on the platform's cloud: DNS records, TLS certificates, Kubernetes ingresses and GPU nodes.
The guides are at https://docs.smarter.sh/en/latest/smarter-framework/smarter-golang.html, and the design decisions in the repository's doc/adr/.
Index ¶
- Constants
- Variables
- func APIBaseURL(raw string) (string, error)
- func DefaultConfigFile() string
- func Deref[T any](p *T) T
- func EnvironmentURL(environment Environment, rootDomain string) string
- func MaskSecret(secret string) string
- func Ptr[T any](v T) *T
- func ToSAM[T any, PT interface{ ... }](m *Manifest) (*T, error)
- type APIConnectionError
- type APIResponseValidationError
- type APIStatusError
- type APIVersion
- type Account
- type AccountContact
- type AccountRef
- type AccountsService
- type AddTextParams
- type AddURLParams
- type CLIVersion
- type ChatSession
- func (s *ChatSession) Send(ctx context.Context, text string) (*PromptChatAPIPromptResponse, error)
- func (s *ChatSession) SendMessage(ctx context.Context, message PromptChatAPIMessage) (*PromptChatAPIPromptResponse, error)
- func (s *ChatSession) SessionKey() string
- func (s *ChatSession) Stream(ctx context.Context, text string) *PromptStream
- func (s *ChatSession) StreamMessage(ctx context.Context, message PromptChatAPIMessage) *PromptStream
- type Client
- func (c *Client) APIKey() string
- func (c *Client) BaseURL() string
- func (c *Client) Do(ctx context.Context, method, path string, body JSONValue, out any) error
- func (c *Client) Environment() Environment
- func (c *Client) GoString() string
- func (c *Client) Kinds(ctx context.Context) ([]KindInfo, error)
- func (c *Client) LogValue() slog.Value
- func (c *Client) Status(ctx context.Context) (*PlatformStatus, error)
- func (c *Client) String() string
- func (c *Client) Version(ctx context.Context) (*PlatformVersion, error)
- func (c *Client) WhoAmI(ctx context.Context) (*WhoAmI, error)
- type ConfigurationError
- type DiscoverManifestParams
- type DiscoverParams
- type DiscoveredModel
- type Environment
- type Guardrail
- type GuardrailEvaluateParams
- type GuardrailEvaluation
- type GuardrailEvent
- type GuardrailEvents
- type GuardrailEventsParams
- type GuardrailFinding
- type GuardrailMatch
- type GuardrailsService
- type ID
- type JSONObject
- type JSONValue
- type JournalEntry
- type JournalListParams
- type JournalMessage
- type JournalPage
- type JournalPagination
- type JournalService
- type JournaledResponse
- type KindInfo
- type KindService
- func (r *KindService[T]) Apply(ctx context.Context, manifest *Manifest) (*JournalMessage, error)
- func (r *KindService[T]) Delete(ctx context.Context, name string) (*JournalMessage, error)
- func (r *KindService[T]) Describe(ctx context.Context, name string) (*Manifest, error)
- func (r *KindService[T]) ExampleManifest(ctx context.Context) (*Manifest, error)
- func (r *KindService[T]) Find(ctx context.Context, name string) (*T, error)
- func (r *KindService[T]) JSONSchema(ctx context.Context) (JSONObject, error)
- func (r *KindService[T]) List(ctx context.Context) ([]T, error)
- func (r *KindService[T]) Retrieve(ctx context.Context, id ID) (*T, error)
- type LLMClient
- type LLMClientAPIKey
- type LLMClientCustomDomain
- type LLMClientFunction
- type LLMClientPlugin
- type LLMClientPluginRef
- type LLMClientsService
- func (s *LLMClientsService) APIKeys(ctx context.Context, id ID) ([]LLMClientAPIKey, error)
- func (s *LLMClientsService) Chat(ctx context.Context, id ID, params *PromptParams) (*ChatSession, error)
- func (s *LLMClientsService) Config(ctx context.Context, id ID, params *PromptParams) (*PromptChatAPIConfig, error)
- func (s *LLMClientsService) CustomDomains(ctx context.Context, id ID) ([]LLMClientCustomDomain, error)
- func (s *LLMClientsService) Deploy(ctx context.Context, name string) (*JournalMessage, error)
- func (s *LLMClientsService) Functions(ctx context.Context, id ID) ([]LLMClientFunction, error)
- func (s *LLMClientsService) Plugins(ctx context.Context, id ID) ([]LLMClientPlugin, error)
- func (s *LLMClientsService) Prompt(ctx context.Context, id ID, messages []PromptChatAPIMessage, ...) (*PromptChatAPIPromptResponse, error)
- func (s *LLMClientsService) Stream(ctx context.Context, id ID, messages []PromptChatAPIMessage, ...) *PromptStream
- func (s *LLMClientsService) Undeploy(ctx context.Context, name string) (*JournalMessage, error)
- type LLMHost
- type LLMHostLogs
- type LLMHostPlan
- type LLMHostReport
- type LLMHostStatus
- type LLMHostsService
- func (s *LLMHostsService) Deploy(ctx context.Context, id ID) (*LLMHostStatus, error)
- func (s *LLMHostsService) Discover(ctx context.Context, params *DiscoverParams) ([]DiscoveredModel, error)
- func (s *LLMHostsService) DiscoverManifest(ctx context.Context, repository string, params *DiscoverManifestParams) (*Manifest, error)
- func (s *LLMHostsService) Logs(ctx context.Context, id ID, params *LogsParams) (*LLMHostLogs, error)
- func (s *LLMHostsService) Plan(ctx context.Context, id ID) (*LLMHostPlan, error)
- func (s *LLMHostsService) Report(ctx context.Context) (*LLMHostReport, error)
- func (s *LLMHostsService) Status(ctx context.Context, id ID) (*LLMHostStatus, error)
- func (s *LLMHostsService) Undeploy(ctx context.Context, id ID, params *UndeployParams) (*LLMHostStatus, error)
- type LogsParams
- type MCPClient
- type MCPClientStatus
- type MCPClientTools
- type MCPClientsService
- func (s *MCPClientsService) CallTool(ctx context.Context, id ID, tool string, arguments JSONObject) (*MCPToolResult, error)
- func (s *MCPClientsService) Refresh(ctx context.Context, id ID) (*MCPClientStatus, error)
- func (s *MCPClientsService) Tools(ctx context.Context, id ID, params *MCPToolsParams) (*MCPClientTools, error)
- type MCPTool
- type MCPToolResult
- type MCPToolsParams
- type Manifest
- type ManifestList
- type ManifestListData
- type ManifestListMetadata
- type ManifestListTitle
- type ManifestMetadata
- type ManifestValidation
- type ManifestsService
- func (s *ManifestsService) Apply(ctx context.Context, manifest *Manifest) (*JournalMessage, error)
- func (s *ManifestsService) Delete(ctx context.Context, kind, name string) (*JournalMessage, error)
- func (s *ManifestsService) Deploy(ctx context.Context, kind, name string) (*JournalMessage, error)
- func (s *ManifestsService) Describe(ctx context.Context, kind, name string) (*Manifest, error)
- func (s *ManifestsService) ExampleManifest(ctx context.Context, kind string) (*Manifest, error)
- func (s *ManifestsService) Get(ctx context.Context, kind, name string) (*ManifestList, error)
- func (s *ManifestsService) JSONSchema(ctx context.Context, kind string) (JSONObject, error)
- func (s *ManifestsService) Logs(ctx context.Context, kind, name string) (*JournaledResponse[JSONObject], error)
- func (s *ManifestsService) Undeploy(ctx context.Context, kind, name string) (*JournalMessage, error)
- func (s *ManifestsService) Validate(ctx context.Context, manifest *Manifest) (*ManifestValidation, error)
- type MessageContent
- type Option
- func WithAPIKey(apiKey string) Option
- func WithBaseURL(baseURL string) Option
- func WithEnvironment(environment Environment) Option
- func WithHTTPClient(client *http.Client) Option
- func WithHeader(key, value string) Option
- func WithLogger(logger *slog.Logger) Option
- func WithLookupEnv(lookup func(string) (string, bool)) Option
- func WithMaxRetries(maxRetries int) Option
- func WithTimeout(timeout time.Duration) Option
- type Orchestrator
- type OrchestratorsService
- type Owner
- type PlatformStatus
- type PlatformVersion
- type Plugin
- type PluginsService
- func (s *PluginsService) Apply(ctx context.Context, manifest *Manifest) (*JournalMessage, error)
- func (s *PluginsService) Delete(ctx context.Context, name string) (*JournalMessage, error)
- func (s *PluginsService) Describe(ctx context.Context, name string) (*Manifest, error)
- func (s *PluginsService) KindOf(ctx context.Context, name string) (string, error)
- func (s *PluginsService) Retrieve(ctx context.Context, id ID) (*Plugin, error)
- func (s *PluginsService) RetrieveManifest(ctx context.Context, id ID) (*Manifest, error)
- type PromptChatAPIChoice
- type PromptChatAPICompletion
- type PromptChatAPIConfig
- type PromptChatAPIConfigRequest
- type PromptChatAPIConfigResponse
- type PromptChatAPIContentPart
- type PromptChatAPIEnvelope
- type PromptChatAPIErrorBody
- type PromptChatAPIErrorResponse
- type PromptChatAPIFileRef
- type PromptChatAPIFunctionCall
- type PromptChatAPIFunctionList
- type PromptChatAPIHistory
- type PromptChatAPIImageURL
- type PromptChatAPIInputAudio
- type PromptChatAPIJournalMetadata
- type PromptChatAPILLMClient
- type PromptChatAPILLMClientFunction
- type PromptChatAPILLMClientPlugin
- type PromptChatAPILLMClientRequest
- type PromptChatAPIListMetaData
- type PromptChatAPIMessage
- type PromptChatAPIMetaData
- type PromptChatAPIOrmModel
- type PromptChatAPIPluginList
- type PromptChatAPIPluginMeta
- type PromptChatAPIPluginSelection
- type PromptChatAPIProgressEvent
- type PromptChatAPIProgressResult
- type PromptChatAPIPromptPluginUsage
- type PromptChatAPIPromptRequest
- type PromptChatAPIPromptResponse
- type PromptChatAPIPromptResult
- type PromptChatAPIPromptToolCall
- type PromptChatAPIStyleSection
- type PromptChatAPIStyles
- type PromptChatAPITokenDetails
- type PromptChatAPIToolCall
- type PromptChatAPIUsage
- type PromptError
- type PromptHistoryService
- func (s *PromptHistoryService) PluginUsage(ctx context.Context) ([]PromptPluginUsage, error)
- func (s *PromptHistoryService) PluginUse(ctx context.Context, id ID) (*PromptPluginUsage, error)
- func (s *PromptHistoryService) Session(ctx context.Context, id ID) (*PromptSession, error)
- func (s *PromptHistoryService) Sessions(ctx context.Context) ([]PromptSession, error)
- func (s *PromptHistoryService) ToolCall(ctx context.Context, id ID) (*PromptToolCall, error)
- func (s *PromptHistoryService) ToolCalls(ctx context.Context) ([]PromptToolCall, error)
- type PromptParams
- type PromptPluginUsage
- type PromptSession
- type PromptStream
- func (s *PromptStream) Close() error
- func (s *PromptStream) Current() PromptChatAPIProgressEvent
- func (s *PromptStream) Err() error
- func (s *PromptStream) Next() bool
- func (s *PromptStream) Response() (*PromptChatAPIPromptResponse, error)
- func (s *PromptStream) Result() *PromptChatAPIProgressResult
- func (s *PromptStream) UntilDone() (*PromptChatAPIPromptResponse, error)
- type PromptToolCall
- type Provider
- type ProviderModel
- type ProvidersService
- type ProxiesService
- type Proxy
- type ProxyRequestParams
- type ReactAppAssets
- type ReactAppBuildInfo
- type ReadService
- type Resource
- type SAMJournalAPIEnvelope
- type SAMJournalAPIErrorBody
- type SAMJournalAPIErrorResponse
- type SAMJournalAPIMetadata
- type SearchParams
- type Secret
- type SecretsService
- type ServerSentEvent
- type SessionRef
- type Stage
- type UndeployParams
- type User
- type UserProfile
- type UserRef
- type ValueError
- type Vectorsearch
- type VectorsearchesService
- type Vectorstore
- type VectorstoreDocument
- type VectorstoreDocumentDeleted
- type VectorstoreDocuments
- type VectorstoreDocumentsAdded
- type VectorstoreRestored
- type VectorstoreSearchResult
- type VectorstoreSearchResults
- type VectorstoreSnapshot
- type VectorstoreSnapshots
- type VectorstoreStatus
- type VectorstoresService
- func (s *VectorstoresService) AddFiles(ctx context.Context, id ID, paths []string) (*VectorstoreDocumentsAdded, error)
- func (s *VectorstoresService) AddText(ctx context.Context, id ID, text string, params *AddTextParams) (*VectorstoreDocumentsAdded, error)
- func (s *VectorstoresService) AddURL(ctx context.Context, id ID, url string, params *AddURLParams) (*VectorstoreDocumentsAdded, error)
- func (s *VectorstoresService) CreateSnapshot(ctx context.Context, id ID) (*VectorstoreSnapshot, error)
- func (s *VectorstoresService) DeleteDocument(ctx context.Context, id ID, documentID int) (*VectorstoreDocumentDeleted, error)
- func (s *VectorstoresService) Deploy(ctx context.Context, id ID) (*Vectorstore, error)
- func (s *VectorstoresService) Documents(ctx context.Context, id ID) (*VectorstoreDocuments, error)
- func (s *VectorstoresService) Restore(ctx context.Context, id ID, snapshotID int) (*VectorstoreRestored, error)
- func (s *VectorstoresService) Search(ctx context.Context, id ID, text string, params *SearchParams) (*VectorstoreSearchResults, error)
- func (s *VectorstoresService) Snapshots(ctx context.Context, id ID) (*VectorstoreSnapshots, error)
- func (s *VectorstoresService) Status(ctx context.Context, id ID) (*VectorstoreStatus, error)
- func (s *VectorstoresService) Undeploy(ctx context.Context, id ID) (*Vectorstore, error)
- type ViteManifest
- type ViteManifestChunk
- type WhoAmI
Examples ¶
Constants ¶
const ( // DefaultEnvironment is the environment when none is configured. DefaultEnvironment = EnvironmentProd // DefaultRootDomain is the platform's root domain when none is configured. DefaultRootDomain = "platform.smarter.sh" // LocalURL is the url of the Smarter platform's local development server. LocalURL = "http://localhost:9357" // APIPath is the path of the Smarter api, which every request url is relative to. APIPath = "/api/v1/" // DefaultTimeout is the timeout of a request. Prompts that call several tools can take tens of seconds. DefaultTimeout = 60 * time.Second // DefaultMaxRetries is how many times a failed request is retried. DefaultMaxRetries = 2 )
Defaults of the configuration.
const APIVersionV1 = "smarter.sh/v1"
APIVersionV1 is the apiVersion of every Smarter manifest.
const ChatContractV2 = 2
ChatContractV2 is the version of the Smarter Chat api contract that the SDK reads.
const ChatContractV2Capability = "chat-contract-v2"
ChatContractV2Capability is the X-Smarter-Capabilities value with which the SDK asks for version 2 of the contract.
const ClientName = "smarter-golang"
ClientName is the SDK's X-Smarter-Client header, which identifies it to the platform's logs and journal.
const ReactBuildInfoKey = "_custom"
ReactBuildInfoKey is the key of the build information that each React package's vite.config.ts adds to its manifest.json.
const Version = "0.1.0"
Version is the SDK's version.
Variables ¶
var ( // ErrSmarter matches every error that the SDK returns. ErrSmarter = errors.New("smarter") // ErrResourceNotFound matches a 404 ([ErrNotFound]), and a Find that found no resource of that name. ErrResourceNotFound = fmt.Errorf("%w: resource not found", ErrSmarter) // ErrBadRequest matches a 400: the request is invalid, e.g. a malformed manifest. ErrBadRequest = fmt.Errorf("%w: bad request", ErrSmarter) // ErrAuthentication matches a 401: the api key is missing, invalid, or inactive. ErrAuthentication = fmt.Errorf("%w: authentication failed", ErrSmarter) // ErrPermissionDenied matches a 403: the api key's user may not perform the operation. ErrPermissionDenied = fmt.Errorf("%w: permission denied", ErrSmarter) // ErrNotFound matches a 404: the resource does not exist, or the api key's user may not read it. // It also matches [ErrResourceNotFound]. ErrNotFound = fmt.Errorf("%w: not found", ErrResourceNotFound) // ErrConflict matches a 409: the request conflicts with the resource's current state. ErrConflict = fmt.Errorf("%w: conflict", ErrSmarter) // ErrUnprocessableEntity matches a 422: the request is well-formed but cannot be processed. ErrUnprocessableEntity = fmt.Errorf("%w: unprocessable entity", ErrSmarter) // ErrRateLimit matches a 429: too many requests. ErrRateLimit = fmt.Errorf("%w: rate limited", ErrSmarter) // ErrInternalServer matches a 5xx: the platform failed to process the request. ErrInternalServer = fmt.Errorf("%w: internal server error", ErrSmarter) )
The SDK's errors follow the Python SDK's exception hierarchy (ADR-006). Every error that the SDK returns matches ErrSmarter with errors.Is; an api error also matches the sentinel of its http status, e.g. ErrNotFound, and its details are in an *APIStatusError (errors.As).
var PluginKinds = []string{"Plugin", "ApiPlugin", "SkillPlugin", "SqlPlugin", "WebsearchPlugin", "ImageSearchPlugin"}
PluginKinds are the manifest kinds of plugins.
Functions ¶
func APIBaseURL ¶
APIBaseURL returns the api's base url for a platform url: https://example.com and https://example.com/api/v1 both become https://example.com/api/v1/. It returns a *ConfigurationError if the url is not an http or https url.
func DefaultConfigFile ¶
func DefaultConfigFile() string
DefaultConfigFile returns the path of the smarter cli's configuration file, ~/.smarter/config.yaml.
func Deref ¶
func Deref[T any](p *T) T
Deref returns the value that p points to, or the zero value of T if p is nil.
func EnvironmentURL ¶
func EnvironmentURL(environment Environment, rootDomain string) string
EnvironmentURL returns the platform url of an environment, as the smarter cli derives it: local is http://localhost:9357, alpha, beta and next are https://<environment>.<root domain>, and prod is https://<root domain>.
func MaskSecret ¶
MaskSecret returns a secret, masked for logging: its last four characters, e.g. "****5150", or "None" when there is no secret.
func Ptr ¶
func Ptr[T any](v T) *T
Ptr returns a pointer to a copy of v, e.g. for an optional field: smarter.Ptr(true).
func ToSAM ¶
ToSAM decodes a manifest into its kind's typed struct, e.g. smarter.ToSAM[sam.Guardrail](m). Fields that the struct doesn't declare are ignored (ADR-004). It returns a *ValueError if the manifest is of another kind, or doesn't match the struct.
Example ¶
server := examplePlatform()
defer server.Close()
client := exampleClient(server)
manifest, err := client.Guardrails.Describe(context.Background(), "pii_redactor")
if err != nil {
log.Fatal(err)
}
guardrail, err := smarter.ToSAM[sam.Guardrail](manifest)
if err != nil {
log.Fatal(err)
}
fmt.Println(guardrail.Kind, guardrail.Spec.Config.Strategy)
Output: Guardrail detector
Types ¶
type APIConnectionError ¶
type APIConnectionError struct {
Method, URL string
Err error
// contains filtered or unexported fields
}
APIConnectionError reports that a request got no response, e.g. the server is unreachable, or it timed out: see Timeout.
func (*APIConnectionError) Error ¶
func (e *APIConnectionError) Error() string
func (*APIConnectionError) Timeout ¶
func (e *APIConnectionError) Timeout() bool
Timeout reports whether the request timed out.
func (*APIConnectionError) Unwrap ¶
func (e *APIConnectionError) Unwrap() []error
Unwrap returns the cause, and ErrSmarter.
type APIResponseValidationError ¶
APIResponseValidationError reports that the api's response does not match the SDK's struct of it, which usually means that the SDK and the platform are of incompatible versions.
func (*APIResponseValidationError) Error ¶
func (e *APIResponseValidationError) Error() string
func (*APIResponseValidationError) Unwrap ¶
func (e *APIResponseValidationError) Unwrap() []error
Unwrap returns the cause, and ErrSmarter.
type APIStatusError ¶
type APIStatusError struct {
Method, URL string
// StatusCode is the response's http status.
StatusCode int
// Message is the error's description, from whichever shape of error the platform returned.
Message string
// Body is the response's body.
Body []byte
// Header is the response's headers.
Header http.Header
// JournalError is the Smarter Journal error, when the response is a journaled error.
JournalError *SAMJournalAPIErrorBody
}
APIStatusError reports that the api returned a 4xx or 5xx status. It matches the sentinel of its status with errors.Is, e.g. ErrNotFound for a 404.
Example ¶
server := examplePlatform()
defer server.Close()
client := exampleClient(server)
_, err := client.Manifests.Describe(context.Background(), "LLMClient", "no_such_client")
var status *smarter.APIStatusError
if errors.As(err, &status) {
fmt.Println(status.StatusCode, status.ErrorClass())
}
fmt.Println(errors.Is(err, smarter.ErrInternalServer), errors.Is(err, smarter.ErrSmarter))
Output: 503 SAMBrokerErrorNotReady true true
func (*APIStatusError) Error ¶
func (e *APIStatusError) Error() string
func (*APIStatusError) ErrorClass ¶
func (e *APIStatusError) ErrorClass() string
ErrorClass returns the name of the platform's exception class, e.g. SAMBrokerErrorNotFound, when the platform sent it.
func (*APIStatusError) Unwrap ¶
func (e *APIStatusError) Unwrap() error
Unwrap returns the sentinel of the error's status.
type APIVersion ¶
type APIVersion struct {
// Version is the Smarter platform's semantic version.
Version string `json:"version"`
// Python holds Python package versions, by package; nil when a package isn't installed.
Python map[string]*string `json:"python,omitempty"`
}
APIVersion is the platform's version, and the versions of its main Python packages.
type Account ¶
type Account struct {
Resource
AccountNumber string `json:"accountNumber"`
IsDefaultAccount *bool `json:"isDefaultAccount,omitempty"`
CompanyName string `json:"companyName,omitempty"`
PhoneNumber string `json:"phoneNumber,omitempty"`
Address1 string `json:"address1,omitempty"`
Address2 string `json:"address2,omitempty"`
City string `json:"city,omitempty"`
State string `json:"state,omitempty"`
PostalCode string `json:"postalCode,omitempty"`
Country string `json:"country,omitempty"`
Language string `json:"language,omitempty"`
Timezone string `json:"timezone,omitempty"`
Currency string `json:"currency,omitempty"`
IsActive *bool `json:"isActive,omitempty"`
}
Account is a Smarter account: the tenant that owns users and resources.
type AccountContact ¶
type AccountContact struct {
ID int `json:"id"`
Account *AccountRef `json:"account,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
IsPrimary *bool `json:"isPrimary,omitempty"`
IsTest *bool `json:"isTest,omitempty"`
Welcomed *bool `json:"welcomed,omitempty"`
}
AccountContact is a contact of an account, who receives its notices.
type AccountRef ¶
type AccountRef struct {
AccountNumber string `json:"accountNumber"`
}
AccountRef is the account of a resource's owner.
type AccountsService ¶
type AccountsService struct {
*KindService[Account]
// Users are the users of the api key's account: /api/v1/accounts/users/.
Users *ReadService[User]
// Contacts are the contacts of the api key's account: /api/v1/accounts/contacts/.
Contacts *ReadService[AccountContact]
// UserProfiles are each user's membership of an account: /api/v1/accounts/user-profiles/.
UserProfiles *ReadService[UserProfile]
}
AccountsService holds the operations of Accounts: /api/v1/accounts/, and the manifest api's Account kind, with the account's users, contacts and user profiles. Only superusers may read them: the platform refuses other users with a 403. Users and accounts are created and changed with manifests (the User and Account kinds).
type AddTextParams ¶
type AddTextParams struct {
// Name is the document's name.
Name string
// Metadata is a JSON object, stored with each of the document's chunks.
Metadata JSONObject
}
AddTextParams are the optional arguments of VectorstoresService.AddText.
type AddURLParams ¶
type AddURLParams struct {
// Metadata is a JSON object, stored with each of the document's chunks.
Metadata JSONObject
}
AddURLParams are the optional arguments of VectorstoresService.AddURL.
type CLIVersion ¶
type CLIVersion struct {
Version string `json:"version,omitempty"`
}
CLIVersion is the version of the smarter cli that the platform recommends.
type ChatSession ¶
type ChatSession struct {
// LLMClientID is the LLMClient's id or hashed id.
LLMClientID ID
// Config is the chat session's configuration.
Config *PromptChatAPIConfig
// Messages is the chat thread.
Messages []PromptChatAPIMessage
// contains filtered or unexported fields
}
ChatSession is a multi-turn conversation with an LLMClient. It keeps the chat session's key, so that the platform keeps the session's history, and the thread, which it sends with each prompt as Smarter Chat does. Create one with LLMClientsService.Chat. A session is not safe for concurrent use.
func (*ChatSession) Send ¶
func (s *ChatSession) Send(ctx context.Context, text string) (*PromptChatAPIPromptResponse, error)
Send sends a user message, and adds it and the prompt's messages to the thread. The response's Text() is the LLM's reply.
func (*ChatSession) SendMessage ¶
func (s *ChatSession) SendMessage(ctx context.Context, message PromptChatAPIMessage) (*PromptChatAPIPromptResponse, error)
SendMessage sends a message, and adds it and the prompt's messages to the thread.
func (*ChatSession) SessionKey ¶
func (s *ChatSession) SessionKey() string
SessionKey returns the chat session's key, with which the session can be resumed: see LLMClientsService.Chat.
func (*ChatSession) Stream ¶
func (s *ChatSession) Stream(ctx context.Context, text string) *PromptStream
Stream sends a user message, and streams the prompt's progress. The thread is updated when the stream has been read to its end, if the prompt succeeded.
func (*ChatSession) StreamMessage ¶
func (s *ChatSession) StreamMessage(ctx context.Context, message PromptChatAPIMessage) *PromptStream
StreamMessage sends a message, and streams the prompt's progress. See ChatSession.Stream.
type Client ¶
type Client struct {
// Manifests is the manifest api: apply, validate, get, describe, delete, deploy, undeploy and
// logs, for any kind.
Manifests *ManifestsService
// LLMClients are LLMClients, and prompting and chatting with them.
LLMClients *LLMClientsService
// Guardrails are Guardrails.
Guardrails *GuardrailsService
// MCPClients are MCPClients.
MCPClients *MCPClientsService
// Vectorstores are Vectorstores.
Vectorstores *VectorstoresService
// LLMHosts are LLMHosts.
LLMHosts *LLMHostsService
// Secrets are Secrets.
Secrets *SecretsService
// Plugins are Plugins, of every plugin kind.
Plugins *PluginsService
// Orchestrators are Orchestrators.
Orchestrators *OrchestratorsService
// Vectorsearches are Vectorsearches.
Vectorsearches *VectorsearchesService
// Accounts are Accounts, and their users, contacts and user profiles.
Accounts *AccountsService
// History is the history of chat sessions, tool calls and plugin uses.
History *PromptHistoryService
// Journal is the Smarter Journal. Superusers only.
Journal *JournalService
// Providers are the LLM providers and their models.
Providers *ProvidersService
// Proxies are proxies to LLM providers' own apis.
Proxies *ProxiesService
// contains filtered or unexported fields
}
Client is a client of a Smarter platform's api. Its fields group the api's operations, and it is safe for concurrent use by many goroutines. Create one with NewClient.
func NewClient ¶
NewClient returns a client. Each value is taken from the first of: the options, the SMARTER_* environment variables (SMARTER_API_KEY, SMARTER_BASE_URL, SMARTER_ENVIRONMENT, SMARTER_ROOT_DOMAIN, SMARTER_TIMEOUT in seconds, SMARTER_MAX_RETRIES, SMARTER_LOG and SMARTER_CONFIG_FILE), the smarter cli's configuration file (~/.smarter/config.yaml), and the defaults: the prod environment of platform.smarter.sh. Without a base url, the url is derived from the environment as the cli derives it: see EnvironmentURL.
It returns a *ConfigurationError if no api key is found, or a value is invalid.
Example ¶
server := examplePlatform()
defer server.Close()
// smarter.NewClient() alone reads SMARTER_API_KEY, or the smarter cli's ~/.smarter/config.yaml.
client, err := smarter.NewClient(
smarter.WithAPIKey("an example api key, 64 characters long, as the platform issues"),
smarter.WithBaseURL(server.URL),
smarter.WithLookupEnv(testEnv(nil)),
)
if err != nil {
log.Fatal(err)
}
me, err := client.WhoAmI(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Println(me.User.Username, me.Account.AccountNumber)
Output: admin 1234-5678-9012
func (*Client) BaseURL ¶
BaseURL returns the api's base url, e.g. https://platform.smarter.sh/api/v1/.
func (*Client) Do ¶
Do sends a request to an api endpoint that the SDK doesn't wrap, with the client's authentication, retries and error handling, and decodes its JSON response into out, unless out is nil. The path is relative to the api's base url, e.g. "cli/whoami/", and body, unless nil, is sent as JSON.
func (*Client) Environment ¶
func (c *Client) Environment() Environment
Environment returns the environment that the configuration was resolved for.
func (*Client) Kinds ¶
Kinds returns the resource kinds that the platform supports, and which of them can be deployed.
func (*Client) Status ¶
func (c *Client) Status(ctx context.Context) (*PlatformStatus, error)
Status returns the state of the platform's infrastructure and compute.
type ConfigurationError ¶
type ConfigurationError struct {
Message string
}
ConfigurationError reports that the client is missing configuration that it needs, e.g. an api key, or that a value is invalid. NewClient returns it.
func (*ConfigurationError) Error ¶
func (e *ConfigurationError) Error() string
func (*ConfigurationError) Unwrap ¶
func (e *ConfigurationError) Unwrap() error
Unwrap returns ErrSmarter.
type DiscoverManifestParams ¶
type DiscoverManifestParams struct {
// Catalog is the catalog, huggingface by default.
Catalog string
// Engine is the inference engine, or "" for the platform's choice.
Engine string
// Name is the LLMHost's name, or "" for one derived from the repository.
Name string
// TokenSecret is the name of a Secret that holds the catalog's access token, for gated models.
TokenSecret string
}
DiscoverManifestParams are the optional arguments of LLMHostsService.DiscoverManifest.
type DiscoverParams ¶
type DiscoverParams struct {
// Query is the search text, e.g. qwen.
Query string
// Task selects only models of this task, e.g. chat or embedding.
Task string
// Catalog is the catalog, huggingface by default.
Catalog string
// Limit is the maximum number of models, 20 by default.
Limit int
}
DiscoverParams are the optional arguments of LLMHostsService.Discover.
type DiscoveredModel ¶
type DiscoveredModel struct {
Catalog string `json:"catalog,omitempty"`
Source string `json:"source,omitempty"`
Repository string `json:"repository"`
Task string `json:"task,omitempty"`
Description string `json:"description,omitempty"`
License string `json:"license,omitempty"`
Gated *bool `json:"gated,omitempty"`
Downloads *int `json:"downloads,omitempty"`
Likes *int `json:"likes,omitempty"`
Tags []string `json:"tags,omitempty"`
Manifest JSONObject `json:"manifest,omitempty"`
}
DiscoveredModel is a model found in a public catalog, e.g. Hugging Face, with the LLMHost manifest that would serve it.
type Environment ¶
type Environment string
Environment is an environment of the smarter cli's configuration file.
const ( EnvironmentLocal Environment = "local" EnvironmentAlpha Environment = "alpha" EnvironmentBeta Environment = "beta" EnvironmentNext Environment = "next" EnvironmentProd Environment = "prod" )
The environments of the smarter cli's configuration file.
type Guardrail ¶
type Guardrail struct {
Resource
// Stage is input or output.
Stage string `json:"stage,omitempty"`
Category string `json:"category,omitempty"`
// Strategy is e.g. regex, detector, classifier or llm.
Strategy string `json:"strategy,omitempty"`
Pattern string `json:"pattern,omitempty"`
Config JSONObject `json:"config,omitempty"`
Threshold *float64 `json:"threshold,omitempty"`
// Action is e.g. block, redact or flag.
Action string `json:"action,omitempty"`
Replacement string `json:"replacement,omitempty"`
Message string `json:"message,omitempty"`
Severity *int `json:"severity,omitempty"`
// Mode is enforce or monitor.
Mode string `json:"mode,omitempty"`
FailClosed *bool `json:"failClosed,omitempty"`
Priority *int `json:"priority,omitempty"`
IsActive *bool `json:"isActive,omitempty"`
}
Guardrail is a check that the platform runs on prompts (input) or on the LLM's replies (output).
type GuardrailEvaluateParams ¶
type GuardrailEvaluateParams struct {
// Stage is the stage to evaluate the text as, StageInput by default. The Guardrail must run on it.
Stage Stage
}
GuardrailEvaluateParams are the optional arguments of GuardrailsService.Evaluate.
type GuardrailEvaluation ¶
type GuardrailEvaluation struct {
Guardrail string `json:"guardrail"`
Stage string `json:"stage"`
Triggered bool `json:"triggered"`
// Disposition is e.g. passed, blocked, redacted or flagged.
Disposition string `json:"disposition,omitempty"`
// Text is the text after the guardrail's action, e.g. redacted.
Text string `json:"text,omitempty"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
DurationMs *float64 `json:"durationMs,omitempty"`
Findings []GuardrailFinding `json:"findings,omitempty"`
}
GuardrailEvaluation is the result of a guardrail's dry run on a text. Nothing is saved: an evaluation does not create an event.
type GuardrailEvent ¶
type GuardrailEvent struct {
ID int `json:"id"`
CreatedAt string `json:"createdAt,omitempty"`
// LLMClient is the name of the LLMClient whose prompt triggered it.
LLMClient string `json:"llmclient,omitempty"`
Stage string `json:"stage,omitempty"`
Disposition string `json:"disposition,omitempty"`
Reviewed *bool `json:"reviewed,omitempty"`
}
GuardrailEvent is a guardrail's finding in a real prompt, saved for review.
type GuardrailEvents ¶
type GuardrailEvents struct {
Guardrail string `json:"guardrail"`
Events []GuardrailEvent `json:"events"`
}
GuardrailEvents are the latest events of a guardrail.
type GuardrailEventsParams ¶
type GuardrailEventsParams struct {
// Reviewed selects only reviewed (true) or unreviewed (false) events, when it isn't nil.
Reviewed *bool
// Disposition selects only events of this disposition, e.g. blocked.
Disposition string
}
GuardrailEventsParams are the optional arguments of GuardrailsService.Events.
type GuardrailFinding ¶
type GuardrailFinding struct {
Confidence *float64 `json:"confidence,omitempty"`
Rationale string `json:"rationale,omitempty"`
Matches []GuardrailMatch `json:"matches,omitempty"`
}
GuardrailFinding is one finding of a guardrail evaluation.
type GuardrailMatch ¶
type GuardrailMatch struct {
Start int `json:"start"`
End int `json:"end"`
Text string `json:"text"`
Label string `json:"label,omitempty"`
}
GuardrailMatch is a span of the text that a guardrail matched.
type GuardrailsService ¶
type GuardrailsService struct {
*KindService[Guardrail]
}
GuardrailsService holds the operations of Guardrails: /api/v1/guardrails/, and the manifest api's Guardrail kind. A Guardrail is a check that the platform runs on prompts and on the LLM's replies.
func (*GuardrailsService) Evaluate ¶
func (s *GuardrailsService) Evaluate(ctx context.Context, id ID, text string, params *GuardrailEvaluateParams) (*GuardrailEvaluation, error)
Evaluate dry-runs a Guardrail on a text, without saving an event, and returns whether it triggered, its disposition, and the text after its action. The error matches ErrBadRequest if the text is empty or too long, or the Guardrail does not run on the stage.
Example ¶
server := examplePlatform()
defer server.Close()
client := exampleClient(server)
result, err := client.Guardrails.Evaluate(context.Background(), smarter.IntID(17), "my email is jane@example.com",
&smarter.GuardrailEvaluateParams{Stage: smarter.StageOutput})
if err != nil {
log.Fatal(err)
}
fmt.Println(result.Triggered, result.Findings[0].Matches[0].Label)
Output: true email
func (*GuardrailsService) Events ¶
func (s *GuardrailsService) Events(ctx context.Context, id ID, params *GuardrailEventsParams) (*GuardrailEvents, error)
Events returns the latest events of a Guardrail that the user owns, newest first.
type ID ¶
type ID string
ID is a resource's id, as text: its integer primary key, e.g. IntID(5), or its hashed id, e.g. ID("rMTAwMDAwNQx"). It is the Python SDK's SmarterIdType.
type JSONObject ¶
JSONObject is a JSON object whose shape is not fixed, e.g. a manifest's spec, whose fields depend on its kind. It is the Python SDK's SmarterJsonObjectType.
type JSONValue ¶
type JSONValue = any
JSONValue is a decoded JSON value whose shape really is free: a string, a float64, a bool, nil, a []any or a map[string]any. It is the Python SDK's SmarterJsonType. See ADR-013.
type JournalEntry ¶
type JournalEntry struct {
Key string `json:"key"`
CreatedAt string `json:"createdAt,omitempty"`
// User is the username of the caller, or "" for an anonymous request.
User string `json:"user,omitempty"`
Thing string `json:"thing"`
Command string `json:"command"`
StatusCode int `json:"statusCode"`
Request JSONValue `json:"request,omitempty"`
Response JSONValue `json:"response,omitempty"`
}
JournalEntry is a Smarter Journal entry, as /api/v1/journal/ returns it.
The list returns entries without Request and Response. Retrieving one entry by its key includes them. Only superusers may read the journal, because the request documents hold the callers' credentials.
type JournalListParams ¶
type JournalListParams struct {
// Page is the page number, from 1. 1 by default.
Page int
// PageSize is how many entries per page, or 0 for the platform's default.
PageSize int
// Search selects only entries whose key, thing or command contains this text.
Search string
// Ordering is a sort field, e.g. createdAt or -statusCode.
Ordering string
}
JournalListParams are the optional arguments of JournalService.List.
type JournalMessage ¶
type JournalMessage struct {
SAMJournalAPIEnvelope
// Message is a human-readable message, e.g. "LLMClient calculator applied".
Message string `json:"message,omitempty"`
}
JournalMessage is a journaled response that carries only a message, e.g. the response of apply, delete or deploy. It is the Python SDK's SmarterJournalMessage.
type JournalPage ¶
type JournalPage struct {
Objects []JournalEntry `json:"objects"`
Pagination JournalPagination `json:"pagination"`
}
JournalPage is one page of the journal's entries.
type JournalPagination ¶
type JournalPagination struct {
Page int `json:"page"`
PageSize int `json:"pageSize"`
NumPages int `json:"numPages"`
Count int `json:"count"`
Search string `json:"search,omitempty"`
Ordering string `json:"ordering,omitempty"`
SortFields []string `json:"sortFields,omitempty"`
}
JournalPagination describes one page of the journal's entries.
type JournalService ¶
type JournalService struct {
// contains filtered or unexported fields
}
JournalService reads the Smarter Journal: a record of every journaled api request and response. Superusers only: each entry's request document holds the caller's headers, including their api key.
func (*JournalService) List ¶
func (s *JournalService) List(ctx context.Context, params *JournalListParams) (*JournalPage, error)
List returns one page of the journal's entries, newest first, without their request and response documents, and its pagination.
func (*JournalService) Retrieve ¶
func (s *JournalService) Retrieve(ctx context.Context, key string) (*JournalEntry, error)
Retrieve returns a journal entry, with its request and response documents, by its key: the metadata key of a journaled response.
type JournaledResponse ¶
type JournaledResponse[T any] struct { SAMJournalAPIEnvelope // Data is the response's data, or nil when it has none. Data *T `json:"data,omitempty"` // Message is a human-readable message. Message string `json:"message,omitempty"` }
JournaledResponse is a successful journaled response whose data is a T. It is the Python SDK's SmarterJournaledResponse.
type KindInfo ¶
type KindInfo struct {
Singular string `json:"Singular"`
Plural string `json:"Plural"`
// APIKind is the kind, as it appears in a manifest.
APIKind string `json:"APIKind"`
Display string `json:"Display,omitempty"`
DisplayPlural string `json:"DisplayPlural,omitempty"`
// Deployable is true if the kind can be deployed.
Deployable bool `json:"Deployable"`
}
KindInfo is a resource kind that the platform supports, as /api/v1/cli/resources/ describes it.
type KindService ¶
type KindService[T named] struct {
// Kind is the manifest kind, e.g. Guardrail.
Kind string
// Path is the REST list endpoint, relative to the api's base url, e.g. guardrails/.
Path string
// contains filtered or unexported fields
}
KindService holds the operations of one resource kind, e.g. Guardrail: List, Retrieve and Find, from the REST api, and Apply, Describe, Delete, ExampleManifest and JSONSchema, from the manifest api (ADR-003). Each resource family's service embeds it.
func (*KindService[T]) Apply ¶
func (r *KindService[T]) Apply(ctx context.Context, manifest *Manifest) (*JournalMessage, error)
Apply creates or updates a resource of this kind from its manifest. It returns a *ValueError if the manifest is of another kind.
func (*KindService[T]) Delete ¶
func (r *KindService[T]) Delete(ctx context.Context, name string) (*JournalMessage, error)
Delete permanently deletes a resource.
func (*KindService[T]) Describe ¶
Describe returns a resource's manifest, with its read-only status.
func (*KindService[T]) ExampleManifest ¶
func (r *KindService[T]) ExampleManifest(ctx context.Context) (*Manifest, error)
ExampleManifest returns a valid example manifest of this kind, to start from.
func (*KindService[T]) Find ¶
func (r *KindService[T]) Find(ctx context.Context, name string) (*T, error)
Find returns the first resource of a name that the user may read. The error matches ErrResourceNotFound if there is none.
func (*KindService[T]) JSONSchema ¶
func (r *KindService[T]) JSONSchema(ctx context.Context) (JSONObject, error)
JSONSchema returns the JSON Schema of this kind's manifest.
func (*KindService[T]) List ¶
func (r *KindService[T]) List(ctx context.Context) ([]T, error)
List returns every resource of this kind that the api key's user may read.
func (*KindService[T]) Retrieve ¶
func (r *KindService[T]) Retrieve(ctx context.Context, id ID) (*T, error)
Retrieve returns one resource, by its id or hashed id. The error matches ErrNotFound if it doesn't exist, or the user may not read it.
type LLMClient ¶
type LLMClient struct {
Resource
RFC1034CompliantName string `json:"rfc1034CompliantName,omitempty"`
Provider string `json:"provider,omitempty"`
DefaultModel string `json:"defaultModel,omitempty"`
// DefaultSystemRole is the system prompt of a new chat session.
DefaultSystemRole string `json:"defaultSystemRole,omitempty"`
Deployed *bool `json:"deployed,omitempty"`
DefaultHost string `json:"defaultHost,omitempty"`
DefaultURL string `json:"defaultUrl,omitempty"`
CustomHost string `json:"customHost,omitempty"`
CustomURL string `json:"customUrl,omitempty"`
SandboxHost string `json:"sandboxHost,omitempty"`
SandboxURL string `json:"sandboxUrl,omitempty"`
// URLLLMClient is where to send prompts: the chat api's prompt url.
URLLLMClient string `json:"urlLlmclient,omitempty"`
// URLChatConfig is the chat api's configuration url.
URLChatConfig string `json:"urlChatConfig,omitempty"`
// IsAuthenticationRequired reports whether prompting the LLMClient requires an api key.
IsAuthenticationRequired *bool `json:"isAuthenticationRequired,omitempty"`
Functions []LLMClientFunction `json:"functions,omitempty"`
Plugins []LLMClientPluginRef `json:"plugins,omitempty"`
APIKeys []LLMClientAPIKey `json:"apiKeys,omitempty"`
CustomDomains []LLMClientCustomDomain `json:"customDomains,omitempty"`
}
LLMClient is a deployable AI agent, built from an LLM provider and model, a system prompt, plugins and functions. Prompt it with LLMClientsService.Prompt, or start a chat with LLMClientsService.Chat.
type LLMClientAPIKey ¶
type LLMClientAPIKey struct {
ID int `json:"id"`
LLMClient *int `json:"llmclient,omitempty"`
// APIKey is the api key's public key_id, a UUID. Never the key itself.
APIKey string `json:"apiKey,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
}
LLMClientAPIKey is an api key that may call an LLMClient that requires authentication.
type LLMClientCustomDomain ¶
type LLMClientCustomDomain struct {
ID int `json:"id"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Version string `json:"version,omitempty"`
// DomainName is the domain, e.g. example.com.
DomainName string `json:"domainName,omitempty"`
// VerificationStatus is Not Verified, Verifying, Verified or Failed.
VerificationStatus string `json:"verificationStatus,omitempty"`
VerifiedAt string `json:"verifiedAt,omitempty"`
VerificationMessage string `json:"verificationMessage,omitempty"`
// UserProfile is the owner's user profile id.
UserProfile *int `json:"userProfile,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
}
LLMClientCustomDomain is a custom domain on which an LLMClient is deployed: the domain itself, and its verification.
type LLMClientFunction ¶
type LLMClientFunction struct {
ID int `json:"id"`
Name string `json:"name,omitempty"`
LLMClient *int `json:"llmclient,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
}
LLMClientFunction is a built-in function of an LLMClient, e.g. calculator.
type LLMClientPlugin ¶
type LLMClientPlugin struct {
ID int `json:"id"`
PluginMeta Plugin `json:"pluginMeta"`
LLMClient *int `json:"llmclient,omitempty"`
}
LLMClientPlugin is the association of a plugin with an LLMClient.
type LLMClientPluginRef ¶
LLMClientPluginRef is a plugin of an LLMClient, by its id and name.
type LLMClientsService ¶
type LLMClientsService struct {
*KindService[LLMClient]
}
LLMClientsService holds the operations of LLMClients: /api/v1/llm-clients/, and the manifest api's LLMClient kind. Prompt one, stream a prompt's progress, or hold a multi-turn chat.
func (*LLMClientsService) APIKeys ¶
func (s *LLMClientsService) APIKeys(ctx context.Context, id ID) ([]LLMClientAPIKey, error)
APIKeys returns the api keys that may call an LLMClient that requires authentication.
func (*LLMClientsService) Chat ¶
func (s *LLMClientsService) Chat(ctx context.Context, id ID, params *PromptParams) (*ChatSession, error)
Chat starts a conversation with an LLMClient, or resumes the one of params.SessionKey.
func (*LLMClientsService) Config ¶
func (s *LLMClientsService) Config(ctx context.Context, id ID, params *PromptParams) (*PromptChatAPIConfig, error)
Config returns an LLMClient's chat configuration, and a chat session: an existing session, with its history, when params has its SessionKey, or a new one. The configuration's SessionKey identifies it.
func (*LLMClientsService) CustomDomains ¶
func (s *LLMClientsService) CustomDomains(ctx context.Context, id ID) ([]LLMClientCustomDomain, error)
CustomDomains returns the custom domains of an LLMClient.
func (*LLMClientsService) Deploy ¶
func (s *LLMClientsService) Deploy(ctx context.Context, name string) (*JournalMessage, error)
Deploy deploys an LLMClient on its own host name. This creates real, possibly billable infrastructure: DNS records, a TLS certificate and a Kubernetes ingress.
func (*LLMClientsService) Functions ¶
func (s *LLMClientsService) Functions(ctx context.Context, id ID) ([]LLMClientFunction, error)
Functions returns an LLMClient's built-in functions, e.g. calculator.
func (*LLMClientsService) Plugins ¶
func (s *LLMClientsService) Plugins(ctx context.Context, id ID) ([]LLMClientPlugin, error)
Plugins returns an LLMClient's plugins.
func (*LLMClientsService) Prompt ¶
func (s *LLMClientsService) Prompt(ctx context.Context, id ID, messages []PromptChatAPIMessage, params *PromptParams) (*PromptChatAPIPromptResponse, error)
Prompt prompts an LLMClient with a chat thread, e.g. smarter.Text("What is 17 times 23?").
The platform runs the LLMClient's whole prompt: it selects plugins, calls the LLM, runs the tools that the LLM calls, and applies the Guardrails. Prompts are billed by the LLM provider. The response's Text() is the LLM's final reply, and Data.Messages every message that the prompt added, including Smarter's own. A failed prompt, e.g. one that the LLM provider refused, returns an *APIStatusError whose Body is the error response.
Example ¶
server := examplePlatform()
defer server.Close()
client := exampleClient(server)
response, err := client.LLMClients.Prompt(context.Background(), smarter.IntID(5), smarter.Text("What is 17 times 23?"), nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(strings.Contains(response.Text(), "391"))
Output: true
func (*LLMClientsService) Stream ¶
func (s *LLMClientsService) Stream(ctx context.Context, id ID, messages []PromptChatAPIMessage, params *PromptParams) *PromptStream
Stream prompts an LLMClient, and streams its progress: the LLM requests, tool calls and plugin calls. The request is sent by the first call of the stream's Next. Close the stream when you are done with it. The client's timeout applies to each event.
func (*LLMClientsService) Undeploy ¶
func (s *LLMClientsService) Undeploy(ctx context.Context, name string) (*JournalMessage, error)
Undeploy undoes an LLMClient's deployment.
type LLMHost ¶
type LLMHost struct {
Resource
Spec JSONObject `json:"spec,omitempty"`
ModelSource string `json:"modelSource,omitempty"`
ModelRepository string `json:"modelRepository,omitempty"`
ModelRevision string `json:"modelRevision,omitempty"`
// ModelTask is e.g. chat, completion or embedding.
ModelTask string `json:"modelTask,omitempty"`
// InferenceEngine is e.g. vllm, tgi, tei, ollama or llama_cpp.
InferenceEngine string `json:"inferenceEngine,omitempty"`
APIFormat string `json:"apiFormat,omitempty"`
// Compute is the id of the LLMHostCompute that the LLMHost runs on.
Compute *int `json:"compute,omitempty"`
GPUCount *int `json:"gpuCount,omitempty"`
GPUType string `json:"gpuType,omitempty"`
Replicas *int `json:"replicas,omitempty"`
ReadyReplicas *int `json:"readyReplicas,omitempty"`
Status string `json:"status,omitempty"`
StatusMessage string `json:"statusMessage,omitempty"`
EndpointURL string `json:"endpointUrl,omitempty"`
PublicURL string `json:"publicUrl,omitempty"`
ServedModelName string `json:"servedModelName,omitempty"`
IsActive *bool `json:"isActive,omitempty"`
DeployedAt string `json:"deployedAt,omitempty"`
CostPerHour string `json:"costPerHour,omitempty"`
}
LLMHost is an open-weight model that the platform serves on its own Kubernetes cluster: the model, the inference engine that serves it, and the compute it runs on.
type LLMHostLogs ¶
LLMHostLogs are the latest log lines of an LLMHost's pods.
type LLMHostPlan ¶
type LLMHostPlan struct {
LLMHost string `json:"llmhost"`
Resources []JSONObject `json:"resources,omitempty"`
}
LLMHostPlan holds the Kubernetes resources that deploying an LLMHost would create, without creating them.
type LLMHostReport ¶
type LLMHostReport struct {
Totals JSONObject `json:"totals,omitempty"`
ByStatus map[string]int `json:"byStatus,omitempty"`
ByEngine map[string]int `json:"byEngine,omitempty"`
LLMHosts []JSONObject `json:"llmhosts,omitempty"`
}
LLMHostReport is a report of every LLMHost that the user may read: counts, and estimated costs.
type LLMHostStatus ¶
type LLMHostStatus struct {
LLMHost string `json:"llmhost"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
Replicas *int `json:"replicas,omitempty"`
ReadyReplicas *int `json:"readyReplicas,omitempty"`
Healthy *bool `json:"healthy,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
PublicURL string `json:"publicUrl,omitempty"`
Pods []JSONObject `json:"pods,omitempty"`
CheckedAt string `json:"checkedAt,omitempty"`
}
LLMHostStatus is an LLMHost's state, read from Kubernetes now.
type LLMHostsService ¶
type LLMHostsService struct {
*KindService[LLMHost]
}
LLMHostsService holds the operations of LLMHosts: /api/v1/llmhosts/, and the manifest api's LLMHost kind. An LLMHost is an open-weight model that the platform serves on its own Kubernetes cluster.
func (*LLMHostsService) Deploy ¶
func (s *LLMHostsService) Deploy(ctx context.Context, id ID) (*LLMHostStatus, error)
Deploy deploys an LLMHost on the platform's cluster. This creates real, billable infrastructure, e.g. GPU nodes. Check LLMHostsService.Plan first.
func (*LLMHostsService) Discover ¶
func (s *LLMHostsService) Discover(ctx context.Context, params *DiscoverParams) ([]DiscoveredModel, error)
Discover searches a public model catalog for models that an LLMHost can serve, and returns them, each with the LLMHost manifest that would serve it.
func (*LLMHostsService) DiscoverManifest ¶
func (s *LLMHostsService) DiscoverManifest(ctx context.Context, repository string, params *DiscoverManifestParams) (*Manifest, error)
DiscoverManifest returns an LLMHost manifest for a model in a public catalog, e.g. Qwen/Qwen2.5-7B-Instruct, ready to apply.
func (*LLMHostsService) Logs ¶
func (s *LLMHostsService) Logs(ctx context.Context, id ID, params *LogsParams) (*LLMHostLogs, error)
Logs returns the latest log lines of an LLMHost's pods.
func (*LLMHostsService) Plan ¶
func (s *LLMHostsService) Plan(ctx context.Context, id ID) (*LLMHostPlan, error)
Plan returns the Kubernetes resources that deploying an LLMHost would create, without creating them.
func (*LLMHostsService) Report ¶
func (s *LLMHostsService) Report(ctx context.Context) (*LLMHostReport, error)
Report returns a report of every LLMHost that the user may read: counts by status and engine, and estimated costs.
func (*LLMHostsService) Status ¶
func (s *LLMHostsService) Status(ctx context.Context, id ID) (*LLMHostStatus, error)
Status returns an LLMHost's state, read from Kubernetes now: its status, replicas and pods.
func (*LLMHostsService) Undeploy ¶
func (s *LLMHostsService) Undeploy(ctx context.Context, id ID, params *UndeployParams) (*LLMHostStatus, error)
Undeploy undeploys an LLMHost, and returns its state.
type LogsParams ¶
type LogsParams struct {
// Tail is how many lines, 200 by default.
Tail int
}
LogsParams are the optional arguments of LLMHostsService.Logs.
type MCPClient ¶
type MCPClient struct {
Resource
// Transport is http, sse or stdio.
Transport string `json:"transport,omitempty"`
EndpointURL string `json:"endpointUrl,omitempty"`
Command string `json:"command,omitempty"`
Timeout *int `json:"timeout,omitempty"`
AuthType string `json:"authType,omitempty"`
AllowedTools []string `json:"allowedTools,omitempty"`
AllowedResources []string `json:"allowedResources,omitempty"`
IncludeInstructions *bool `json:"includeInstructions,omitempty"`
CacheTTL *int `json:"cacheTtl,omitempty"`
IsActive *bool `json:"isActive,omitempty"`
// Status is e.g. connected or error.
Status string `json:"status,omitempty"`
Priority *int `json:"priority,omitempty"`
ProtocolVersion string `json:"protocolVersion,omitempty"`
ServerName string `json:"serverName,omitempty"`
ServerVersion string `json:"serverVersion,omitempty"`
// Tools are the names of every tool that the server offers.
Tools []string `json:"tools,omitempty"`
LastConnectedAt string `json:"lastConnectedAt,omitempty"`
LastError string `json:"lastError,omitempty"`
}
MCPClient is a connection to a Model Context Protocol server: the server, how to reach it, and which of its tools the LLM may call.
type MCPClientStatus ¶
type MCPClientStatus struct {
Name string `json:"name"`
Status string `json:"status,omitempty"`
ProtocolVersion string `json:"protocolVersion,omitempty"`
ServerName string `json:"serverName,omitempty"`
ServerVersion string `json:"serverVersion,omitempty"`
LastConnected string `json:"lastConnected,omitempty"`
LastError string `json:"lastError,omitempty"`
// Error is the error of a failed refresh.
Error string `json:"error,omitempty"`
}
MCPClientStatus is the connection state of an MCPClient.
type MCPClientTools ¶
type MCPClientTools struct {
MCPClientStatus
Instructions string `json:"instructions,omitempty"`
Tools []MCPTool `json:"tools"`
}
MCPClientTools are an MCPClient's allowed tools, and the server's instructions.
type MCPClientsService ¶
type MCPClientsService struct {
*KindService[MCPClient]
}
MCPClientsService holds the operations of MCPClients: /api/v1/mcpclients/, and the manifest api's MCPClient kind. An MCPClient is the platform's connection to a Model Context Protocol server.
func (*MCPClientsService) CallTool ¶
func (s *MCPClientsService) CallTool(ctx context.Context, id ID, tool string, arguments JSONObject) (*MCPToolResult, error)
CallTool calls one of an MCPClient's tools with its arguments, as its input schema describes them, or nil for none. Only the owner may call tools. Check the result's IsError: a tool reports its own failures in its result.
func (*MCPClientsService) Refresh ¶
func (s *MCPClientsService) Refresh(ctx context.Context, id ID) (*MCPClientStatus, error)
Refresh reconnects to an MCPClient's server, reloads its catalog, and returns the connection's state. Only the owner may refresh.
func (*MCPClientsService) Tools ¶
func (s *MCPClientsService) Tools(ctx context.Context, id ID, params *MCPToolsParams) (*MCPClientTools, error)
Tools returns the tools that an MCPClient allows the LLM to call, from the server's cached catalog, with the connection's state and the server's instructions.
type MCPTool ¶
type MCPTool struct {
Name string `json:"name"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
// InputSchema is the tool's arguments, as a JSON Schema.
InputSchema JSONObject `json:"inputSchema,omitempty"`
ReadOnly *bool `json:"readOnly,omitempty"`
Destructive *bool `json:"destructive,omitempty"`
}
MCPTool is a tool of an MCP server, which the MCPClient allows the LLM to call.
type MCPToolResult ¶
type MCPToolResult struct {
// Name is the MCPClient's name.
Name string `json:"name"`
Tool string `json:"tool"`
IsError bool `json:"isError"`
// Content is the tool's result, as text.
Content string `json:"content,omitempty"`
}
MCPToolResult is the result of a tool call. Check IsError: a tool reports its own failures in its result.
type MCPToolsParams ¶
type MCPToolsParams struct {
// Refresh reads the catalog from the server now, instead of from the cache.
Refresh bool
}
MCPToolsParams are the optional arguments of MCPClientsService.Tools.
type Manifest ¶
type Manifest struct {
APIVersion string `json:"apiVersion"`
// Kind is the resource kind, e.g. LLMClient. See [Client.Kinds].
Kind string `json:"kind"`
Metadata ManifestMetadata `json:"metadata"`
// Spec is the resource's specification.
Spec JSONObject `json:"spec"`
// Status is read-only state, returned by describe.
Status JSONObject `json:"status,omitempty"`
// Extra holds the top-level fields that the SDK doesn't declare.
Extra map[string]json.RawMessage `json:"-"`
}
Manifest is a Smarter Application Manifest: the YAML document that declares a resource.
It has the same four sections as a Kubernetes manifest: APIVersion, Kind, Metadata and Spec. Describe adds a read-only Status. Spec is a JSON object, because its fields depend on the kind: use ToSAM for the kind's typed struct. Top-level fields that the SDK doesn't declare are kept in Extra, so describe, change and apply loses nothing.
func ManifestFromFile ¶
ManifestFromFile reads a manifest from a YAML or JSON file.
func ManifestFromObject ¶
func ManifestFromObject(object JSONObject) (*Manifest, error)
ManifestFromObject converts a manifest's decoded JSON (or YAML) object into a Manifest.
func ManifestFromSAM ¶
ManifestFromSAM converts a typed SAM struct, e.g. a *sam.Guardrail, into a Manifest.
func ManifestFromYAML ¶
ManifestFromYAML parses a manifest from YAML (or JSON) text.
func ParseManifest ¶
ParseManifest decodes a manifest from JSON, and checks that it has a kind and a name.
func (Manifest) MarshalJSON ¶
MarshalJSON encodes the manifest, with the fields that the SDK doesn't declare.
func (*Manifest) SAM ¶
SAM decodes the manifest into its kind's typed struct, e.g. a *sam.Guardrail, which callers get with a type switch or assertion. It returns a *ValueError if the SDK has no struct of the kind, or the manifest doesn't match it. See also ToSAM.
func (*Manifest) ToApply ¶
ToApply returns the manifest as the api's apply and validate commands take it: without its read-only Status.
func (*Manifest) ToYAML ¶
ToYAML returns the manifest as YAML text, without its read-only Status, ready to apply, with its sections in the order of the manifest.
func (*Manifest) UnmarshalJSON ¶
UnmarshalJSON decodes the manifest, and keeps the fields that the SDK doesn't declare.
type ManifestList ¶
type ManifestList struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Name string `json:"name,omitempty"`
Metadata ManifestListMetadata `json:"metadata"`
Data ManifestListData `json:"data"`
}
ManifestList is the result of get: the resources of one kind, as a table. Data.Items are the rows, and Data.Titles their columns. The columns depend on the kind.
func (*ManifestList) Names ¶
func (l *ManifestList) Names() []string
Names returns the names of the resources: each row's name, or its username for the User kind.
type ManifestListData ¶
type ManifestListData struct {
Titles []ManifestListTitle `json:"titles"`
Items []JSONObject `json:"items"`
}
ManifestListData is the table of a get result.
type ManifestListMetadata ¶
type ManifestListMetadata struct {
Count int `json:"count"`
}
ManifestListMetadata is the metadata of a get result.
type ManifestListTitle ¶
ManifestListTitle is a column of a get result: the field's name, and its Django field type.
type ManifestMetadata ¶
type ManifestMetadata struct {
// Name is the resource's name, unique per account and kind, in snake_case.
Name string `json:"name"`
Description string `json:"description,omitempty"`
// Version is the resource's semantic version, e.g. 1.0.0.
Version string `json:"version,omitempty"`
Tags []string `json:"tags,omitempty"`
// Annotations are key-value pairs, as a list of single-key objects.
Annotations []JSONObject `json:"annotations,omitempty"`
// Extra holds the fields that the SDK doesn't declare.
Extra map[string]json.RawMessage `json:"-"`
}
ManifestMetadata is a manifest's metadata: the resource's name, and descriptive information about it. Fields that the SDK doesn't declare are kept in Extra.
func (ManifestMetadata) MarshalJSON ¶
func (m ManifestMetadata) MarshalJSON() ([]byte, error)
MarshalJSON encodes the metadata, with the fields that the SDK doesn't declare.
func (*ManifestMetadata) UnmarshalJSON ¶
func (m *ManifestMetadata) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the metadata, and keeps the fields that the SDK doesn't declare.
type ManifestValidation ¶
type ManifestValidation struct {
Valid bool `json:"valid"`
Errors []JSONValue `json:"errors,omitempty"`
}
ManifestValidation is the result of validating a manifest, without applying it.
type ManifestsService ¶
type ManifestsService struct {
// contains filtered or unexported fields
}
ManifestsService is the manifest api: the brokered, journaled /api/v1/cli/ endpoints that the smarter cli uses. Every resource kind is managed through the same verbs: apply, validate, get, describe, delete, deploy, undeploy and logs. The kind's broker on the platform validates the manifest with its Pydantic models and applies its business rules, so this is the only way that the SDK writes resources (ADR-003).
func (*ManifestsService) Apply ¶
func (s *ManifestsService) Apply(ctx context.Context, manifest *Manifest) (*JournalMessage, error)
Apply creates or updates a resource from its manifest. The platform compares the manifest with the resource's current state and makes the changes that the difference requires. The error matches ErrBadRequest if the platform rejects the manifest.
Example ¶
server := examplePlatform()
defer server.Close()
client := exampleClient(server)
manifest, err := smarter.ManifestFromYAML(`
apiVersion: smarter.sh/v1
kind: Secret
metadata:
name: openai_api_key
description: The OpenAI api key.
spec:
config:
value: sk-...
`)
if err != nil {
log.Fatal(err)
}
response, err := client.Manifests.Apply(context.Background(), manifest)
if err != nil {
log.Fatal(err)
}
fmt.Println(response.Message != "")
Output: true
func (*ManifestsService) Delete ¶
func (s *ManifestsService) Delete(ctx context.Context, kind, name string) (*JournalMessage, error)
Delete permanently deletes a resource. The error matches ErrNotFound if it doesn't exist.
func (*ManifestsService) Deploy ¶
func (s *ManifestsService) Deploy(ctx context.Context, kind, name string) (*JournalMessage, error)
Deploy deploys a resource, e.g. an LLMClient on its own host name.
This creates real infrastructure on the platform's cloud, e.g. DNS records, TLS certificates and Kubernetes ingresses, which may be billable. See Client.Kinds for the kinds that can be deployed.
func (*ManifestsService) Describe ¶
Describe returns a resource's manifest, with its read-only status, which ManifestsService.Apply accepts as is. The error matches ErrNotFound if the resource doesn't exist.
func (*ManifestsService) ExampleManifest ¶
ExampleManifest returns a valid example manifest of a kind, to start from.
func (*ManifestsService) Get ¶
func (s *ManifestsService) Get(ctx context.Context, kind, name string) (*ManifestList, error)
Get returns the resources of one kind, as a table: Data.Items are its rows, and Names() the resources' names. With a name, only the resource of that name.
func (*ManifestsService) JSONSchema ¶
func (s *ManifestsService) JSONSchema(ctx context.Context, kind string) (JSONObject, error)
JSONSchema returns the JSON Schema (draft 2020-12) of a kind's manifest, e.g. to validate manifests locally or to generate a form.
func (*ManifestsService) Logs ¶
func (s *ManifestsService) Logs(ctx context.Context, kind, name string) (*JournaledResponse[JSONObject], error)
Logs returns a resource's logs: the platform's message, and its data for the kinds that have logs.
func (*ManifestsService) Undeploy ¶
func (s *ManifestsService) Undeploy(ctx context.Context, kind, name string) (*JournalMessage, error)
Undeploy undoes a resource's deployment.
func (*ManifestsService) Validate ¶
func (s *ManifestsService) Validate(ctx context.Context, manifest *Manifest) (*ManifestValidation, error)
Validate validates a manifest without applying it, and returns whether it is valid, and its errors.
type MessageContent ¶
type MessageContent struct {
// Text is the content when it is a text.
Text string
// Parts is the content when it is a list of parts.
Parts []PromptChatAPIContentPart
// IsParts reports whether the content is a list of parts.
IsParts bool
}
MessageContent is a message's content: a text, or a list of content parts. Build one with TextContent or PartsContent.
func PartsContent ¶
func PartsContent(parts ...PromptChatAPIContentPart) *MessageContent
PartsContent returns a content of parts.
func TextContent ¶
func TextContent(text string) *MessageContent
TextContent returns a text content.
func (MessageContent) MarshalJSON ¶
func (c MessageContent) MarshalJSON() ([]byte, error)
MarshalJSON encodes the content as a string, or as a list of parts.
func (*MessageContent) UnmarshalJSON ¶
func (c *MessageContent) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes a string, or a list of parts.
type Option ¶
type Option func(*options)
Option configures a Client. Every option is optional: see NewClient for where each value is looked up when it isn't given.
func WithBaseURL ¶
WithBaseURL sets the platform's url, e.g. https://platform.example.com or http://localhost:9357.
func WithEnvironment ¶
func WithEnvironment(environment Environment) Option
WithEnvironment sets the environment of the smarter cli's configuration file to use: local, alpha, beta, next or prod.
func WithHTTPClient ¶
WithHTTPClient sets the *http.Client that sends the requests, e.g. one with a proxy. Its Timeout should be 0: the client applies its own timeout to each attempt.
func WithHeader ¶
WithHeader adds a header to every request.
func WithLogger ¶
WithLogger sets the logger. Without one, the client logs nothing, unless SMARTER_LOG is debug or info, which log to stderr. See ADR-007.
func WithLookupEnv ¶
WithLookupEnv sets the function that reads environment variables, os.LookupEnv by default, e.g. to configure a client from a map in a test.
func WithMaxRetries ¶
WithMaxRetries sets how many times a request that failed for a transient reason (a timeout, a 429, a 502, ...) is retried. 0 disables retries, e.g. so that a prompt is never sent twice.
func WithTimeout ¶
WithTimeout sets the timeout of each attempt of a request. For a stream, it applies to each read.
type Orchestrator ¶
type Orchestrator struct {
Resource
// Strategy is how its LLMClients collaborate: sequential, parallel, supervisor, router, voting or debate.
Strategy string `json:"strategy,omitempty"`
MaxIterations *int `json:"maxIterations,omitempty"`
IsActive *bool `json:"isActive,omitempty"`
// LLMClients are the ids of its LLMClients.
LLMClients []int `json:"llmclients,omitempty"`
}
Orchestrator is a multi-agent workflow that composes LLMClients.
type OrchestratorsService ¶
type OrchestratorsService struct {
*KindService[Orchestrator]
}
OrchestratorsService holds the operations of Orchestrators: /api/v1/orchestrators/, and the manifest api's Orchestrator kind.
type Owner ¶
type Owner struct {
User *UserRef `json:"user,omitempty"`
Account *AccountRef `json:"account,omitempty"`
}
Owner is the owner of a resource: its user profile, as the user and the account.
type PlatformStatus ¶
type PlatformStatus struct {
Infrastructures JSONObject `json:"infrastructures,omitempty"`
Compute JSONObject `json:"compute,omitempty"`
}
PlatformStatus is the response of Status: the state of the platform's infrastructure and compute. The sections' contents depend on how the platform is hosted, so they are JSON objects.
type PlatformVersion ¶
type PlatformVersion struct {
API APIVersion `json:"api"`
CLI *CLIVersion `json:"cli,omitempty"`
}
PlatformVersion is the response of Version.
type Plugin ¶
type Plugin struct {
Resource
PluginClass string `json:"pluginClass,omitempty"`
Kind string `json:"kind,omitempty"`
}
Plugin is a plugin's metadata. Its Kind is the manifest kind, e.g. ApiPlugin or SqlPlugin, and its PluginClass the implementation: api, skill, sql, static, websearch or imagesearch.
type PluginsService ¶
type PluginsService struct {
*KindService[Plugin]
}
PluginsService holds the operations of Plugins: /api/v1/plugins/, and the manifest api's plugin kinds. A plugin's manifest kind is its class, e.g. ApiPlugin or SqlPlugin: Apply accepts any of them, and Describe and Delete look the kind up by name.
func (*PluginsService) Apply ¶
func (s *PluginsService) Apply(ctx context.Context, manifest *Manifest) (*JournalMessage, error)
Apply creates or updates a plugin from its manifest, of any plugin kind. It returns a *ValueError if the manifest is not a plugin's.
func (*PluginsService) Delete ¶
func (s *PluginsService) Delete(ctx context.Context, name string) (*JournalMessage, error)
Delete permanently deletes a plugin.
func (*PluginsService) Retrieve ¶
Retrieve returns one plugin, by its id, from the list. The platform's plugins/<id>/ returns a plugin's manifest, not the plugin: see PluginsService.RetrieveManifest. The error matches ErrResourceNotFound if the user may read no plugin of that id.
func (*PluginsService) RetrieveManifest ¶
RetrieveManifest returns one plugin's manifest, by the plugin's id: what the Python SDK's plugins.retrieve() returns. The platform serves this only when its ALLOW_API_GET waffle switch is on. Otherwise it answers 405: use Find or Describe instead.
type PromptChatAPIChoice ¶
type PromptChatAPIChoice struct {
Index int `json:"index"`
// FinishReason is e.g. stop, length or tool_calls.
FinishReason string `json:"finish_reason,omitempty"`
Message *PromptChatAPIMessage `json:"message,omitempty"`
}
PromptChatAPIChoice is a choice of a chat completion.
type PromptChatAPICompletion ¶
type PromptChatAPICompletion struct {
ID string `json:"id,omitempty"`
Object string `json:"object,omitempty"`
Created *int64 `json:"created,omitempty"`
Model string `json:"model,omitempty"`
Choices []PromptChatAPIChoice `json:"choices"`
Usage *PromptChatAPIUsage `json:"usage,omitempty"`
SystemFingerprint string `json:"system_fingerprint,omitempty"`
ServiceTier string `json:"service_tier,omitempty"`
}
PromptChatAPICompletion is the LLM's chat completion, in the format of the OpenAI api.
type PromptChatAPIConfig ¶
type PromptChatAPIConfig struct {
Contract int `json:"contract,omitempty"`
// SessionKey is the chat session's key.
SessionKey string `json:"session_key"`
// SandboxMode is true for a workbench url.
SandboxMode bool `json:"sandbox_mode"`
// DebugMode is the platform's ENABLE_REACTAPP_DEBUG_MODE waffle switch.
DebugMode bool `json:"debug_mode"`
MetaData PromptChatAPIMetaData `json:"meta_data"`
LLMClient PromptChatAPILLMClient `json:"llmclient"`
History PromptChatAPIHistory `json:"history"`
Plugins PromptChatAPIPluginList `json:"plugins"`
Functions *PromptChatAPIFunctionList `json:"functions,omitempty"`
}
PromptChatAPIConfig is an LLMClient's chat configuration: the LLMClient, the chat session's key and history, and its plugins and functions. A new session's configuration has an empty history. Pass its SessionKey to the prompt api to continue the session.
type PromptChatAPIConfigRequest ¶
type PromptChatAPIConfigRequest struct {
// SessionKey is the chat session's key, or "" for a new session.
SessionKey string `json:"session_key,omitempty"`
}
PromptChatAPIConfigRequest is the configuration api's request body.
type PromptChatAPIConfigResponse ¶
type PromptChatAPIConfigResponse struct {
PromptChatAPIEnvelope
Data PromptChatAPIConfig `json:"data"`
}
PromptChatAPIConfigResponse is the configuration api's response.
type PromptChatAPIContentPart ¶
type PromptChatAPIContentPart struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ImageURL *PromptChatAPIImageURL `json:"image_url,omitempty"`
InputAudio *PromptChatAPIInputAudio `json:"input_audio,omitempty"`
File *PromptChatAPIFileRef `json:"file,omitempty"`
Refusal string `json:"refusal,omitempty"`
}
PromptChatAPIContentPart is a part of a message whose content is a list of parts. Its Type says which of its other fields it has: text (Text), image_url (ImageURL), input_audio (InputAudio), file (File) or refusal (Refusal). It mirrors the platform's PromptChatApiTextPart, PromptChatApiImagePart, PromptChatApiAudioPart, PromptChatApiFilePart and PromptChatApiRefusalPart.
type PromptChatAPIEnvelope ¶
type PromptChatAPIEnvelope struct {
// API is the api version, e.g. "smarter.sh/v1".
API string `json:"api"`
Metadata PromptChatAPIJournalMetadata `json:"metadata"`
}
PromptChatAPIEnvelope holds the fields that every chat response adds beside its data.
type PromptChatAPIErrorBody ¶
type PromptChatAPIErrorBody struct {
// ErrorClass is the name of the error's class, e.g. NotFound or LLMProviderError.
ErrorClass string `json:"errorClass"`
// Description is a human-readable description.
Description string `json:"description"`
// Status is the http status.
Status int `json:"status"`
}
PromptChatAPIErrorBody is the error of a chat error response.
type PromptChatAPIErrorResponse ¶
type PromptChatAPIErrorResponse struct {
Error PromptChatAPIErrorBody `json:"error"`
API string `json:"api,omitempty"`
Metadata *PromptChatAPIJournalMetadata `json:"metadata,omitempty"`
}
PromptChatAPIErrorResponse is a chat error response.
type PromptChatAPIFileRef ¶
type PromptChatAPIFileRef struct {
FileData string `json:"file_data,omitempty"`
FileID string `json:"file_id,omitempty"`
Filename string `json:"filename,omitempty"`
}
PromptChatAPIFileRef is a file, base64 encoded, or by the provider's file id.
type PromptChatAPIFunctionCall ¶
type PromptChatAPIFunctionCall struct {
Name string `json:"name"`
// Arguments are the function's arguments, as a JSON string.
Arguments string `json:"arguments"`
}
PromptChatAPIFunctionCall is the function that a tool call calls.
type PromptChatAPIFunctionList ¶
type PromptChatAPIFunctionList struct {
MetaData PromptChatAPIListMetaData `json:"meta_data"`
Functions []PromptChatAPILLMClientFunction `json:"functions"`
}
PromptChatAPIFunctionList holds the LLMClient's built-in functions.
type PromptChatAPIHistory ¶
type PromptChatAPIHistory struct {
// ChatHistory holds the session's messages, which restore the chat thread.
ChatHistory []PromptChatAPIMessage `json:"chat_history"`
PromptToolCallHistory []PromptChatAPIPromptToolCall `json:"prompt_tool_call_history,omitempty"`
PromptPluginUsageHistory []PromptChatAPIPromptPluginUsage `json:"prompt_plugin_usage_history,omitempty"`
PluginSelectorHistory []PromptChatAPIPluginSelection `json:"plugin_selector_history,omitempty"`
LLMClientRequestHistory []PromptChatAPILLMClientRequest `json:"llmclient_request_history,omitempty"`
}
PromptChatAPIHistory is the chat session's history.
type PromptChatAPIImageURL ¶
type PromptChatAPIImageURL struct {
URL string `json:"url"`
// Detail is auto, low or high.
Detail string `json:"detail,omitempty"`
}
PromptChatAPIImageURL is an image, by its url or as a data url.
type PromptChatAPIInputAudio ¶
type PromptChatAPIInputAudio struct {
Data string `json:"data"`
// Format is wav or mp3.
Format string `json:"format"`
}
PromptChatAPIInputAudio is audio, base64 encoded.
type PromptChatAPIJournalMetadata ¶
type PromptChatAPIJournalMetadata struct {
// Command is the journal's command, e.g. prompt.
Command string `json:"command,omitempty"`
// Thing is the journal's thing, e.g. LLMClient.
Thing string `json:"thing,omitempty"`
Key string `json:"key,omitempty"`
}
PromptChatAPIJournalMetadata is the metadata of a chat response.
type PromptChatAPILLMClient ¶
type PromptChatAPILLMClient struct {
ID int `json:"id"`
Name string `json:"name"`
// URLLLMClient is the url of the LLMClient's prompt api.
URLLLMClient string `json:"url_llmclient,omitempty"`
Version string `json:"version,omitempty"`
Deployed *bool `json:"deployed,omitempty"`
Provider string `json:"provider,omitempty"`
DefaultModel string `json:"default_model,omitempty"`
// DefaultSystemRole is the system prompt of a new chat session.
DefaultSystemRole string `json:"default_system_role,omitempty"`
AppName string `json:"app_name,omitempty"`
AppAssistant string `json:"app_assistant,omitempty"`
AppWelcomeMessage string `json:"app_welcome_message,omitempty"`
AppExamplePrompts []string `json:"app_example_prompts,omitempty"`
AppPlaceholder string `json:"app_placeholder,omitempty"`
AppInfoURL string `json:"app_info_url,omitempty"`
AppFileAttachment *bool `json:"app_file_attachment,omitempty"`
Styles *PromptChatAPIStyles `json:"styles,omitempty"`
}
PromptChatAPILLMClient is the LLMClient, as its configuration describes it.
type PromptChatAPILLMClientFunction ¶
type PromptChatAPILLMClientFunction struct {
PromptChatAPIOrmModel
LLMClient int `json:"llmclient"`
// Name is get_current_weather, date_calculator or calculator.
Name string `json:"name,omitempty"`
}
PromptChatAPILLMClientFunction is a built-in function of the LLMClient.
type PromptChatAPILLMClientPlugin ¶
type PromptChatAPILLMClientPlugin struct {
PromptChatAPIOrmModel
LLMClient int `json:"llmclient"`
PluginMeta PromptChatAPIPluginMeta `json:"plugin_meta"`
}
PromptChatAPILLMClientPlugin is a plugin of the LLMClient.
type PromptChatAPILLMClientRequest ¶
type PromptChatAPILLMClientRequest struct {
PromptChatAPIOrmModel
LLMClient int `json:"llmclient"`
Request *PromptChatAPIPromptRequest `json:"request,omitempty"`
SessionKey string `json:"session_key,omitempty"`
IsAggregation *bool `json:"is_aggregation,omitempty"`
}
PromptChatAPILLMClientRequest is a request that Smarter sent to the LLM.
type PromptChatAPIListMetaData ¶
type PromptChatAPIListMetaData struct {
TotalPlugins *int `json:"total_plugins,omitempty"`
PluginsReturned *int `json:"plugins_returned,omitempty"`
TotalFunctions *int `json:"total_functions,omitempty"`
FunctionsReturned *int `json:"functions_returned,omitempty"`
}
PromptChatAPIListMetaData holds the counts of a list of the LLMClient's plugins or functions.
type PromptChatAPIMessage ¶
type PromptChatAPIMessage struct {
// Role is system, assistant, user, tool, smarter or smarter_error.
Role string `json:"role"`
// Content is the message's text, or a list of content parts, or nil, e.g. for an assistant's tool
// calls. It is always encoded, as null when it is nil: the platform requires the key.
Content *MessageContent `json:"content"`
// ToolCalls are an assistant message's tool calls.
ToolCalls []PromptChatAPIToolCall `json:"tool_calls,omitempty"`
// ToolCallID is the tool call that a tool message answers.
ToolCallID string `json:"tool_call_id,omitempty"`
// Name is the name of a tool message's function.
Name string `json:"name,omitempty"`
}
PromptChatAPIMessage is a message of a chat thread, in the format of the OpenAI api.
Smarter adds its own roles: smarter for informational messages (e.g. the prompt's configuration, the tools presented to the LLM, and its token charges), and smarter_error. These are saved in the session's history, and are never sent to the LLM.
func Text ¶
func Text(text string) []PromptChatAPIMessage
Text returns a prompt of one user message, for LLMClientsService.Prompt and LLMClientsService.Stream.
func UserMessage ¶
func UserMessage(text string) PromptChatAPIMessage
UserMessage returns a user message with a text.
func (PromptChatAPIMessage) Text ¶
func (m PromptChatAPIMessage) Text() string
Text returns the message's text: its content, or the text of its text parts, joined by blank lines.
type PromptChatAPIMetaData ¶
type PromptChatAPIMetaData struct {
Ready *bool `json:"ready,omitempty"`
IsValid *bool `json:"is_valid,omitempty"`
IsDeployed *bool `json:"is_deployed,omitempty"`
}
PromptChatAPIMetaData is the LLMClient's state.
type PromptChatAPIOrmModel ¶
type PromptChatAPIOrmModel struct {
ID int `json:"id"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
}
PromptChatAPIOrmModel holds the fields of a Django row that the contract returns.
type PromptChatAPIPluginList ¶
type PromptChatAPIPluginList struct {
MetaData PromptChatAPIListMetaData `json:"meta_data"`
Plugins []PromptChatAPILLMClientPlugin `json:"plugins"`
}
PromptChatAPIPluginList holds the LLMClient's plugins.
type PromptChatAPIPluginMeta ¶
type PromptChatAPIPluginMeta struct {
PromptChatAPIOrmModel
Name string `json:"name"`
Description string `json:"description,omitempty"`
Version string `json:"version,omitempty"`
Tags []string `json:"tags,omitempty"`
// Annotations are a list of JSON objects, or a JSON object.
Annotations JSONValue `json:"annotations,omitempty"`
// PluginClass is api, skill, sql, static, websearch or imagesearch.
PluginClass string `json:"plugin_class"`
}
PromptChatAPIPluginMeta is a plugin's metadata.
type PromptChatAPIPluginSelection ¶
type PromptChatAPIPluginSelection struct {
PromptChatAPIOrmModel
PluginSelector int `json:"plugin_selector"`
SearchTerm string `json:"search_term,omitempty"`
Messages []PromptChatAPIMessage `json:"messages,omitempty"`
SessionKey string `json:"session_key,omitempty"`
}
PromptChatAPIPluginSelection is a plugin selector's decision in the chat session.
type PromptChatAPIProgressEvent ¶
type PromptChatAPIProgressEvent struct {
// Type is llm_request, tool_requested, tool_responded, plugin_called, mcp_tool_called,
// mcp_tool_responded or mcp_tool_failed.
Type string `json:"type"`
// Message is a short sentence, which a chat ui can display as is.
Message string `json:"message"`
// Fields holds every field of the event, including Type and Message.
Fields JSONObject `json:"-"`
}
PromptChatAPIProgressEvent is the data of a progress event: a step of a running prompt. Events may carry more fields, depending on their type, e.g. tool and arguments: they are in Fields.
func (*PromptChatAPIProgressEvent) UnmarshalJSON ¶
func (e *PromptChatAPIProgressEvent) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the event, and keeps all of its fields in Fields.
type PromptChatAPIProgressResult ¶
type PromptChatAPIProgressResult struct {
// Status is the prompt's http status.
Status int `json:"status"`
// Response is exactly the JSON of a non-streaming response, or of an error response.
Response PromptChatAPIPromptResponse `json:"response"`
}
PromptChatAPIProgressResult is the data of the final result event.
type PromptChatAPIPromptPluginUsage ¶
type PromptChatAPIPromptPluginUsage struct {
PromptChatAPIOrmModel
Prompt int `json:"prompt"`
Plugin int `json:"plugin"`
InputText string `json:"input_text,omitempty"`
}
PromptChatAPIPromptPluginUsage is a use of a plugin in the chat session.
type PromptChatAPIPromptRequest ¶
type PromptChatAPIPromptRequest struct {
SessionKey string `json:"session_key,omitempty"`
Messages []PromptChatAPIMessage `json:"messages"`
}
PromptChatAPIPromptRequest is the prompt api's request body.
type PromptChatAPIPromptResponse ¶
type PromptChatAPIPromptResponse struct {
PromptChatAPIEnvelope
Data PromptChatAPIPromptResult `json:"data"`
Error *PromptChatAPIErrorBody `json:"error,omitempty"`
}
PromptChatAPIPromptResponse is the prompt api's response. A failed prompt has Error too, and its Data.Messages include a smarter_error message. A streamed prompt's error response has only Error.
func (PromptChatAPIPromptResponse) Text ¶
func (r PromptChatAPIPromptResponse) Text() string
Text returns the text of the LLM's final reply. See PromptChatAPIPromptResult.Text.
type PromptChatAPIPromptResult ¶
type PromptChatAPIPromptResult struct {
Contract int `json:"contract,omitempty"`
// Status is the prompt's http status: 200, or the LLM provider's error status.
Status int `json:"status"`
// Messages are the messages that the prompt added to the chat thread, in order.
Messages []PromptChatAPIMessage `json:"messages"`
// Completion is the LLM's chat completion.
Completion *PromptChatAPICompletion `json:"completion,omitempty"`
// Plugins are the plugins that Smarter selected.
Plugins []string `json:"plugins"`
// Tools are the functions that the LLM could call.
Tools []string `json:"tools"`
}
PromptChatAPIPromptResult is the result of a prompt.
func (PromptChatAPIPromptResult) AssistantMessages ¶
func (r PromptChatAPIPromptResult) AssistantMessages() []PromptChatAPIMessage
AssistantMessages returns the assistant messages that the prompt added: the LLM's replies and tool calls.
func (PromptChatAPIPromptResult) Text ¶
func (r PromptChatAPIPromptResult) Text() string
Text returns the text of the LLM's final reply: the last assistant message that has content, or "".
type PromptChatAPIPromptToolCall ¶
type PromptChatAPIPromptToolCall struct {
PromptChatAPIOrmModel
Prompt int `json:"prompt"`
Plugin *int `json:"plugin,omitempty"`
FunctionName string `json:"function_name,omitempty"`
FunctionArgs string `json:"function_args,omitempty"`
Request JSONValue `json:"request,omitempty"`
Response JSONValue `json:"response,omitempty"`
}
PromptChatAPIPromptToolCall is a tool call of the chat session.
type PromptChatAPIStyleSection ¶
type PromptChatAPIStyleSection struct {
BackgroundColor string `json:"background_color,omitempty"`
Color string `json:"color,omitempty"`
BorderColor string `json:"border_color,omitempty"`
InfoColor string `json:"info_color,omitempty"`
LinkColor string `json:"link_color,omitempty"`
EditorBackgroundColor string `json:"editor_background_color,omitempty"`
PlaceholderColor string `json:"placeholder_color,omitempty"`
}
PromptChatAPIStyleSection holds the colors of one section of the chat ui.
type PromptChatAPIStyles ¶
type PromptChatAPIStyles struct {
AppLogoURL string `json:"app_logo_url,omitempty"`
AppBackgroundImageURL string `json:"app_background_image_url,omitempty"`
AppBackgroundImageSize string `json:"app_background_image_size,omitempty"`
AssistantAvatarURL string `json:"assistant_avatar_url,omitempty"`
UserAvatarURL string `json:"user_avatar_url,omitempty"`
FontFamily string `json:"font_family,omitempty"`
GoogleFont string `json:"google_font,omitempty"`
FontSize string `json:"font_size,omitempty"`
BorderRadius string `json:"border_radius,omitempty"`
MainContainer *PromptChatAPIStyleSection `json:"main_container,omitempty"`
ConversationHeader *PromptChatAPIStyleSection `json:"conversation_header,omitempty"`
MessageList *PromptChatAPIStyleSection `json:"message_list,omitempty"`
IncomingMessage *PromptChatAPIStyleSection `json:"incoming_message,omitempty"`
OutgoingMessage *PromptChatAPIStyleSection `json:"outgoing_message,omitempty"`
MessageInput *PromptChatAPIStyleSection `json:"message_input,omitempty"`
Buttons *PromptChatAPIStyleSection `json:"buttons,omitempty"`
TypingIndicator *PromptChatAPIStyleSection `json:"typing_indicator,omitempty"`
}
PromptChatAPIStyles are the LLMClient's chat ui styles.
type PromptChatAPITokenDetails ¶
type PromptChatAPITokenDetails struct {
ReasoningTokens *int `json:"reasoning_tokens,omitempty"`
CachedTokens *int `json:"cached_tokens,omitempty"`
AudioTokens *int `json:"audio_tokens,omitempty"`
}
PromptChatAPITokenDetails is the breakdown of a completion's tokens.
type PromptChatAPIToolCall ¶
type PromptChatAPIToolCall struct {
ID string `json:"id"`
Type string `json:"type,omitempty"`
Function PromptChatAPIFunctionCall `json:"function"`
}
PromptChatAPIToolCall is a tool call of an assistant message.
type PromptChatAPIUsage ¶
type PromptChatAPIUsage struct {
PromptTokens *int `json:"prompt_tokens,omitempty"`
CompletionTokens *int `json:"completion_tokens,omitempty"`
TotalTokens *int `json:"total_tokens,omitempty"`
PromptTokensDetails *PromptChatAPITokenDetails `json:"prompt_tokens_details,omitempty"`
CompletionTokensDetails *PromptChatAPITokenDetails `json:"completion_tokens_details,omitempty"`
}
PromptChatAPIUsage is a chat completion's token usage.
type PromptError ¶
type PromptError struct {
Message string
// Response is the error response.
Response *PromptChatAPIPromptResponse
}
PromptError reports that a streamed prompt failed: its result event carried an error response.
func (*PromptError) Error ¶
func (e *PromptError) Error() string
type PromptHistoryService ¶
type PromptHistoryService struct {
// contains filtered or unexported fields
}
PromptHistoryService reads the chat sessions of the api key's user, and their tool calls and plugin uses, newest first: /api/v1/prompts/history/. An account admin also reads the sessions of their account's users, and a superuser every session.
func (*PromptHistoryService) PluginUsage ¶
func (s *PromptHistoryService) PluginUsage(ctx context.Context) ([]PromptPluginUsage, error)
PluginUsage returns the plugin uses of the chat sessions.
func (*PromptHistoryService) PluginUse ¶
func (s *PromptHistoryService) PluginUse(ctx context.Context, id ID) (*PromptPluginUsage, error)
PluginUse returns a plugin use, by id.
func (*PromptHistoryService) Session ¶
func (s *PromptHistoryService) Session(ctx context.Context, id ID) (*PromptSession, error)
Session returns a chat session, by id.
func (*PromptHistoryService) Sessions ¶
func (s *PromptHistoryService) Sessions(ctx context.Context) ([]PromptSession, error)
Sessions returns the chat sessions.
func (*PromptHistoryService) ToolCall ¶
func (s *PromptHistoryService) ToolCall(ctx context.Context, id ID) (*PromptToolCall, error)
ToolCall returns a tool call, by id.
func (*PromptHistoryService) ToolCalls ¶
func (s *PromptHistoryService) ToolCalls(ctx context.Context) ([]PromptToolCall, error)
ToolCalls returns the tool calls of the chat sessions, with the LLM requests that made them.
type PromptParams ¶
type PromptParams struct {
// SessionKey is the chat session's key, from [LLMClientsService.Config], to keep the prompt's
// history in that session, or "" for none.
SessionKey string
}
PromptParams are the optional arguments of a prompt.
type PromptPluginUsage ¶
type PromptPluginUsage struct {
ID int `json:"id"`
Prompt *SessionRef `json:"prompt,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
Plugin *Plugin `json:"plugin,omitempty"`
InputText string `json:"input_text,omitempty"`
}
PromptPluginUsage is a use of a plugin in a chat session.
type PromptSession ¶
type PromptSession struct {
ID int `json:"id"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
SessionKey string `json:"session_key,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
URL string `json:"url,omitempty"`
UserProfile *int `json:"user_profile,omitempty"`
LLMClient *int `json:"llmclient,omitempty"`
}
PromptSession is a chat session: one conversation with an LLMClient, by its session key.
type PromptStream ¶
type PromptStream struct {
// contains filtered or unexported fields
}
PromptStream is a prompt whose progress is streamed as Server-Sent Events. Read it like a bufio.Scanner:
stream := client.LLMClients.Stream(ctx, id, smarter.Text("What is sin(pi / 2)?"), nil)
defer stream.Close()
for stream.Next() {
fmt.Println(stream.Current().Message)
}
response, err := stream.Response()
Response is the prompt's response, exactly as a non-streaming prompt returns it, once Next has returned false.
Example ¶
server := examplePlatform()
defer server.Close()
client := exampleClient(server)
stream := client.LLMClients.Stream(context.Background(), smarter.IntID(6), smarter.Text("What is 17 times 23?"), nil)
defer func() { _ = stream.Close() }()
for stream.Next() {
if stream.Current().Type == "llm_request" {
fmt.Println("an LLM request")
break
}
}
Output: an LLM request
func (*PromptStream) Close ¶
func (s *PromptStream) Close() error
Close closes the stream's connection. It is safe to call more than once.
func (*PromptStream) Current ¶
func (s *PromptStream) Current() PromptChatAPIProgressEvent
Current returns the progress event that the last call of Next read, e.g. "Calling tool calculator".
func (*PromptStream) Err ¶
func (s *PromptStream) Err() error
Err returns the error that ended the stream, if any.
func (*PromptStream) Next ¶
func (s *PromptStream) Next() bool
Next reads the next progress event, which Current returns. It sends the request on its first call. It returns false at the end of the stream, or on an error, which Err returns.
func (*PromptStream) Response ¶
func (s *PromptStream) Response() (*PromptChatAPIPromptResponse, error)
Response returns the prompt's response, once the stream has been read. It returns the stream's error, a *PromptError if the prompt failed, or an error that matches ErrSmarter if the stream hasn't been read, or ended without a result.
func (*PromptStream) Result ¶
func (s *PromptStream) Result() *PromptChatAPIProgressResult
Result returns the final result event, once the stream has been read: the prompt's status and response. It is nil until then.
func (*PromptStream) UntilDone ¶
func (s *PromptStream) UntilDone() (*PromptChatAPIPromptResponse, error)
UntilDone reads the stream to its end, discarding the progress events, and returns the prompt's response. It closes the stream.
type PromptToolCall ¶
type PromptToolCall struct {
ID int `json:"id"`
Prompt *SessionRef `json:"prompt,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
// Plugin is the id of the plugin that the tool belongs to, if any.
Plugin *int `json:"plugin,omitempty"`
FunctionName string `json:"function_name,omitempty"`
FunctionArgs string `json:"function_args,omitempty"`
Request JSONValue `json:"request,omitempty"`
Response JSONValue `json:"response,omitempty"`
}
PromptToolCall is a tool call that the LLM made in a chat session.
type Provider ¶
type Provider struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
BaseURL string `json:"baseUrl,omitempty"`
IsActive *bool `json:"isActive,omitempty"`
}
Provider is an LLM provider that the platform is configured for, e.g. openai.
type ProviderModel ¶
type ProviderModel struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
MaxTokens *int `json:"maxTokens,omitempty"`
SupportsStreaming *bool `json:"supportsStreaming,omitempty"`
SupportsTools *bool `json:"supportsTools,omitempty"`
Metadata JSONObject `json:"metadata,omitempty"`
}
ProviderModel is a model of an LLM provider.
type ProvidersService ¶
type ProvidersService struct {
// contains filtered or unexported fields
}
ProvidersService reads the LLM providers that the platform is configured for, e.g. openai or anthropic, and their models: /api/v1/providers/.
func (*ProvidersService) List ¶
func (s *ProvidersService) List(ctx context.Context) ([]Provider, error)
List returns the providers.
func (*ProvidersService) Models ¶
func (s *ProvidersService) Models(ctx context.Context, name string) ([]ProviderModel, error)
Models returns a provider's models.
type ProxiesService ¶
type ProxiesService struct {
// contains filtered or unexported fields
}
ProxiesService gives authenticated passthrough access to LLM providers' own apis: /api/v1/proxy/. The platform holds the provider's api key, and callers use their Smarter api key instead. The platform serves these endpoints only when SMARTER_ENABLE_PROXY is true. The easiest way to call a proxy is with the provider's own SDK, with BaseURL and the client's APIKey.
func (*ProxiesService) BaseURL ¶
func (s *ProxiesService) BaseURL(name string) string
BaseURL returns a proxy's base url, for the provider's own SDK, e.g. https://platform.smarter.sh/api/v1/proxy/openai/.
func (*ProxiesService) List ¶
func (s *ProxiesService) List(ctx context.Context) ([]Proxy, error)
List returns the proxies that the user may call.
func (*ProxiesService) Request ¶
func (s *ProxiesService) Request(ctx context.Context, name, path string, params *ProxyRequestParams) (JSONValue, error)
Request sends a request to a provider's api, through its proxy, and returns the provider's JSON response, or nil for an empty one. The path, e.g. v1/chat/completions, must be one of the proxy's AllowedPaths.
type Proxy ¶
type Proxy struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Provider string `json:"provider,omitempty"`
// URL is the proxy's base url on the Smarter platform.
URL string `json:"url,omitempty"`
UpstreamURL string `json:"upstreamUrl,omitempty"`
AllowedPaths []string `json:"allowedPaths,omitempty"`
IsActive *bool `json:"isActive,omitempty"`
}
Proxy is authenticated passthrough access to an LLM provider's own api. The platform holds the provider's api key. Callers use their Smarter api key instead, and may reach only AllowedPaths.
type ProxyRequestParams ¶
type ProxyRequestParams struct {
// Method is the http method, POST by default.
Method string
// JSON is the JSON body, as the provider's api expects it, or nil for none.
JSON JSONValue
// Query holds query parameters.
Query url.Values
}
ProxyRequestParams are the optional arguments of ProxiesService.Request.
type ReactAppAssets ¶
type ReactAppAssets struct {
// JS are the JS files, the entry point's first.
JS []string `json:"js"`
// CSS are the CSS files, the entry point's first.
CSS []string `json:"css"`
}
ReactAppAssets are the ordered JS and CSS files of a React app's entry point, which a Django template includes.
type ReactAppBuildInfo ¶
type ReactAppBuildInfo struct {
// BuildTime is when the app was built.
BuildTime string `json:"buildTime"`
// Version is the version of the app's npm package.
Version string `json:"version"`
// BuildEnv is the build's NODE_ENV, e.g. production.
BuildEnv string `json:"buildEnv"`
}
ReactAppBuildInfo is the build information that each React package's vite.config.ts adds to its manifest.json, as _custom.
type ReadService ¶
type ReadService[T any] struct { // contains filtered or unexported fields }
ReadService lists and retrieves the rows of a read-only REST endpoint, e.g. an account's users.
type Resource ¶
type Resource struct {
ID int `json:"id"`
HashedID string `json:"hashedId,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Version string `json:"version,omitempty"`
Tags []string `json:"tags,omitempty"`
Annotations []JSONObject `json:"annotations,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
UserProfile *Owner `json:"userProfile,omitempty"`
CanDelete *bool `json:"canDelete,omitempty"`
ManifestURL string `json:"manifestUrl,omitempty"`
Ready *bool `json:"ready,omitempty"`
}
Resource holds the fields that every Smarter resource shares, as the REST api returns them: the same metadata as a manifest's metadata. Each resource's struct embeds it.
func (Resource) Ref ¶
Ref returns the resource's ID, for the methods that take one: its hashed id when it has one.
func (Resource) ResourceName ¶
ResourceName returns the resource's name.
type SAMJournalAPIEnvelope ¶
type SAMJournalAPIEnvelope struct {
// API is the api version, e.g. "smarter.sh/v1".
API string `json:"api,omitempty"`
Metadata *SAMJournalAPIMetadata `json:"metadata,omitempty"`
}
SAMJournalAPIEnvelope holds the fields that every journaled response adds beside its own data.
type SAMJournalAPIErrorBody ¶
type SAMJournalAPIErrorBody struct {
// ErrorClass is the name of the exception's class, e.g. SAMBrokerErrorNotFound.
ErrorClass string `json:"errorClass"`
// Stacktrace is the server's stack trace, when the platform includes it.
Stacktrace string `json:"stacktrace,omitempty"`
// Description is a human-readable description of the error.
Description string `json:"description,omitempty"`
// Status is the http status.
Status int `json:"status"`
// Args are the exception's arguments, or the request's url.
Args JSONValue `json:"args,omitempty"`
// Cause is the exception's cause.
Cause string `json:"cause,omitempty"`
// Context is the exception's context, or the response's thing and command.
Context string `json:"context,omitempty"`
// Thing is the journal's thing, e.g. Guardrail.
Thing string `json:"thing,omitempty"`
// Command is the journal's command, e.g. describe.
Command string `json:"command,omitempty"`
}
SAMJournalAPIErrorBody is the error of a journaled error response. Every error of the cli api has this shape.
type SAMJournalAPIErrorResponse ¶
type SAMJournalAPIErrorResponse struct {
SAMJournalAPIEnvelope
Error SAMJournalAPIErrorBody `json:"error"`
}
SAMJournalAPIErrorResponse is the body of a journaled error response.
type SAMJournalAPIMetadata ¶
type SAMJournalAPIMetadata struct {
// Command is the journal's command, e.g. apply.
Command string `json:"command"`
// Thing is the journal's thing, e.g. Guardrail. The string "None" when there is none.
Thing string `json:"thing"`
// Key is the key of the response's journal entry, when the journal is enabled.
Key string `json:"key,omitempty"`
}
SAMJournalAPIMetadata is the metadata of a journaled response: its command and thing, and the key of its journal entry.
type SearchParams ¶
type SearchParams struct {
// K is how many chunks to return, 4 by default. The platform caps it.
K int
// SearchType is similarity (the default), mmr (maximal marginal relevance), or
// similarity_score_threshold.
SearchType string
// ScoreThreshold is the minimum score, for similarity_score_threshold.
ScoreThreshold *float64
// FetchK is how many chunks mmr considers.
FetchK *int
// LambdaMult is mmr's balance of relevance (1) and diversity (0).
LambdaMult *float64
// Filter selects only chunks whose metadata match.
Filter JSONObject
}
SearchParams are the optional arguments of VectorstoresService.Search.
type Secret ¶
type Secret struct {
Resource
ExpiresAt string `json:"expiresAt,omitempty"`
LastAccessed string `json:"lastAccessed,omitempty"`
}
Secret is a secret's metadata. The api never returns a secret's value.
type SecretsService ¶
type SecretsService struct {
*KindService[Secret]
}
SecretsService holds the operations of Secrets: /api/v1/secrets/, and the manifest api's Secret kind. The api never returns a secret's value. Create and rotate secrets with Apply.
type ServerSentEvent ¶
type ServerSentEvent struct {
// Event is the event's type, e.g. "progress", or "" for an unnamed event.
Event string
// Data is the event's data: its data: lines, joined by newlines.
Data string
// ID is the event's id, if any.
ID string
// Retry is the reconnection time that the server asked for, in milliseconds, or 0.
Retry int
}
ServerSentEvent is one Server-Sent Event. The Smarter prompt api streams a prompt's progress as progress events while it runs, then one result event with the same JSON as a non-streaming response.
func (ServerSentEvent) JSON ¶
func (e ServerSentEvent) JSON(v any) error
JSON decodes the event's data into v.
type SessionRef ¶
type SessionRef struct {
// ID is the session's id.
ID int
// Session is the session, when the platform returned it, not only its id.
Session *PromptSession
}
SessionRef is a chat session that a history row refers to: the session itself, or only its id.
func (SessionRef) MarshalJSON ¶
func (s SessionRef) MarshalJSON() ([]byte, error)
MarshalJSON encodes the session, or its id.
func (*SessionRef) UnmarshalJSON ¶
func (s *SessionRef) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes a session, or a session's id.
type UndeployParams ¶
type UndeployParams struct {
// Purge deletes the LLMHost's model storage too.
Purge bool
}
UndeployParams are the optional arguments of LLMHostsService.Undeploy.
type User ¶
type User struct {
ID int `json:"id"`
Username string `json:"username"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Email string `json:"email,omitempty"`
IsStaff *bool `json:"isStaff,omitempty"`
IsSuperuser *bool `json:"isSuperuser,omitempty"`
}
User is a user of the platform.
type UserProfile ¶
type UserProfile struct {
Resource
User User `json:"user"`
Account AccountRef `json:"account"`
ProfileImageURL string `json:"profileImageUrl,omitempty"`
IsTest *bool `json:"isTest,omitempty"`
}
UserProfile is a user's membership of an account, which owns the resources that the user creates in it.
type ValueError ¶
ValueError reports an invalid argument, before any request is sent.
func (*ValueError) Error ¶
func (e *ValueError) Error() string
func (*ValueError) Unwrap ¶
func (e *ValueError) Unwrap() []error
Unwrap returns the cause, and ErrSmarter.
type Vectorsearch ¶
type Vectorsearch struct {
Resource
// SearchType is similarity, similarity_score_threshold or mmr.
SearchType string `json:"searchType,omitempty"`
// K is the number of chunks to return.
K *int `json:"k,omitempty"`
ScoreThreshold *float64 `json:"scoreThreshold,omitempty"`
// FetchK is the candidates of an mmr search.
FetchK *int `json:"fetchK,omitempty"`
// LambdaMult is an mmr search's diversity.
LambdaMult *float64 `json:"lambdaMult,omitempty"`
MetadataFilter JSONValue `json:"metadataFilter,omitempty"`
IsEnabled *bool `json:"isEnabled,omitempty"`
// Vectorstore is the id of its vectorstore.
Vectorstore *int `json:"vectorstore,omitempty"`
// AuthSecret is the id of its Secret, if any.
AuthSecret *int `json:"authSecret,omitempty"`
}
Vectorsearch is a retrieval pipeline over a vectorstore.
type VectorsearchesService ¶
type VectorsearchesService struct {
*KindService[Vectorsearch]
}
VectorsearchesService holds the operations of Vectorsearches: /api/v1/vectorsearches/, and the manifest api's Vectorsearch kind.
type Vectorstore ¶
type Vectorstore struct {
Resource
// Backend is e.g. qdrant or pinecone.
Backend string `json:"backend,omitempty"`
// Hosting is self_hosted or managed.
Hosting string `json:"hosting,omitempty"`
IsActive *bool `json:"isActive,omitempty"`
Dimension *int `json:"dimension,omitempty"`
Metric string `json:"metric,omitempty"`
EmbeddingsProvider string `json:"embeddingsProvider,omitempty"`
EmbeddingsModel string `json:"embeddingsModel,omitempty"`
// Status is e.g. pending, ready or error.
Status string `json:"status,omitempty"`
StatusMessage string `json:"statusMessage,omitempty"`
IndexName string `json:"indexName,omitempty"`
EndpointURL string `json:"endpointUrl,omitempty"`
VectorCount *int `json:"vectorCount,omitempty"`
DocumentCount *int `json:"documentCount,omitempty"`
SnapshotCount *int `json:"snapshotCount,omitempty"`
Spec JSONObject `json:"spec,omitempty"`
DeployedAt string `json:"deployedAt,omitempty"`
}
Vectorstore is a vector database, hosted by Smarter or by a provider, for retrieval-augmented generation.
type VectorstoreDocument ¶
type VectorstoreDocument struct {
ID int `json:"id"`
Name string `json:"name"`
CreatedAt string `json:"createdAt,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
// Source is upload, text or url.
Source string `json:"source,omitempty"`
ContentType string `json:"contentType,omitempty"`
// Status is e.g. pending, loaded, error or deleting.
Status string `json:"status,omitempty"`
ChunkCount *int `json:"chunkCount,omitempty"`
Metadata JSONObject `json:"metadata,omitempty"`
}
VectorstoreDocument is a document of a vectorstore: a file, a text or a url, split into chunks and embedded.
type VectorstoreDocumentDeleted ¶
type VectorstoreDocumentDeleted struct {
Document string `json:"document"`
Status string `json:"status"`
}
VectorstoreDocumentDeleted is a document that is being deleted, with its chunks.
type VectorstoreDocuments ¶
type VectorstoreDocuments struct {
Documents []VectorstoreDocument `json:"documents"`
}
VectorstoreDocuments are a vectorstore's documents.
type VectorstoreDocumentsAdded ¶
type VectorstoreDocumentsAdded struct {
Documents []VectorstoreDocument `json:"documents"`
// Duplicates are documents that already existed.
Duplicates []VectorstoreDocument `json:"duplicates,omitempty"`
Queued bool `json:"queued"`
Message string `json:"message,omitempty"`
}
VectorstoreDocumentsAdded is the result of adding documents. Documents are loaded asynchronously, and only once the vectorstore is deployed: see Queued.
type VectorstoreRestored ¶
type VectorstoreRestored struct {
Vectorstore string `json:"vectorstore"`
Restored string `json:"restored"`
VectorCount *int `json:"vectorCount,omitempty"`
}
VectorstoreRestored is the result of restoring a snapshot.
type VectorstoreSearchResult ¶
type VectorstoreSearchResult struct {
ID JSONValue `json:"id,omitempty"`
Text string `json:"text"`
Metadata JSONObject `json:"metadata,omitempty"`
Score *float64 `json:"score,omitempty"`
}
VectorstoreSearchResult is a chunk that matched a search.
type VectorstoreSearchResults ¶
type VectorstoreSearchResults struct {
Vectorstore string `json:"vectorstore"`
Results []VectorstoreSearchResult `json:"results"`
}
VectorstoreSearchResults are the chunks that matched a search, best first.
type VectorstoreSnapshot ¶
type VectorstoreSnapshot struct {
ID int `json:"id"`
Name string `json:"name,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Status string `json:"status,omitempty"`
Scheduled *bool `json:"scheduled,omitempty"`
SizeBytes *int64 `json:"sizeBytes,omitempty"`
}
VectorstoreSnapshot is a snapshot of a vectorstore's data.
type VectorstoreSnapshots ¶
type VectorstoreSnapshots struct {
Snapshots []VectorstoreSnapshot `json:"snapshots"`
}
VectorstoreSnapshots are a vectorstore's snapshots.
type VectorstoreStatus ¶
type VectorstoreStatus struct {
Vectorstore string `json:"vectorstore"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
VectorCount *int `json:"vectorCount,omitempty"`
Stats JSONObject `json:"stats,omitempty"`
}
VectorstoreStatus is a vectorstore's state, checked now.
type VectorstoresService ¶
type VectorstoresService struct {
*KindService[Vectorstore]
}
VectorstoresService holds the operations of Vectorstores: /api/v1/vectorstores/, and the manifest api's Vectorstore kind. The platform serves these endpoints only when SMARTER_ENABLE_VECTORSTORE is true.
func (*VectorstoresService) AddFiles ¶
func (s *VectorstoresService) AddFiles(ctx context.Context, id ID, paths []string) (*VectorstoreDocumentsAdded, error)
AddFiles uploads files, by their paths, as documents, e.g. PDF, Word, HTML or text files. The platform extracts their text.
func (*VectorstoresService) AddText ¶
func (s *VectorstoresService) AddText(ctx context.Context, id ID, text string, params *AddTextParams) (*VectorstoreDocumentsAdded, error)
AddText adds a text as a document. It is loaded asynchronously, once the vectorstore is deployed.
func (*VectorstoresService) AddURL ¶
func (s *VectorstoresService) AddURL(ctx context.Context, id ID, url string, params *AddURLParams) (*VectorstoreDocumentsAdded, error)
AddURL adds a public web page or file, by its url, as a document. The platform fetches it.
func (*VectorstoresService) CreateSnapshot ¶
func (s *VectorstoresService) CreateSnapshot(ctx context.Context, id ID) (*VectorstoreSnapshot, error)
CreateSnapshot takes a snapshot of a vectorstore's data now.
func (*VectorstoresService) DeleteDocument ¶
func (s *VectorstoresService) DeleteDocument(ctx context.Context, id ID, documentID int) (*VectorstoreDocumentDeleted, error)
DeleteDocument removes a document and its chunks, asynchronously.
func (*VectorstoresService) Deploy ¶
func (s *VectorstoresService) Deploy(ctx context.Context, id ID) (*Vectorstore, error)
Deploy deploys a vectorstore: it creates its database, or connects to the provider's. A self-hosted vectorstore creates real, possibly billable, Kubernetes resources.
func (*VectorstoresService) Documents ¶
func (s *VectorstoresService) Documents(ctx context.Context, id ID) (*VectorstoreDocuments, error)
Documents returns a vectorstore's documents, newest first.
func (*VectorstoresService) Restore ¶
func (s *VectorstoresService) Restore(ctx context.Context, id ID, snapshotID int) (*VectorstoreRestored, error)
Restore replaces a vectorstore's data with one of its snapshots, and returns the restored vector count.
func (*VectorstoresService) Search ¶
func (s *VectorstoresService) Search(ctx context.Context, id ID, text string, params *SearchParams) (*VectorstoreSearchResults, error)
Search searches a vectorstore, and returns the matching chunks, best first.
func (*VectorstoresService) Snapshots ¶
func (s *VectorstoresService) Snapshots(ctx context.Context, id ID) (*VectorstoreSnapshots, error)
Snapshots returns a vectorstore's snapshots.
func (*VectorstoresService) Status ¶
func (s *VectorstoresService) Status(ctx context.Context, id ID) (*VectorstoreStatus, error)
Status returns a vectorstore's state, checked now: its status and vector count.
func (*VectorstoresService) Undeploy ¶
func (s *VectorstoresService) Undeploy(ctx context.Context, id ID) (*Vectorstore, error)
Undeploy stops serving a vectorstore. A self-hosted server's data is kept.
type ViteManifest ¶
type ViteManifest struct {
// Chunks are the manifest's chunks, keyed by source path.
Chunks map[string]ViteManifestChunk
// BuildInfo is the _custom build information, if the package's vite.config.ts adds it.
BuildInfo *ReactAppBuildInfo
}
ViteManifest is a React app's Vite-generated manifest.json: its chunks, keyed by source path, and Smarter's build information. It decodes from and encodes to the file's shape.
func (ViteManifest) CollectAssets ¶
func (m ViteManifest) CollectAssets(key, assetType string) []string
CollectAssets returns the JS ("js") or CSS ("css") files of a chunk and of its static imports, the chunk's own first, then each import's, depth first, in the order they are listed. Each chunk is visited once, so circular imports terminate.
func (ViteManifest) EntryKey ¶
func (m ViteManifest) EntryKey() string
EntryKey returns the key of the manifest's entry point, the first chunk (in key order) with isEntry, or "" if the manifest has none.
func (ViteManifest) MarshalJSON ¶
func (m ViteManifest) MarshalJSON() ([]byte, error)
MarshalJSON encodes the manifest in the shape of manifest.json, with the build information as its _custom entry.
func (*ViteManifest) UnmarshalJSON ¶
func (m *ViteManifest) UnmarshalJSON(data []byte) error
UnmarshalJSON splits the manifest.json's _custom entry from its chunks.
type ViteManifestChunk ¶
type ViteManifestChunk struct {
// File is the output file of this chunk, relative to the app's static directory.
File string `json:"file"`
Name string `json:"name,omitempty"`
Names []string `json:"names,omitempty"`
Src string `json:"src,omitempty"`
IsEntry bool `json:"isEntry,omitempty"`
IsDynamicEntry bool `json:"isDynamicEntry,omitempty"`
// Imports are the manifest keys of statically imported chunks.
Imports []string `json:"imports,omitempty"`
// DynamicImports are the manifest keys of dynamically imported chunks.
DynamicImports []string `json:"dynamicImports,omitempty"`
// CSS are the CSS files that this chunk loads.
CSS []string `json:"css,omitempty"`
// Assets are the other static files that this chunk references.
Assets []string `json:"assets,omitempty"`
}
ViteManifestChunk is one entry of a Vite-generated manifest.json: a chunk, or a static asset. See https://vite.dev/guide/backend-integration.
type WhoAmI ¶
type WhoAmI struct {
User User `json:"user"`
Account Account `json:"account"`
// Environment is the platform's environment, e.g. local or prod.
Environment string `json:"environment,omitempty"`
}
WhoAmI is the owner of the api key: the user, their account, and the platform's environment.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
cmd/samgen
command
Command samgen generates the SDK's sam package from the Smarter platform's committed JSON Schemas.
|
Command samgen generates the SDK's sam package from the Smarter platform's committed JSON Schemas. |
|
Package sam holds a Go struct of every SAM (Smarter Application Manifest) kind, generated from the Smarter platform's JSON Schemas.
|
Package sam holds a Go struct of every SAM (Smarter Application Manifest) kind, generated from the Smarter platform's JSON Schemas. |