Documentation
¶
Index ¶
- Constants
- type APIKey
- type APIKeyListResponse
- type APIKeyScope
- type APIResponse
- type BatchFileResult
- type BatchUploadResponse
- type Client
- func (c *Client) Delete(ctx context.Context, path string) error
- func (c *Client) Get(ctx context.Context, path string, result interface{}) error
- func (c *Client) GetBaseURL() string
- func (c *Client) GetUserAgent() string
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) Patch(ctx context.Context, path string, body interface{}, result interface{}) error
- func (c *Client) Post(ctx context.Context, path string, body interface{}, result interface{}) error
- func (c *Client) Put(ctx context.Context, path string, body interface{}, result interface{}) error
- func (c *Client) SetTimeout(timeout time.Duration)
- func (c *Client) ValidateAPIKey(ctx context.Context) error
- func (c *Client) WithContext(ctx context.Context) context.Context
- type ClientOption
- type ErrorResponse
- type FileUpload
- type GenerateClient
- type GenerateTextRequest
- type GenerateTextResponse
- type ListOptions
- type PaginatedResponse
- type Persona
- type PersonaListResponse
- type PersonasClient
- func (p *PersonasClient) AssociateFiles(ctx context.Context, personaID string, fileIDs []string) error
- func (p *PersonasClient) Create(ctx context.Context, persona *Persona) (*Persona, error)
- func (p *PersonasClient) Delete(ctx context.Context, personaID string) error
- func (p *PersonasClient) DisassociateFiles(ctx context.Context, personaID string, fileIDs []string) error
- func (p *PersonasClient) Get(ctx context.Context, personaID string) (*Persona, error)
- func (p *PersonasClient) List(ctx context.Context) ([]Persona, error)
- func (p *PersonasClient) ListFiles(ctx context.Context, personaID string) ([]TrainingFile, error)
- func (p *PersonasClient) Update(ctx context.Context, personaID string, persona *Persona) (*Persona, error)
- type Profile
- type ProfileListResponse
- type ProfilesClient
- func (p *ProfilesClient) AssociateWithPersona(ctx context.Context, profileID, personaID string) error
- func (p *ProfilesClient) Create(ctx context.Context, profile *Profile) (*Profile, error)
- func (p *ProfilesClient) Delete(ctx context.Context, profileID string) error
- func (p *ProfilesClient) DisassociateFromPersona(ctx context.Context, profileID, personaID string) error
- func (p *ProfilesClient) Get(ctx context.Context, profileID string) (*Profile, error)
- func (p *ProfilesClient) GetPersonaProfiles(ctx context.Context, personaID string) ([]Profile, error)
- func (p *ProfilesClient) List(ctx context.Context) ([]Profile, error)
- func (p *ProfilesClient) Update(ctx context.Context, profileID string, profile *Profile) (*Profile, error)
- type RateLimitError
- type ToneCloneClient
- type TrainingClient
- func (t *TrainingClient) CreateJob(ctx context.Context, personaID string, fileIDs []string) (*TrainingJob, error)
- func (t *TrainingClient) CreatePersonaTrainingJob(ctx context.Context, personaID string) (*TrainingJob, error)
- func (t *TrainingClient) DeleteFile(ctx context.Context, fileID string) error
- func (t *TrainingClient) GetFile(ctx context.Context, fileID string) (*TrainingFile, error)
- func (t *TrainingClient) GetJob(ctx context.Context, jobID string) (*TrainingJob, error)
- func (t *TrainingClient) ListFiles(ctx context.Context) ([]TrainingFile, error)
- func (t *TrainingClient) ListJobs(ctx context.Context) ([]TrainingJob, error)
- func (t *TrainingClient) UploadFile(ctx context.Context, file io.Reader, filename string) (*TrainingFile, error)
- func (t *TrainingClient) UploadFileBatch(ctx context.Context, files []FileUpload, personaID, source string) (*BatchUploadResponse, error)
- func (t *TrainingClient) UploadText(ctx context.Context, request *UploadTextRequest) (*TrainingFile, error)
- type TrainingFile
- type TrainingFileListResponse
- type TrainingJob
- type UploadTextRequest
- type User
- type WritingSession
- type WritingSessionListResponse
Constants ¶
const ( APIVersion = "v1" DefaultBaseURL = "https://api.toneclone.ai" DefaultTimeout = 30 * time.Second )
Constants for the API client
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKey ¶
type APIKey struct {
KeyID string `json:"keyId"`
Name string `json:"name"`
Prefix string `json:"prefix"`
Scopes []APIKeyScope `json:"scopes"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
LastUsedAt *time.Time `json:"lastUsedAt,omitempty"`
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
UsageCount int64 `json:"usageCount"`
}
APIKey represents an API key (for management)
type APIKeyListResponse ¶
type APIKeyListResponse struct {
Keys []APIKey `json:"keys"`
}
APIKeyListResponse represents the response from listing API keys
type APIKeyScope ¶
type APIKeyScope string
API Key Scope types
const ( // Read permissions ScopePersonasRead APIKeyScope = "personas:read" ScopeProfilesRead APIKeyScope = "profiles:read" ScopeTrainingRead APIKeyScope = "training:read" ScopeFilesRead APIKeyScope = "files:read" ScopeWritingRead APIKeyScope = "writing:read" ScopeUserRead APIKeyScope = "user:read" // Write permissions ScopePersonasWrite APIKeyScope = "personas:write" ScopeProfilesWrite APIKeyScope = "profiles:write" ScopeTrainingWrite APIKeyScope = "training:write" ScopeFilesWrite APIKeyScope = "files:write" ScopeWritingWrite APIKeyScope = "writing:write" ScopeUserWrite APIKeyScope = "user:write" // Text generation ScopeTextGenerate APIKeyScope = "text:generate" // Admin permissions ScopeAdmin APIKeyScope = "admin:all" // Wildcard permission ScopeAll APIKeyScope = "*" )
type APIResponse ¶
type APIResponse[T any] struct { Data T `json:"data,omitempty"` Error string `json:"error,omitempty"` Status int `json:"status,omitempty"` }
APIResponse represents a generic API response
type BatchFileResult ¶
type BatchFileResult struct {
FileID string `json:"file_id,omitempty"`
Filename string `json:"filename"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
Size int64 `json:"size,omitempty"`
Associated bool `json:"associated"`
}
BatchFileResult represents the result of uploading a single file in a batch
type BatchUploadResponse ¶
type BatchUploadResponse struct {
Files []BatchFileResult `json:"files"`
PersonaID string `json:"persona_id,omitempty"`
Summary struct {
Total int `json:"total"`
Uploaded int `json:"uploaded"`
Associated int `json:"associated"`
Failed int `json:"failed"`
} `json:"summary"`
}
BatchUploadResponse represents the response from batch file upload
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the ToneClone API client
func NewClient ¶
func NewClient(apiKey string, options ...ClientOption) *Client
NewClient creates a new ToneClone API client
func (*Client) GetBaseURL ¶
GetBaseURL returns the configured base URL
func (*Client) GetUserAgent ¶
GetUserAgent returns the configured user agent
func (*Client) Patch ¶
func (c *Client) Patch(ctx context.Context, path string, body interface{}, result interface{}) error
Patch performs a PATCH request
func (*Client) SetTimeout ¶
SetTimeout updates the client timeout
func (*Client) ValidateAPIKey ¶
ValidateAPIKey validates that the API key is working
type ClientOption ¶
type ClientOption func(*Client)
ClientOption represents a configuration option for the client
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient sets a custom HTTP client
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout sets a custom timeout
func WithUserAgent ¶
func WithUserAgent(userAgent string) ClientOption
WithUserAgent sets a custom user agent
type ErrorResponse ¶
type ErrorResponse struct {
ErrorMsg string `json:"error"`
Message string `json:"message,omitempty"`
Code string `json:"code,omitempty"`
}
ErrorResponse represents an API error response
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
type FileUpload ¶
FileUpload represents a file to be uploaded
type GenerateClient ¶
type GenerateClient struct {
// contains filtered or unexported fields
}
GenerateClient handles text generation API operations
func NewGenerateClient ¶
func NewGenerateClient(client *Client) *GenerateClient
NewGenerateClient creates a new generate client
func (*GenerateClient) SimpleText ¶
func (g *GenerateClient) SimpleText(ctx context.Context, prompt string, personaID ...string) (string, error)
SimpleText generates text with just a prompt and optional persona
func (*GenerateClient) Text ¶
func (g *GenerateClient) Text(ctx context.Context, request *GenerateTextRequest) (*GenerateTextResponse, error)
Text generates text using the specified parameters
type GenerateTextRequest ¶
type GenerateTextRequest struct {
Prompt string `json:"prompt"`
PersonaID string `json:"personaId"`
ProfileID string `json:"profileId,omitempty"`
ProfileIDs []string `json:"profileIds,omitempty"`
Context string `json:"context,omitempty"`
SessionID string `json:"sessionId,omitempty"`
Document string `json:"document,omitempty"`
Selection string `json:"selection,omitempty"`
Formality int `json:"formality,omitempty"`
ReadingLevel int `json:"readingLevel,omitempty"`
Length int `json:"length,omitempty"`
Model string `json:"model,omitempty"`
Streaming *bool `json:"streaming,omitempty"`
}
GenerateTextRequest represents a text generation request
type GenerateTextResponse ¶
type GenerateTextResponse struct {
Text string `json:"text"`
PersonaID string `json:"personaId,omitempty"`
ProfileID string `json:"profileId,omitempty"`
Model string `json:"model,omitempty"`
Tokens int `json:"tokens,omitempty"`
}
GenerateTextResponse represents a text generation response
type ListOptions ¶
type ListOptions struct {
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
Sort string `json:"sort,omitempty"`
Filter string `json:"filter,omitempty"`
}
ListOptions represents common listing options
type PaginatedResponse ¶
type PaginatedResponse[T any] struct { Items []T `json:"items"` Total int `json:"total"` Limit int `json:"limit"` Offset int `json:"offset"` HasMore bool `json:"hasMore"` NextOffset int `json:"nextOffset,omitempty"` }
PaginatedResponse represents a paginated response
type Persona ¶
type Persona struct {
PersonaID string `json:"personaId"`
Name string `json:"name"`
LastUsedAt time.Time `json:"lastUsedAt"`
LastModifiedAt time.Time `json:"lastModifiedAt"`
Status string `json:"status"`
TrainingStatus string `json:"trainingStatus"`
PersonaType string `json:"personaType"`
VoiceEvolution bool `json:"voiceEvolution"`
PromptDescription string `json:"personaPromptDescription,omitempty"`
}
Persona represents a writing persona
type PersonaListResponse ¶
type PersonaListResponse struct {
Personas []Persona `json:"personas"`
}
PersonaListResponse represents the response from listing personas
type PersonasClient ¶
type PersonasClient struct {
// contains filtered or unexported fields
}
PersonasClient handles persona-related API operations
func NewPersonasClient ¶
func NewPersonasClient(client *Client) *PersonasClient
NewPersonasClient creates a new personas client
func (*PersonasClient) AssociateFiles ¶
func (p *PersonasClient) AssociateFiles(ctx context.Context, personaID string, fileIDs []string) error
AssociateFiles associates files with a persona
func (*PersonasClient) Delete ¶
func (p *PersonasClient) Delete(ctx context.Context, personaID string) error
Delete deletes a persona
func (*PersonasClient) DisassociateFiles ¶
func (p *PersonasClient) DisassociateFiles(ctx context.Context, personaID string, fileIDs []string) error
DisassociateFiles removes file associations from a persona
func (*PersonasClient) List ¶
func (p *PersonasClient) List(ctx context.Context) ([]Persona, error)
List retrieves all personas
func (*PersonasClient) ListFiles ¶
func (p *PersonasClient) ListFiles(ctx context.Context, personaID string) ([]TrainingFile, error)
ListFiles retrieves files associated with a persona
type Profile ¶
type Profile struct {
PK string `json:"PK"`
SK string `json:"SK"`
ProfileID string `json:"profileId"`
UserID string `json:"userId"`
Name string `json:"name"`
Instructions string `json:"instructions"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
Profile represents a writing profile
type ProfileListResponse ¶
type ProfileListResponse struct {
Profiles []Profile `json:"profiles"`
}
ProfileListResponse represents the response from listing profiles
type ProfilesClient ¶
type ProfilesClient struct {
// contains filtered or unexported fields
}
ProfilesClient handles profile-related API operations
func NewProfilesClient ¶
func NewProfilesClient(client *Client) *ProfilesClient
NewProfilesClient creates a new profiles client
func (*ProfilesClient) AssociateWithPersona ¶
func (p *ProfilesClient) AssociateWithPersona(ctx context.Context, profileID, personaID string) error
AssociateWithPersona associates a profile with a persona
func (*ProfilesClient) Delete ¶
func (p *ProfilesClient) Delete(ctx context.Context, profileID string) error
Delete deletes a profile
func (*ProfilesClient) DisassociateFromPersona ¶
func (p *ProfilesClient) DisassociateFromPersona(ctx context.Context, profileID, personaID string) error
DisassociateFromPersona disassociates a profile from a persona
func (*ProfilesClient) GetPersonaProfiles ¶
func (p *ProfilesClient) GetPersonaProfiles(ctx context.Context, personaID string) ([]Profile, error)
GetPersonaProfiles retrieves all profiles associated with a persona
type RateLimitError ¶
type RateLimitError struct {
ErrorResponse
RemainingRequests int
ResetTime time.Time
RetryAfterSeconds int
}
RateLimitError represents a rate limiting error with retry information
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type ToneCloneClient ¶
type ToneCloneClient struct {
*Client
// Resource clients
Personas *PersonasClient
Generate *GenerateClient
Training *TrainingClient
Profiles *ProfilesClient
}
ToneCloneClient provides access to all ToneClone API resources
func NewToneCloneClient ¶
func NewToneCloneClient(apiKey string, options ...ClientOption) *ToneCloneClient
NewToneCloneClient creates a new ToneClone API client with all resource clients
func NewToneCloneClientFromConfig ¶
func NewToneCloneClientFromConfig(baseURL, apiKey string, timeout time.Duration) *ToneCloneClient
NewToneCloneClientFromConfig creates a client from configuration
func (*ToneCloneClient) Ping ¶
func (tc *ToneCloneClient) Ping(ctx context.Context) error
Ping tests the connection to the API
func (*ToneCloneClient) ValidateConnection ¶
func (tc *ToneCloneClient) ValidateConnection(ctx context.Context) error
ValidateConnection validates that the client can connect and authenticate
type TrainingClient ¶
type TrainingClient struct {
// contains filtered or unexported fields
}
TrainingClient handles training-related API operations
func NewTrainingClient ¶
func NewTrainingClient(client *Client) *TrainingClient
NewTrainingClient creates a new training client
func (*TrainingClient) CreateJob ¶
func (t *TrainingClient) CreateJob(ctx context.Context, personaID string, fileIDs []string) (*TrainingJob, error)
CreateJob creates a new training job
func (*TrainingClient) CreatePersonaTrainingJob ¶
func (t *TrainingClient) CreatePersonaTrainingJob(ctx context.Context, personaID string) (*TrainingJob, error)
CreatePersonaTrainingJob creates a training job for a persona using all associated files
func (*TrainingClient) DeleteFile ¶
func (t *TrainingClient) DeleteFile(ctx context.Context, fileID string) error
DeleteFile deletes a training file
func (*TrainingClient) GetFile ¶
func (t *TrainingClient) GetFile(ctx context.Context, fileID string) (*TrainingFile, error)
GetFile retrieves a specific training file by ID
func (*TrainingClient) GetJob ¶
func (t *TrainingClient) GetJob(ctx context.Context, jobID string) (*TrainingJob, error)
GetJob retrieves a specific training job by ID
func (*TrainingClient) ListFiles ¶
func (t *TrainingClient) ListFiles(ctx context.Context) ([]TrainingFile, error)
ListFiles retrieves all training files for the user
func (*TrainingClient) ListJobs ¶
func (t *TrainingClient) ListJobs(ctx context.Context) ([]TrainingJob, error)
ListJobs retrieves all training jobs for the user
func (*TrainingClient) UploadFile ¶
func (t *TrainingClient) UploadFile(ctx context.Context, file io.Reader, filename string) (*TrainingFile, error)
UploadFile uploads a binary file
func (*TrainingClient) UploadFileBatch ¶
func (t *TrainingClient) UploadFileBatch(ctx context.Context, files []FileUpload, personaID, source string) (*BatchUploadResponse, error)
UploadFileBatch uploads multiple files in a single request
func (*TrainingClient) UploadText ¶
func (t *TrainingClient) UploadText(ctx context.Context, request *UploadTextRequest) (*TrainingFile, error)
UploadText uploads text content
type TrainingFile ¶
type TrainingFile struct {
PK string `json:"PK"`
SK string `json:"SK"`
UserID string `json:"userId"`
FileID string `json:"fileId"`
FileName string `json:"filename"`
FileType string `json:"fileType"`
FileSize int64 `json:"size"`
CreatedAt time.Time `json:"createdAt"`
ModifiedAt time.Time `json:"modifiedAt"`
S3Key string `json:"s3Key"`
ContentType string `json:"contentType"`
Source string `json:"source"`
UsedForTraining bool `json:"usedForTraining"`
PersonaID string `json:"personaId,omitempty"`
}
TrainingFile represents a training file
type TrainingFileListResponse ¶
type TrainingFileListResponse struct {
Files []TrainingFile `json:"files"`
}
TrainingFileListResponse represents the response from listing training files
type TrainingJob ¶
type TrainingJob struct {
JobID string `json:"jobId"`
PersonaID string `json:"personaId"`
FileIDs []string `json:"fileIds"`
TotalFiles int `json:"totalFiles"`
FilesProcessed int `json:"filesProcessed"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
OpenAIJobID string `json:"openAIJobID,omitempty"`
OpenAIJobStatus string `json:"openAIJobStatus,omitempty"`
BaseModel string `json:"baseModel,omitempty"`
}
TrainingJob represents a training job
type UploadTextRequest ¶
type UploadTextRequest struct {
Content string `json:"content"`
Filename string `json:"filename"`
Source string `json:"source"`
}
UploadTextRequest represents a text upload request
type User ¶
type User struct {
UserID string `json:"userId"`
Email string `json:"email"`
Name string `json:"name,omitempty"`
CreatedAt time.Time `json:"createdAt"`
Plan string `json:"plan,omitempty"`
}
User represents user information
type WritingSession ¶
type WritingSession struct {
SessionID string `json:"sessionId"`
Title string `json:"title,omitempty"`
Content string `json:"content,omitempty"`
PersonaID string `json:"personaId,omitempty"`
ProfileID string `json:"profileId,omitempty"`
CreatedAt time.Time `json:"createdAt"`
LastModifiedAt time.Time `json:"lastModifiedAt"`
Status string `json:"status"`
}
WritingSession represents a writing session
type WritingSessionListResponse ¶
type WritingSessionListResponse struct {
Sessions []WritingSession `json:"sessions"`
}
WritingSessionListResponse represents the response from listing writing sessions