Documentation
¶
Index ¶
- Variables
- type APIError
- type AgentCase
- type AgentResponse
- type AnalyzeImageFromURLRequest
- type AnalyzeImageResponse
- type ApiTokenCreateRequest
- type ApiTokenCreateResponse
- type AuthCase
- type ChatCompletionRequest
- type ChatCompletionResponse
- type ChatRagInfo
- type ChatReference
- type ChatRequest
- type ChatResponse
- type ChatvoltAgentItem
- type ChatvoltAgentQueryRequest
- type ChatvoltAgentQueryResponse
- type ChatvoltAgentVisibility
- type ChatvoltCase
- type ChatvoltContact
- type ChatvoltCredentialsDTO
- type Client
- type CollectionCase
- type CollectionResponse
- type CollectionsResponse
- type ConfigureChatvoltRequest
- type ConfigureGoogleRequest
- type ConfigureOpenAIRequest
- type CreateAgentRequest
- type CreateCollectionRequest
- type CreateTenantRequestDto
- type CreateUserRequestDto
- type DocumentCase
- type DocumentResponse
- type GoogleCase
- type ListAgentsResponse
- type ListApiTokensResponse
- type ListChatvoltAgentsResponse
- type ListDocumentsParams
- type ListDocumentsResponse
- type ListUsersParams
- type LoginRequest
- type LoginResponse
- type OTPRequest
- type OTPResetPasswordRequest
- type OpenAICase
- type OpenAICredentialsDTO
- type OpenAIModel
- type OpenAISettingsDTO
- type OpenRouterCase
- type OpenRouterDesyncResponse
- type OpenRouterEmbeddingModel
- type OpenRouterListEmbeddingModelsResponse
- type OpenRouterListModelsResponse
- type OpenRouterModelInfo
- type OpenRouterModelPricing
- type OpenRouterSyncRequest
- type OpenRouterSyncResponse
- type Options
- type ProviderCase
- type ProviderResponseDto
- type ProvidersResponseDto
- type RestErrCause
- type ServiceCase
- type ServiceResponseDto
- type ServicesResponseDto
- type TenantCase
- type TenantResponseDto
- type TenantsResponseDto
- type TranscribeAudioFromURLRequest
- type TranscribeAudioRequest
- type TranscriptionResponse
- type UpdateAgentRequest
- type UpdateTenantRequestDto
- type UpdateUserRequestDto
- type UploadDocumentRequest
- type UserCase
- type UserResponseDto
- type UserRole
- type VisionAICredentialsDTO
- type VisionOCRFromURLRequest
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidToken = errors.New("synapse: token cannot be empty") ErrForbidden = errors.New("synapse: forbidden — insufficient permissions") ErrNotFound = errors.New("synapse: resource not found") ErrConflict = errors.New("synapse: conflict — resource already exists or duplicate") ErrBadRequest = errors.New("synapse: bad request — invalid parameters") ErrInternalServer = errors.New("synapse: internal server error") ErrBadGateway = errors.New("synapse: bad gateway — upstream provider error") ErrIntegrationNotConfigured = errors.New("synapse: integration not configured for this tenant") )
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
// StatusCode is the HTTP status returned by the API.
StatusCode int `json:"-"`
// Code mirrors the numeric code in the response body.
Code int `json:"code"`
// Err is the short error label from the response body.
Err string `json:"error"`
// Message is the human-readable description from the response body.
Message string `json:"message"`
// TraceID is the trace identifier returned by the API for debugging.
TraceID string `json:"trace_id"`
// Causes holds field-level validation errors when applicable.
Causes []RestErrCause `json:"causes"`
}
APIError represents an error response from the Synapse API. It carries the full response payload and wraps a typed sentinel error so callers can use errors.Is for control flow.
Example:
_, err := client.Auth.Login(ctx, req)
if errors.Is(err, synapse.ErrUnauthorized) { ... }
if apiErr, ok := synapse.AsAPIError(err); ok {
fmt.Println(apiErr.TraceID, apiErr.Causes)
}
func AsAPIError ¶
AsAPIError unwraps err into *APIError and reports whether it succeeded. Use this to inspect the full API error payload (causes, trace_id, etc.).
type AgentCase ¶ added in v0.0.6
type AgentCase interface {
// Create registers a new AI agent for the authenticated tenant.
Create(ctx context.Context, req CreateAgentRequest) (*AgentResponse, error)
// Get returns an agent by its UUID.
Get(ctx context.Context, agentUUID string) (*AgentResponse, error)
// List returns a paginated list of agents for the authenticated tenant.
// Use page=0 and size=0 to rely on server defaults.
List(ctx context.Context, page, size int) (*ListAgentsResponse, error)
// Update replaces all mutable fields of an agent (PUT semantics).
Update(ctx context.Context, agentUUID string, req UpdateAgentRequest) (*AgentResponse, error)
// Patch updates a single field of an agent (PATCH semantics).
// Set exactly one field in req; the server rejects requests with 0 or more than 1 field.
Patch(ctx context.Context, agentUUID string, req UpdateAgentRequest) (*AgentResponse, error)
// Delete permanently removes an agent and all its conversations.
Delete(ctx context.Context, agentUUID string) error
// Chat sends a message to an agent and returns the response.
// Omit req.ConversationUUID to start a new conversation; the returned
// ChatResponse.ConversationUUID can be passed in subsequent calls to maintain context.
Chat(ctx context.Context, req ChatRequest) (*ChatResponse, error)
}
AgentCase provides CRUD and chat operations for AI agents.
type AgentResponse ¶ added in v0.0.6
type AgentResponse struct {
UUID string `json:"uuid"`
TenantUUID string `json:"tenant_uuid"`
Name string `json:"name"`
Description string `json:"description"`
Model string `json:"model"`
Prompt string `json:"prompt"`
CollectionUUID *string `json:"collection_uuid"`
QueryEmbedModel string `json:"query_embed_model,omitempty"`
MaxContext int `json:"max_context"`
Temperature float64 `json:"temperature"`
Active bool `json:"active"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
AgentResponse describes an AI agent.
type AnalyzeImageFromURLRequest ¶ added in v0.0.5
type AnalyzeImageFromURLRequest struct {
FileURL string `json:"file_url"`
Prompt string `json:"prompt"`
}
AnalyzeImageFromURLRequest is the body for analysing an image that the server fetches from a download URL (OpenAI image analysis).
type AnalyzeImageResponse ¶
type AnalyzeImageResponse struct {
Response string `json:"response"`
}
AnalyzeImageResponse is returned by both OpenAI and Google Vision image endpoints.
type ApiTokenCreateRequest ¶
type ApiTokenCreateRequest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
// ExpireAt is optional; if omitted the server sets a default expiry.
ExpireAt string `json:"expire_at,omitempty"`
}
ApiTokenCreateRequest is the body for creating an API token.
type ApiTokenCreateResponse ¶
type ApiTokenCreateResponse struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Description string `json:"description"`
Token string `json:"token"`
TenantUUID string `json:"tenant_uuid"`
UserUUID string `json:"user_uuid"`
ExpireAt string `json:"expire_at"`
CreatedAt string `json:"create_at"`
}
ApiTokenCreateResponse describes a created or listed API token.
type AuthCase ¶
type AuthCase interface {
// Login authenticates a user with email and password and returns an access token.
Login(ctx context.Context, req LoginRequest) (*LoginResponse, error)
// Logout revokes the given access token.
Logout(ctx context.Context, token string) error
// Healthcheck validates the current token and returns the logged-in user's data.
Healthcheck(ctx context.Context) (*LoginResponse, error)
// RequestOTP sends a one-time password to the given email address.
RequestOTP(ctx context.Context, req OTPRequest) error
// ResetPassword validates the OTP and replaces the user's password.
ResetPassword(ctx context.Context, req OTPResetPasswordRequest) error
// ListAPITokens returns all API tokens linked to the authenticated user.
// Use page=0 and pageSize=0 to rely on server defaults.
ListAPITokens(ctx context.Context, page, pageSize int) (*ListApiTokensResponse, error)
// CreateAPIToken creates a new API token for the authenticated user.
CreateAPIToken(ctx context.Context, req ApiTokenCreateRequest) (*ApiTokenCreateResponse, error)
}
AuthCase provides all authentication-related operations against the Synapse API.
type ChatCompletionRequest ¶
type ChatCompletionRequest struct {
Prompt string `json:"prompt"`
}
ChatCompletionRequest is the body for a chat completion call.
type ChatCompletionResponse ¶
type ChatCompletionResponse struct {
Response string `json:"response"`
}
ChatCompletionResponse is the response from a chat completion call.
type ChatRagInfo ¶ added in v0.0.6
type ChatRagInfo struct {
Enabled bool `json:"enabled"`
ChunksFound int `json:"chunks_found"`
Error string `json:"error,omitempty"`
}
ChatRagInfo reports what happened during the semantic search step.
type ChatReference ¶ added in v0.0.6
type ChatReference struct {
Filename string `json:"filename"`
ChunkIndex int `json:"chunk_index"`
Score float32 `json:"score"`
ScorePct float32 `json:"score_pct"`
Text string `json:"text"`
}
ChatReference is a document chunk retrieved from Qdrant and used in the RAG context.
type ChatRequest ¶ added in v0.0.6
type ChatRequest struct {
AgentUUID string `json:"agent_uuid"`
Message string `json:"message"`
// ConversationUUID continues an existing conversation; omit to start a new one.
ConversationUUID *string `json:"conversation_uuid,omitempty"`
}
ChatRequest is the body for sending a message to an AI agent.
type ChatResponse ¶ added in v0.0.6
type ChatResponse struct {
ConversationUUID string `json:"conversation_uuid"`
Message string `json:"message"`
References []ChatReference `json:"references"`
Rag ChatRagInfo `json:"rag"`
}
ChatResponse is the reply from the AI agent.
type ChatvoltAgentItem ¶ added in v0.0.4
type ChatvoltAgentItem struct {
ID string `json:"id"`
Name string `json:"name"`
IconUrl *string `json:"iconUrl,omitempty"`
Description string `json:"description"`
ModelName string `json:"modelName"`
Visibility ChatvoltAgentVisibility `json:"visibility"`
}
ChatvoltAgentItem describes a single Chatvolt agent returned by the catalog.
type ChatvoltAgentQueryRequest ¶
type ChatvoltAgentQueryRequest struct {
AgentID string `json:"agentId"`
Query string `json:"query"`
// ConversationID keeps context across turns; omit to start a new conversation.
ConversationID string `json:"conversationId,omitempty"`
// Streaming should generally be false for synchronous responses.
Streaming bool `json:"streaming"`
Contact *ChatvoltContact `json:"contact,omitempty"`
}
ChatvoltAgentQueryRequest is the body for querying a Chatvolt agent.
type ChatvoltAgentQueryResponse ¶
type ChatvoltAgentQueryResponse struct {
Answer string `json:"answer"`
ConversationID string `json:"conversationId"`
MessageID string `json:"messageId"`
VisitorID string `json:"visitorId"`
Sources interface{} `json:"sources"`
Metadata interface{} `json:"metadata"`
}
ChatvoltAgentQueryResponse is the response from a Chatvolt agent query.
type ChatvoltAgentVisibility ¶ added in v0.0.4
type ChatvoltAgentVisibility string
ChatvoltAgentVisibility indicates whether a Chatvolt agent is publicly accessible.
const ( ChatvoltAgentVisibilityPublic ChatvoltAgentVisibility = "public" ChatvoltAgentVisibilityPrivate ChatvoltAgentVisibility = "private" )
type ChatvoltCase ¶
type ChatvoltCase interface {
// Configure creates or updates the Chatvolt integration credentials
// for the authenticated tenant.
Configure(ctx context.Context, req ConfigureChatvoltRequest) error
// Query sends a message to a Chatvolt agent and returns its response.
// Set req.ConversationID to continue an existing conversation thread.
Query(ctx context.Context, req ChatvoltAgentQueryRequest) (*ChatvoltAgentQueryResponse, error)
// ListAgents returns all Chatvolt agents available for the authenticated tenant.
ListAgents(ctx context.Context) (*ListChatvoltAgentsResponse, error)
}
ChatvoltCase provides operations for the Chatvolt agent integration.
type ChatvoltContact ¶
type ChatvoltContact struct {
UserID string `json:"userId,omitempty"`
Email string `json:"email,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
PhoneNumber string `json:"phoneNumber,omitempty"`
}
ChatvoltContact carries optional contact metadata attached to a Chatvolt query.
type ChatvoltCredentialsDTO ¶
type ChatvoltCredentialsDTO struct {
Token string `json:"token"`
}
ChatvoltCredentialsDTO holds the API key for the Chatvolt integration.
type Client ¶
type Client struct {
// Auth covers login, logout, OTP, password reset, and API token management.
Auth AuthCase
// User covers user CRUD operations.
User UserCase
// Tenant covers tenant CRUD operations.
Tenant TenantCase
// Provider covers read operations for catalog integration providers.
Provider ProviderCase
// Service covers read operations for catalog integration services.
Service ServiceCase
// Google covers the Google Vision AI integration (configure + OCR).
Google GoogleCase
// OpenAI covers the OpenAI integration (configure, chat, image analysis, transcription).
OpenAI OpenAICase
// Chatvolt covers the Chatvolt agent integration (configure, query, list agents).
Chatvolt ChatvoltCase
// OpenRouter covers the OpenRouter integration (workspace sync/desync, model listing).
OpenRouter OpenRouterCase
// Collection covers Qdrant vector collection CRUD for the knowledge base.
Collection CollectionCase
// Document covers document upload and vectorization for the knowledge base.
Document DocumentCase
// Agent covers AI agent CRUD operations and chat (including RAG).
Agent AgentCase
}
Client is the top-level Synapse SDK entry point. Each field exposes a domain-specific interface covering a group of API endpoints.
Usage:
client, err := synapse.NewClient("your-token", nil)
// Auth
resp, err := client.Auth.Login(ctx, synapse.LoginRequest{...})
// Tenant
tenant, err := client.Tenant.Get(ctx, "uuid", "")
// Google Vision
err = client.Google.Configure(ctx, synapse.ConfigureGoogleRequest{...})
ocr, err := client.Google.VisionOCR(ctx, "photo.jpg", imageBytes)
// OpenAI
reply, err := client.OpenAI.Chat(ctx, synapse.ChatCompletionRequest{Prompt: "Hello!"})
// Chatvolt
answer, err := client.Chatvolt.Query(ctx, synapse.ChatvoltAgentQueryRequest{...})
// OpenRouter
sync, err := client.OpenRouter.Sync(ctx, synapse.OpenRouterSyncRequest{})
models, err := client.OpenRouter.ListModels(ctx, false)
// Knowledge
col, err := client.Collection.Create(ctx, synapse.CreateCollectionRequest{Name: "docs", VectorSize: 1536})
doc, err := client.Document.Upload(ctx, synapse.UploadDocumentRequest{...})
// Agent
agent, err := client.Agent.Create(ctx, synapse.CreateAgentRequest{...})
resp, err := client.Agent.Chat(ctx, synapse.ChatRequest{AgentUUID: "...", Message: "Olá!"})
func NewClient ¶
NewClient creates and returns a fully initialised Synapse Client.
token is required and is sent as a Bearer token on every request. Pass an *Options to override the base URL or request timeout; pass nil for defaults.
client, err := synapse.NewClient("sk-...", &synapse.Options{
BaseURL: "https://staging.synapse.example.com",
Timeout: 15 * time.Second,
})
type CollectionCase ¶ added in v0.0.6
type CollectionCase interface {
// Create registers a new vector collection for the authenticated tenant.
Create(ctx context.Context, req CreateCollectionRequest) (*CollectionResponse, error)
// Get returns a collection by its UUID.
Get(ctx context.Context, collectionUUID string) (*CollectionResponse, error)
// List returns a paginated list of collections for the authenticated tenant.
// Use page=0 and size=0 to rely on server defaults.
List(ctx context.Context, page, size int) (*CollectionsResponse, error)
// Delete permanently removes a collection and its Qdrant data by UUID.
Delete(ctx context.Context, collectionUUID string) error
}
CollectionCase provides CRUD operations for Qdrant vector collections.
type CollectionResponse ¶ added in v0.0.6
type CollectionResponse struct {
UUID string `json:"uuid"`
TenantUUID string `json:"tenant_uuid"`
Name string `json:"name"`
QdrantCollectionName string `json:"qdrant_collection_name"`
VectorSize uint64 `json:"vector_size"`
Distance string `json:"distance"`
CreatedAt string `json:"createAt"`
UpdatedAt string `json:"updateAt"`
}
CollectionResponse describes a single Qdrant collection registered for a tenant.
type CollectionsResponse ¶ added in v0.0.6
type CollectionsResponse struct {
Collections []CollectionResponse `json:"collections"`
Page int `json:"page"`
Size int `json:"size"`
}
CollectionsResponse is the paginated list of collections for a tenant.
type ConfigureChatvoltRequest ¶
type ConfigureChatvoltRequest struct {
Credentials ChatvoltCredentialsDTO `json:"credentials"`
IsActive bool `json:"is_active,omitempty"`
}
ConfigureChatvoltRequest is the body for creating/updating the Chatvolt integration.
type ConfigureGoogleRequest ¶
type ConfigureGoogleRequest struct {
Credentials VisionAICredentialsDTO `json:"credentials"`
IsActive bool `json:"is_active,omitempty"`
}
ConfigureGoogleRequest is the body for creating/updating the Google Vision integration.
type ConfigureOpenAIRequest ¶
type ConfigureOpenAIRequest struct {
Credentials OpenAICredentialsDTO `json:"credentials"`
Settings OpenAISettingsDTO `json:"settings"`
IsActive bool `json:"is_active,omitempty"`
}
ConfigureOpenAIRequest is the body for creating/updating the OpenAI integration.
type CreateAgentRequest ¶ added in v0.0.6
type CreateAgentRequest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Model string `json:"model"`
Prompt string `json:"prompt"`
// CollectionUUID enables RAG — set to the UUID of an indexed collection.
// The embedding model is resolved automatically from the collection documents.
CollectionUUID *string `json:"collection_uuid,omitempty"`
// MaxContext is the number of conversation turns kept in memory (default: server value).
MaxContext int `json:"max_context,omitempty"`
// Temperature controls randomness: 0.0 (deterministic) – 0.7 (max without hallucination).
Temperature *float64 `json:"temperature,omitempty"`
}
CreateAgentRequest is the body for creating an AI agent.
type CreateCollectionRequest ¶ added in v0.0.6
type CreateCollectionRequest struct {
Name string `json:"name"`
// VectorSize is the dimension of the embedding vectors (e.g. 1536 for text-embedding-ada-002).
// When zero the server uses its default (1536).
VectorSize uint64 `json:"vector_size,omitempty"`
// Distance is the similarity metric: "Cosine" (default), "Euclid", or "Dot".
Distance string `json:"distance,omitempty"`
}
CreateCollectionRequest is the body for creating a Qdrant vector collection.
type CreateTenantRequestDto ¶
type CreateTenantRequestDto struct {
ID string `json:"uuid"`
Name string `json:"name"`
Document string `json:"document"`
}
CreateTenantRequestDto is the body for creating a tenant.
type CreateUserRequestDto ¶
type CreateUserRequestDto struct {
Name string `json:"name"`
Email string `json:"email"`
Password string `json:"password"`
Role UserRole `json:"role"`
}
CreateUserRequestDto is the body for creating a user.
type DocumentCase ¶ added in v0.0.6
type DocumentCase interface {
// Upload sends a document file to the server, which parses it, generates embeddings
// via OpenRouter, and stores the vectors in Qdrant. Processing happens in the background;
// the returned DocumentResponse will have Status="processing" immediately.
Upload(ctx context.Context, req UploadDocumentRequest) (*DocumentResponse, error)
// Get returns the metadata of a document by its UUID.
Get(ctx context.Context, documentUUID string) (*DocumentResponse, error)
// List returns a paginated list of documents belonging to the given collection.
List(ctx context.Context, params ListDocumentsParams) (*ListDocumentsResponse, error)
// Delete removes a document and all its associated Qdrant vectors.
Delete(ctx context.Context, documentUUID string) error
}
DocumentCase provides operations for uploading and managing vectorized documents.
type DocumentResponse ¶ added in v0.0.6
type DocumentResponse struct {
UUID string `json:"uuid"`
TenantUUID string `json:"tenant_uuid"`
CollectionUUID string `json:"collection_uuid"`
Filename string `json:"filename"`
FileType string `json:"file_type"`
EmbedModel string `json:"embed_model"`
ChunkCount int `json:"chunk_count"`
VectorSize int `json:"vector_size"`
TokensUsed int64 `json:"tokens_used"`
// Status is "processing", "ready", or "error".
Status string `json:"status"`
ErrorMessage string `json:"error_message,omitempty"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
DocumentResponse describes a document that has been uploaded and vectorized.
type GoogleCase ¶
type GoogleCase interface {
// Configure creates or updates the Google Vision AI integration credentials
// for the authenticated tenant.
Configure(ctx context.Context, req ConfigureGoogleRequest) error
// VisionOCR extracts text from an image using Google Vision TEXT_DETECTION.
// fileName is used as the multipart filename (e.g. "photo.jpg").
// fileContent is the raw image bytes (png, jpg, jpeg, webp).
VisionOCR(ctx context.Context, fileName string, fileContent []byte) (*AnalyzeImageResponse, error)
// VisionOCRFromURL extracts text from an image that the Synapse server
// downloads from the URL in req.FileURL.
VisionOCRFromURL(ctx context.Context, req VisionOCRFromURLRequest) (*AnalyzeImageResponse, error)
}
GoogleCase provides operations for the Google Vision AI integration.
type ListAgentsResponse ¶ added in v0.0.6
type ListAgentsResponse struct {
Agents []AgentResponse `json:"agents"`
Page int `json:"page"`
Size int `json:"size"`
}
ListAgentsResponse is the paginated list of agents for a tenant.
type ListApiTokensResponse ¶
type ListApiTokensResponse struct {
UserUUID string `json:"user_uuid"`
Page int `json:"page"`
Size int `json:"size"`
APITokens []ApiTokenCreateResponse `json:"api_tokens"`
}
ListApiTokensResponse is the paginated response for the API token list.
type ListChatvoltAgentsResponse ¶ added in v0.0.4
type ListChatvoltAgentsResponse struct {
Agents []ChatvoltAgentItem `json:"agents"`
}
ListChatvoltAgentsResponse is the response for the Chatvolt agents list endpoint.
type ListDocumentsParams ¶ added in v0.0.6
ListDocumentsParams holds query parameters for the document list endpoint.
type ListDocumentsResponse ¶ added in v0.0.6
type ListDocumentsResponse struct {
Documents []DocumentResponse `json:"documents"`
Page int `json:"page"`
Size int `json:"size"`
}
ListDocumentsResponse is the paginated list of documents in a collection.
type ListUsersParams ¶
type ListUsersParams struct {
Page int
Size int
// TenantIdentifier filters by tenant UUID or document (SystemAdmin only).
TenantIdentifier string
}
ListUsersParams holds query parameters for the user list endpoint.
type LoginRequest ¶
LoginRequest holds the credentials for the login endpoint.
type LoginResponse ¶
type LoginResponse struct {
Token string `json:"token"`
Expire string `json:"expire"`
SystemTimeUTC string `json:"system_time_utc"`
User UserResponseDto `json:"user"`
}
LoginResponse is returned on successful login or healthcheck.
type OTPRequest ¶
type OTPRequest struct {
Email string `json:"email"`
}
OTPRequest requests a one-time password to be sent to the given email.
type OTPResetPasswordRequest ¶
type OTPResetPasswordRequest struct {
Email string `json:"email"`
OTP string `json:"otp"`
Password string `json:"password"`
}
OTPResetPasswordRequest resets a user password using an OTP code.
type OpenAICase ¶
type OpenAICase interface {
// Configure creates or updates the OpenAI integration credentials and settings
// for the authenticated tenant.
Configure(ctx context.Context, req ConfigureOpenAIRequest) error
// Chat executes a Chat Completion call using the tenant's configured OpenAI account.
Chat(ctx context.Context, req ChatCompletionRequest) (*ChatCompletionResponse, error)
// AnalyzeImage analyses an image using OpenAI vision.
// fileName is the multipart filename (e.g. "image.png").
// fileContent is the raw image bytes (png, jpg, jpeg, webp).
// prompt describes what analysis to perform.
AnalyzeImage(ctx context.Context, fileName string, fileContent []byte, prompt string) (*AnalyzeImageResponse, error)
// AnalyzeImageFromURL analyses an image that the Synapse server downloads from
// the provided URL (no local upload required).
AnalyzeImageFromURL(ctx context.Context, req AnalyzeImageFromURLRequest) (*AnalyzeImageResponse, error)
// TranscribeAudio converts an audio file to text using OpenAI Whisper or GPT-4o.
// See TranscribeAudioRequest for the full set of options.
TranscribeAudio(ctx context.Context, req TranscribeAudioRequest) (*TranscriptionResponse, error)
// TranscribeAudioFromURL converts an audio file to text; the Synapse server
// downloads the file from the URL in req.FileURL.
TranscribeAudioFromURL(ctx context.Context, req TranscribeAudioFromURLRequest) (*TranscriptionResponse, error)
}
OpenAICase provides operations for the OpenAI integration.
type OpenAICredentialsDTO ¶
type OpenAICredentialsDTO struct {
Token string `json:"token"`
}
OpenAICredentialsDTO holds the API key for the OpenAI integration.
type OpenAIModel ¶
type OpenAIModel string
OpenAIModel is the model identifier accepted by the OpenAI integration.
const ( OpenAIModelGPT4oMini OpenAIModel = "gpt-4o-mini" OpenAIModelGPT4o OpenAIModel = "gpt-4o" OpenAIModelGPT4_1 OpenAIModel = "gpt-4.1" OpenAIModelGPT4_1Mini OpenAIModel = "gpt-4.1-mini" OpenAIModelO4Mini OpenAIModel = "o4-mini" )
type OpenAISettingsDTO ¶
type OpenAISettingsDTO struct {
Model OpenAIModel `json:"model"`
// Temperature ranges 0–2; omitted when zero.
Temperature float64 `json:"temperature,omitempty"`
}
OpenAISettingsDTO configures model and sampling behaviour.
type OpenRouterCase ¶ added in v0.0.6
type OpenRouterCase interface {
// Sync creates or returns an existing OpenRouter workspace for the authenticated tenant.
// SystemAdmin callers may target a specific tenant by setting req.TenantUUID.
Sync(ctx context.Context, req OpenRouterSyncRequest) (*OpenRouterSyncResponse, error)
// Desync removes the OpenRouter workspace for the authenticated tenant.
// SystemAdmin callers may target a specific tenant by setting req.TenantUUID.
Desync(ctx context.Context, req OpenRouterSyncRequest) (*OpenRouterDesyncResponse, error)
// ListModels returns all models available on OpenRouter.
// Set freeOnly=true to filter for free-tier models only.
ListModels(ctx context.Context, freeOnly bool) (*OpenRouterListModelsResponse, error)
// ListEmbeddingModels returns the catalogue of embedding models available on OpenRouter,
// including the vector_size required to configure a collection before indexing documents.
// Set freeOnly=true to filter for free-tier models only.
ListEmbeddingModels(ctx context.Context, freeOnly bool) (*OpenRouterListEmbeddingModelsResponse, error)
}
OpenRouterCase provides operations for the OpenRouter integration.
type OpenRouterDesyncResponse ¶ added in v0.0.6
type OpenRouterDesyncResponse struct {
TenantUUID string `json:"tenant_uuid"`
Removed bool `json:"removed"`
}
OpenRouterDesyncResponse is returned after a successful workspace removal.
type OpenRouterEmbeddingModel ¶ added in v0.0.6
type OpenRouterEmbeddingModel struct {
ID string `json:"id"`
Name string `json:"name"`
Provider string `json:"provider"`
VectorSize int `json:"vector_size"`
Description string `json:"description"`
PricePer1M string `json:"price_per_1m_tokens_usd"`
IsFree bool `json:"is_free"`
}
OpenRouterEmbeddingModel describes a single embedding model on OpenRouter.
type OpenRouterListEmbeddingModelsResponse ¶ added in v0.0.6
type OpenRouterListEmbeddingModelsResponse struct {
Models []OpenRouterEmbeddingModel `json:"models"`
Total int `json:"total"`
}
OpenRouterListEmbeddingModelsResponse is the paginated list of OpenRouter embedding models.
type OpenRouterListModelsResponse ¶ added in v0.0.6
type OpenRouterListModelsResponse struct {
Models []OpenRouterModelInfo `json:"models"`
Total int `json:"total"`
}
OpenRouterListModelsResponse is the paginated list of OpenRouter models.
type OpenRouterModelInfo ¶ added in v0.0.6
type OpenRouterModelInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
ContextLength int `json:"context_length,omitempty"`
Pricing OpenRouterModelPricing `json:"pricing"`
IsFree bool `json:"is_free"`
}
OpenRouterModelInfo describes a single model available on OpenRouter.
type OpenRouterModelPricing ¶ added in v0.0.6
type OpenRouterModelPricing struct {
Prompt string `json:"prompt"`
Completion string `json:"completion"`
}
OpenRouterModelPricing holds per-token pricing for an OpenRouter model.
type OpenRouterSyncRequest ¶ added in v0.0.6
type OpenRouterSyncRequest struct {
TenantUUID string `json:"tenant_uuid,omitempty"`
}
OpenRouterSyncRequest is the body for syncing a workspace with OpenRouter. TenantUUID is optional and only honoured when the caller is a SystemAdmin.
type OpenRouterSyncResponse ¶ added in v0.0.6
type OpenRouterSyncResponse struct {
TenantUUID string `json:"tenant_uuid"`
WorkspaceID string `json:"workspace_id"`
KeyHash string `json:"key_hash"`
Active bool `json:"active"`
AlreadySynced bool `json:"already_synced"`
SyncedAt string `json:"synced_at"`
}
OpenRouterSyncResponse is returned after a successful workspace sync.
type Options ¶
type Options struct {
// BaseURL overrides the default API base URL (https://synapse.wonit.net.br).
// Useful for staging environments or self-hosted deployments.
BaseURL string
// Timeout sets the maximum duration for each HTTP request.
// Defaults to 30 seconds when zero.
Timeout time.Duration
}
Options configures the Synapse client at creation time. All fields are optional; zero values fall back to library defaults.
type ProviderCase ¶
type ProviderCase interface {
// Get fetches a single provider by its UUID.
Get(ctx context.Context, id string) (*ProviderResponseDto, error)
// List returns a paginated list of all available providers.
List(ctx context.Context, page, pageSize int) (*ProvidersResponseDto, error)
}
ProviderCase provides read operations for catalog integration providers.
type ProviderResponseDto ¶
type ProviderResponseDto struct {
ID string `json:"id"`
Name string `json:"name"`
LogoURL string `json:"logo_url"`
Website string `json:"website"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
ProviderResponseDto describes a catalog integration provider (e.g. Google, OpenAI).
type ProvidersResponseDto ¶
type ProvidersResponseDto struct {
Page int `json:"page"`
Size int `json:"size"`
Providers []ProviderResponseDto `json:"providers"`
}
ProvidersResponseDto is the paginated response for the provider list.
type RestErrCause ¶
RestErrCause holds a field-level validation detail returned by the API.
type ServiceCase ¶
type ServiceCase interface {
// Get fetches a single integration service by its UUID.
Get(ctx context.Context, id string) (*ServiceResponseDto, error)
// List returns a paginated list of all available integration services.
List(ctx context.Context, page, pageSize int) (*ServicesResponseDto, error)
}
ServiceCase provides read operations for catalog integration services.
type ServiceResponseDto ¶
type ServiceResponseDto struct {
ID string `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
ProviderID string `json:"provider_id"`
BaseURL string `json:"base_url"`
AuthType string `json:"auth_type"`
DocumentationURL string `json:"documentation_url"`
}
ServiceResponseDto describes a catalog integration service.
type ServicesResponseDto ¶
type ServicesResponseDto struct {
Page int `json:"page"`
Size int `json:"size"`
Services []ServiceResponseDto `json:"services"`
}
ServicesResponseDto is the paginated response for the service list.
type TenantCase ¶
type TenantCase interface {
// Get fetches a tenant by UUID or document (CNPJ/CPF).
// At least one of uuid or document must be non-empty.
Get(ctx context.Context, uuid, document string) (*TenantResponseDto, error)
// List returns a paginated list of all tenants.
List(ctx context.Context, page, pageSize int) (*TenantsResponseDto, error)
// Create registers a new tenant.
Create(ctx context.Context, req CreateTenantRequestDto) (*TenantResponseDto, error)
// Update partially updates the tenant identified by uuid.
Update(ctx context.Context, uuid string, req UpdateTenantRequestDto) (*TenantResponseDto, error)
// Delete permanently removes a tenant by UUID or document.
// At least one of uuid or document must be non-empty.
Delete(ctx context.Context, uuid, document string) error
}
TenantCase provides CRUD operations for tenants within the Synapse API.
type TenantResponseDto ¶
type TenantResponseDto struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Document string `json:"document"`
Live bool `json:"live"`
CreatedAt string `json:"createAt"`
UpdatedAt string `json:"updateAt"`
}
TenantResponseDto is the tenant shape returned by the API.
type TenantsResponseDto ¶
type TenantsResponseDto struct {
Page int `json:"page"`
Size int `json:"size"`
Tenants []TenantResponseDto `json:"tenants"`
}
TenantsResponseDto is the paginated response for the tenant list.
type TranscribeAudioFromURLRequest ¶ added in v0.0.5
type TranscribeAudioFromURLRequest struct {
// FileURL is the download link the server uses to fetch the audio file.
FileURL string `json:"file_url"`
// Model selects the transcription engine: whisper-1 | gpt-4o-transcribe | gpt-4o-mini-transcribe.
Model string `json:"model,omitempty"`
// Language hints the spoken language (e.g. "pt", "en", "es").
Language string `json:"language,omitempty"`
// Prompt is optional auxiliary text to improve transcription accuracy.
Prompt string `json:"prompt,omitempty"`
}
TranscribeAudioFromURLRequest groups all parameters for the audio transcription endpoint when the audio file is fetched from a download URL by the server.
type TranscribeAudioRequest ¶
type TranscribeAudioRequest struct {
// FileName is used as the multipart filename (e.g. "recording.mp3").
FileName string
// Content is the raw audio file bytes.
Content []byte
// Model selects the transcription engine: whisper-1 | gpt-4o-transcribe | gpt-4o-mini-transcribe.
Model string
// Language hints the spoken language (e.g. "pt", "en", "es").
Language string
// Prompt is optional auxiliary text to improve transcription accuracy.
Prompt string
}
TranscribeAudioRequest groups all parameters for the audio transcription endpoint.
type TranscriptionResponse ¶
type TranscriptionResponse struct {
Response string `json:"response"`
}
TranscriptionResponse is the response from the audio transcription endpoint.
type UpdateAgentRequest ¶ added in v0.0.6
type UpdateAgentRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Model *string `json:"model,omitempty"`
Prompt *string `json:"prompt,omitempty"`
CollectionUUID *string `json:"collection_uuid,omitempty"`
MaxContext *int `json:"max_context,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
Active *bool `json:"active,omitempty"`
}
UpdateAgentRequest is used for both full (PUT) and partial (PATCH) agent updates. For PATCH, set exactly one field; for PUT you may set multiple.
type UpdateTenantRequestDto ¶
type UpdateTenantRequestDto struct {
Name string `json:"name,omitempty"`
Document string `json:"document,omitempty"`
// Live uses a pointer so false can be distinguished from omitted.
Live *bool `json:"live,omitempty"`
}
UpdateTenantRequestDto is the body for partially updating a tenant.
type UpdateUserRequestDto ¶
type UpdateUserRequestDto struct {
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
Password string `json:"password,omitempty"`
Role UserRole `json:"role,omitempty"`
}
UpdateUserRequestDto is the body for partially updating a user.
type UploadDocumentRequest ¶ added in v0.0.6
type UploadDocumentRequest struct {
// CollectionUUID is the UUID of the target Qdrant collection.
CollectionUUID string
// EmbedModel is the OpenRouter embedding model ID (e.g. "openai/text-embedding-ada-002").
EmbedModel string
// ChunkSize is the chunk size in characters (default: 1000 when zero).
ChunkSize int
// ChunkOverlap is the overlap between chunks in characters (default: 200 when zero).
ChunkOverlap int
// FileName is the multipart filename (e.g. "report.pdf").
FileName string
// Content is the raw file bytes (PDF, HTML, DOCX, XLSX, CSV).
Content []byte
}
UploadDocumentRequest groups all parameters for the document upload endpoint.
type UserCase ¶
type UserCase interface {
// Get returns a single user by UUID or email.
// Pass the authenticated user's own identifier to fetch their profile.
Get(ctx context.Context, identifier string) (*UserResponseDto, error)
// List returns a paginated list of users.
// SystemAdmin can filter by tenant using params.TenantIdentifier.
List(ctx context.Context, params ListUsersParams) ([]UserResponseDto, error)
// Create registers a new user under the given tenant identifier (UUID or document).
Create(ctx context.Context, tenantIdentifier string, req CreateUserRequestDto) (*UserResponseDto, error)
// Update partially updates a user identified by UUID or email.
Update(ctx context.Context, identifier string, req UpdateUserRequestDto) (*UserResponseDto, error)
// Delete permanently removes a user identified by UUID or email.
Delete(ctx context.Context, identifier string) error
}
UserCase provides CRUD operations for users within the Synapse API.
type UserResponseDto ¶
type UserResponseDto struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Email string `json:"email"`
Role UserRole `json:"role"`
TenantUUID string `json:"tenant_uuid"`
Live bool `json:"live"`
CreatedAt string `json:"create_at"`
UpdatedAt string `json:"update_at"`
}
UserResponseDto is the user shape returned by the API.
type UserRole ¶
type UserRole string
UserRole represents the access level of a user within the system.
type VisionAICredentialsDTO ¶
type VisionAICredentialsDTO struct {
Token string `json:"token"`
}
VisionAICredentialsDTO holds the API key for the Google Vision integration.
type VisionOCRFromURLRequest ¶ added in v0.0.5
type VisionOCRFromURLRequest struct {
FileURL string `json:"file_url"`
}
VisionOCRFromURLRequest is the body for the Google Vision OCR endpoint when the image is fetched by the server from a download URL.