Documentation
¶
Index ¶
- Constants
- Variables
- type AIEngine
- type AddFileReq
- type AddFileResult
- type AddIpfsFileRes
- type AgentPromptHead
- type AudioSpeechRequestExample
- type BidGetter
- type BuildProgress
- type BuildProgressCallback
- type CIDReq
- type CallAgentToolReq
- type CapacityManagerInterface
- type ChatCompletionRequestSwaggerExample
- type ContainerInfo
- type DockerBuildReq
- type DockerBuildRes
- type DockerContainerActionReq
- type DockerContainerInfoRes
- type DockerListContainersReq
- type DockerListContainersRes
- type DockerLogsReq
- type DockerManager
- func (d *DockerManager) BuildImage(ctx context.Context, contextPath, dockerfile, imageName, imageTag string, ...) (string, error)
- func (d *DockerManager) GetContainerInfo(ctx context.Context, containerID string) (*ContainerInfo, error)
- func (d *DockerManager) GetContainerLogs(ctx context.Context, containerID string, tail int, follow bool) (io.ReadCloser, error)
- func (d *DockerManager) GetDockerVersion(ctx context.Context) (string, error)
- func (d *DockerManager) IsClientReady() error
- func (d *DockerManager) ListContainers(ctx context.Context, all bool, filterLabels map[string]string) ([]ContainerInfo, error)
- func (d *DockerManager) PruneContainers(ctx context.Context) (int64, error)
- func (d *DockerManager) PruneImages(ctx context.Context) (int64, error)
- func (d *DockerManager) RemoveContainer(ctx context.Context, containerID string, force bool) error
- func (d *DockerManager) StartContainer(ctx context.Context, imageName string, containerName string, env []string, ...) (string, error)
- func (d *DockerManager) StopContainer(ctx context.Context, containerID string, timeout int) error
- type DockerPruneRes
- type DockerStartContainerReq
- type DockerStartContainerRes
- type DockerStreamBuildEvent
- type DockerVersionRes
- type DownloadFileReq
- type DownloadProgressEvent
- type EmbeddingsRequestExample
- type IdleTimeoutCapacityManager
- type InferenceRes
- type InitiateSessionReq
- type IpfsManager
- func (i *IpfsManager) AddFile(ctx context.Context, filePath string, tags []string, id string, ...) (*AddFileResult, error)
- func (i *IpfsManager) GetFile(ctx context.Context, metadataCIDStr string, destinationPath string) error
- func (i *IpfsManager) GetFileWithProgress(ctx context.Context, metadataCIDStr string, destinationPath string, ...) error
- func (i *IpfsManager) GetPinnedFiles(ctx context.Context) ([]PinnedFileMetadata, error)
- func (i *IpfsManager) GetVersion(ctx context.Context) (string, error)
- func (i *IpfsManager) IsNodeReady() error
- func (i *IpfsManager) Pin(ctx context.Context, cidStr string) error
- func (i *IpfsManager) Unpin(ctx context.Context, cidStr string) error
- type IpfsVersionRes
- type MORRPCController
- type PingReq
- type PingRes
- type PinnedFileMetadata
- type PinnedFileRes
- type PortMapping
- type ProgressCallback
- type ProgressReader
- type PromptHead
- type PromptReq
- type ProxyController
- func (c *ProxyController) AddFile(ctx *gin.Context)
- func (c *ProxyController) Agents(ctx *gin.Context)
- func (c *ProxyController) AudioSpeech(ctx *gin.Context)
- func (c *ProxyController) AudioTranscription(ctx *gin.Context)
- func (c *ProxyController) BuildDockerImage(ctx *gin.Context)
- func (c *ProxyController) CallAgentTool(ctx *gin.Context)
- func (c *ProxyController) DeleteChat(ctx *gin.Context)
- func (c *ProxyController) DownloadFile(ctx *gin.Context)
- func (c *ProxyController) Embeddings(ctx *gin.Context)
- func (c *ProxyController) GetAgentTools(ctx *gin.Context)
- func (c *ProxyController) GetChat(ctx *gin.Context)
- func (c *ProxyController) GetChats(ctx *gin.Context)
- func (c *ProxyController) GetContainer(ctx *gin.Context)
- func (c *ProxyController) GetContainerLogs(ctx *gin.Context)
- func (c *ProxyController) GetDockerVersion(ctx *gin.Context)
- func (c *ProxyController) GetIpfsVersion(ctx *gin.Context)
- func (c *ProxyController) GetPinnedFiles(ctx *gin.Context)
- func (s *ProxyController) InitiateSession(ctx *gin.Context)
- func (c *ProxyController) ListContainers(ctx *gin.Context)
- func (c *ProxyController) Models(ctx *gin.Context)
- func (c *ProxyController) Pin(ctx *gin.Context)
- func (s *ProxyController) Ping(ctx *gin.Context)
- func (c *ProxyController) Prompt(ctx *gin.Context)
- func (c *ProxyController) PruneContainers(ctx *gin.Context)
- func (c *ProxyController) PruneImages(ctx *gin.Context)
- func (s *ProxyController) RegisterRoutes(r interfaces.Router)
- func (c *ProxyController) RemoveContainer(ctx *gin.Context)
- func (c *ProxyController) StartContainer(ctx *gin.Context)
- func (c *ProxyController) StopContainer(ctx *gin.Context)
- func (c *ProxyController) StreamBuildDockerImage(ctx *gin.Context)
- func (c *ProxyController) StreamContainerLogs(ctx *gin.Context)
- func (c *ProxyController) StreamDownloadFile(ctx *gin.Context)
- func (c *ProxyController) Unpin(ctx *gin.Context)
- func (c *ProxyController) UpdateChatTitle(ctx *gin.Context)
- type ProxyReceiver
- func (s *ProxyReceiver) CallAgentTool(ctx context.Context, msgID string, reqID string, userPubKey string, ...) (*msg.RpcResponse, error)
- func (s *ProxyReceiver) GetAgentTools(ctx context.Context, msgID string, reqID string, userPubKey string, ...) (*msg.RpcResponse, error)
- func (s *ProxyReceiver) SessionPrompt(ctx context.Context, requestID string, userPubKey string, payload []byte, ...) (int, int, error)
- func (s *ProxyReceiver) SessionReport(ctx context.Context, msgID string, reqID string, session *storages.Session, ...) (*msg.RpcResponse, error)
- func (s *ProxyReceiver) SessionRequest(ctx context.Context, msgID string, reqID string, req *m.SessionReq, ...) (*msg.RpcResponse, error)
- type ProxyServiceSender
- func (p *ProxyServiceSender) CallAgentTool(ctx context.Context, sessionID common.Hash, toolName string, ...) (string, error)
- func (p *ProxyServiceSender) GetAgentTools(ctx context.Context, sessionID common.Hash) (string, error)
- func (p *ProxyServiceSender) GetModelIdSession(ctx context.Context, sessionID common.Hash) (common.Hash, error)
- func (p *ProxyServiceSender) GetSessionReportFromProvider(ctx context.Context, sessionID common.Hash) (*msgs.SessionReportRes, error)
- func (p *ProxyServiceSender) GetSessionReportFromUser(ctx context.Context, sessionID common.Hash) (lib.HexString, lib.HexString, error)
- func (p *ProxyServiceSender) InitiateSession(ctx context.Context, user common.Address, provider common.Address, ...) (*msgs.SessionRes, error)
- func (p *ProxyServiceSender) Ping(ctx context.Context, providerURL string, providerAddr common.Address) (time.Duration, error)
- func (p *ProxyServiceSender) SendAudioSpeech(ctx context.Context, sessionID common.Hash, ...) (interface{}, error)
- func (p *ProxyServiceSender) SendAudioTranscriptionV2(ctx context.Context, sessionID common.Hash, ...) (interface{}, error)
- func (p *ProxyServiceSender) SendEmbeddings(ctx context.Context, sessionID common.Hash, ...) (interface{}, error)
- func (p *ProxyServiceSender) SendPromptV2(ctx context.Context, sessionID common.Hash, ...) (interface{}, error)
- func (p *ProxyServiceSender) SetSessionService(service SessionService)
- type ResponderFlusher
- type ResultResponse
- type SendResponse
- type SessionService
- type SimpleCapacityManager
- type StreamingSession
- type StreamingSessionManager
- func (sm *StreamingSessionManager) CleanupExpiredSessions()
- func (sm *StreamingSessionManager) CreateSession(streamID, sessionID string, totalChunks uint32, fileSize uint64, ...) (*StreamingSession, error)
- func (sm *StreamingSessionManager) GetSession(streamID string) (*StreamingSession, bool)
- func (sm *StreamingSessionManager) RemoveSession(streamID string)
- type UpdateChatTitleReq
Constants ¶
const ( // Memory optimization constants for audio processing BASE64_ENCODING_CHUNK_SIZE = 1024 * 1024 // 1MB chunks for base64 encoding BASE64_DECODING_CHUNK_SIZE = 64 * 1024 // 64KB chunks for base64 decoding CONTENT_TYPE_DETECTION_SIZE = 512 // 512 bytes for content type detection )
const ( TimeoutPingDefault = 5 * time.Second SENDER_AUDIO_STREAM_CHUNK_SIZE = 1 * 1024 * 1024 // 1mb chunks for audio streaming )
const (
AUDIO_STREAM_TIMEOUT_SECONDS = 1 * 60 * 60 // 1 hour timeout for audio streaming sessions
)
Variables ¶
var ( ErrValidation = fmt.Errorf("request validation failed") ErrUnmarshal = fmt.Errorf("failed to unmarshal request") ErrGenerateReport = fmt.Errorf("failed to generate report") )
var ( ErrMissingPrKey = fmt.Errorf("missing private key") ErrCreateReq = fmt.Errorf("failed to create request") ErrProvider = fmt.Errorf("provider request failed") ErrInvalidSig = fmt.Errorf("received invalid signature from provider") ErrFailedStore = fmt.Errorf("failed store user") ErrInvalidResponse = fmt.Errorf("invalid response") ErrResponseErr = fmt.Errorf("response error") ErrDecrFailed = fmt.Errorf("failed to decrypt ai response chunk") ErrMasrshalFailed = fmt.Errorf("failed to marshal response") ErrDecode = fmt.Errorf("failed to decode response") ErrSessionNotFound = fmt.Errorf("session not found") ErrSessionExpired = fmt.Errorf("session expired") ErrProviderNotFound = fmt.Errorf("provider not found") ErrEmpty = fmt.Errorf("empty result and no error") ErrConnectProvider = fmt.Errorf("failed to connect to provider") ErrWriteProvider = fmt.Errorf("failed to write to provider") )
var (
ErrUnknownMethod = fmt.Errorf("unknown method")
)
Functions ¶
This section is empty.
Types ¶
type AIEngine ¶
type AIEngine interface { GetLocalModels() ([]aiengine.LocalModel, error) GetLocalAgents() ([]aiengine.LocalAgent, error) CallAgentTool(ctx context.Context, sessionID, agentID common.Hash, toolName string, input map[string]interface{}) (interface{}, error) GetAgentTools(ctx context.Context, sessionID, agentID common.Hash) ([]aiengine.AgentTool, error) GetAdapter(ctx context.Context, chatID, modelID, sessionID common.Hash, storeContext, forwardContext bool) (aiengine.AIEngineStream, error) }
type AddFileReq ¶
type AddFileResult ¶
type AddFileResult struct { FileCID string `json:"fileCID"` MetadataCID string `json:"metadataCID"` }
AddFileResult contains CIDs for both the file and its metadata
type AddIpfsFileRes ¶
type AddIpfsFileRes struct { FileCID string `json:"fileCID" validate:"required"` MetadataCID string `json:"metadataCID" validate:"required"` FileCIDHash lib.HexString `json:"fileCIDHash" validate:"required" swaggertype:"string"` MetadataCIDHash lib.HexString `json:"metadataCIDHash" validate:"required" swaggertype:"string"` }
type AgentPromptHead ¶
type BuildProgress ¶
type BuildProgress struct { Status string `json:"status"` Stream string `json:"stream,omitempty"` Progress string `json:"progress,omitempty"` ID string `json:"id,omitempty"` Current int64 `json:"current,omitempty"` Total int64 `json:"total,omitempty"` Percentage float64 `json:"percentage,omitempty"` Error string `json:"error,omitempty"` TimeUpdated int64 `json:"timeUpdated"` ErrorDetails string `json:"errorDetails,omitempty"` }
BuildProgress represents the progress of a Docker image build
type BuildProgressCallback ¶
type BuildProgressCallback func(progress BuildProgress) error
BuildProgressCallback is a function that reports build progress
type CallAgentToolReq ¶
type CapacityManagerInterface ¶
func CreateCapacityManager ¶
func CreateCapacityManager(modelConfig *config.ModelConfig, storage *storages.SessionStorage, log lib.ILogger) CapacityManagerInterface
type ContainerInfo ¶
type ContainerInfo struct { ID string `json:"id"` Name string `json:"name"` Image string `json:"image"` Status string `json:"status"` State string `json:"state"` CreatedAt string `json:"createdAt"` Ports []PortMapping `json:"ports"` Labels map[string]string `json:"labels"` NetworkMode string `json:"networkMode"` }
ContainerInfo represents details about a Docker container
type DockerBuildReq ¶
type DockerBuildReq struct { ContextPath string `json:"contextPath" binding:"required" validate:"required"` Dockerfile string `json:"dockerfile" validate:"required"` ImageName string `json:"imageName" binding:"required" validate:"required"` ImageTag string `json:"imageTag"` BuildArgs map[string]string `json:"buildArgs"` }
DockerBuildReq defines the request for building a Docker image
type DockerBuildRes ¶
type DockerBuildRes struct {
ImageTag string `json:"imageTag" validate:"required"`
}
DockerBuildRes defines the response for building a Docker image
type DockerContainerActionReq ¶
type DockerContainerActionReq struct { ContainerID string `json:"containerId" binding:"required" validate:"required"` Timeout int `json:"timeout,omitempty"` Force bool `json:"force,omitempty"` }
DockerContainerActionReq defines the request for container actions (stop, remove)
type DockerContainerInfoRes ¶
type DockerContainerInfoRes struct {
ContainerInfo
}
DockerContainerInfoRes defines the response for container info
type DockerListContainersReq ¶
type DockerListContainersReq struct { All bool `json:"all"` FilterLabels map[string]string `json:"filterLabels"` }
DockerListContainersReq defines the request for listing containers
type DockerListContainersRes ¶
type DockerListContainersRes struct {
Containers []ContainerInfo `json:"containers"`
}
DockerListContainersRes defines the response for listing containers
type DockerLogsReq ¶
type DockerLogsReq struct { ContainerID string `json:"containerId" binding:"required" validate:"required"` Tail int `json:"tail,omitempty"` Follow bool `json:"follow,omitempty"` }
DockerLogsReq defines the request for container logs
type DockerManager ¶
type DockerManager struct {
// contains filtered or unexported fields
}
DockerManager is a wrapper for the Docker SDK
func NewDockerManager ¶
func NewDockerManager(log lib.ILogger) *DockerManager
NewDockerManager creates a new Docker manager
func (*DockerManager) BuildImage ¶
func (d *DockerManager) BuildImage(ctx context.Context, contextPath, dockerfile, imageName, imageTag string, buildArgs map[string]string, progressCallback BuildProgressCallback) (string, error)
BuildImage builds a Docker image from a Dockerfile in the specified context path
func (*DockerManager) GetContainerInfo ¶
func (d *DockerManager) GetContainerInfo(ctx context.Context, containerID string) (*ContainerInfo, error)
GetContainerInfo retrieves information about a container
func (*DockerManager) GetContainerLogs ¶
func (d *DockerManager) GetContainerLogs(ctx context.Context, containerID string, tail int, follow bool) (io.ReadCloser, error)
GetContainerLogs retrieves logs from a container
func (*DockerManager) GetDockerVersion ¶
func (d *DockerManager) GetDockerVersion(ctx context.Context) (string, error)
GetDockerVersion gets the Docker server version
func (*DockerManager) IsClientReady ¶
func (d *DockerManager) IsClientReady() error
IsClientReady checks if the Docker client is ready
func (*DockerManager) ListContainers ¶
func (d *DockerManager) ListContainers(ctx context.Context, all bool, filterLabels map[string]string) ([]ContainerInfo, error)
ListContainers lists all containers matching the specified filters
func (*DockerManager) PruneContainers ¶
func (d *DockerManager) PruneContainers(ctx context.Context) (int64, error)
PruneContainers removes stopped containers
func (*DockerManager) PruneImages ¶
func (d *DockerManager) PruneImages(ctx context.Context) (int64, error)
PruneImages removes unused Docker images
func (*DockerManager) RemoveContainer ¶
RemoveContainer removes a Docker container
func (*DockerManager) StartContainer ¶
func (d *DockerManager) StartContainer(ctx context.Context, imageName string, containerName string, env []string, ports map[string]string, volumes map[string]string, networkMode string) (string, error)
StartContainer starts a Docker container with the specified options
func (*DockerManager) StopContainer ¶
StopContainer stops a Docker container
type DockerPruneRes ¶
type DockerPruneRes struct {
SpaceReclaimed int64 `json:"spaceReclaimed"`
}
DockerPruneRes defines the response for Docker pruning operations
type DockerStartContainerReq ¶
type DockerStartContainerReq struct { ImageName string `json:"imageName" binding:"required" validate:"required"` ContainerName string `json:"containerName"` Env []string `json:"env"` Ports map[string]string `json:"ports"` Volumes map[string]string `json:"volumes"` NetworkMode string `json:"networkMode"` }
DockerStartContainerReq defines the request for starting a Docker container
type DockerStartContainerRes ¶
type DockerStartContainerRes struct {
ContainerID string `json:"containerId" validate:"required"`
}
DockerStartContainerRes defines the response for starting a Docker container
type DockerStreamBuildEvent ¶
type DockerStreamBuildEvent struct { Status string `json:"status"` // Status message Stream string `json:"stream,omitempty"` Progress string `json:"progress,omitempty"` ID string `json:"id,omitempty"` Current int64 `json:"current,omitempty"` Total int64 `json:"total,omitempty"` Percentage float64 `json:"percentage,omitempty"` Error string `json:"error,omitempty"` TimeUpdated int64 `json:"timeUpdated"` ErrorDetails string `json:"errorDetails,omitempty"` }
DockerStreamBuildEvent defines a stream event for Docker image building
type DockerVersionRes ¶
type DockerVersionRes struct {
Version string `json:"version" validate:"required"`
}
DockerVersionRes defines the response for Docker version
type DownloadFileReq ¶
type DownloadFileReq struct {
DestinationPath string `json:"destinationPath" validate:"required"`
}
type DownloadProgressEvent ¶
type DownloadProgressEvent struct { Status string `json:"status"` // "downloading", "completed", "error" Downloaded int64 `json:"downloaded"` // Bytes downloaded so far Total int64 `json:"total"` // Total bytes to download Percentage float64 `json:"percentage"` // Percentage complete (0-100) Error string `json:"error,omitempty"` // Error message, if status is "error" TimeUpdated int64 `json:"timeUpdated"` // Timestamp of the update }
type IdleTimeoutCapacityManager ¶
type IdleTimeoutCapacityManager struct {
// contains filtered or unexported fields
}
func NewIdleTimeoutCapacityManager ¶
func NewIdleTimeoutCapacityManager(modelConfig *config.ModelConfig, storage *storages.SessionStorage, log lib.ILogger) *IdleTimeoutCapacityManager
func (*IdleTimeoutCapacityManager) HasCapacity ¶
func (idcm *IdleTimeoutCapacityManager) HasCapacity(modelID string) bool
type InferenceRes ¶
type InferenceRes struct { Signature lib.HexString `json:"signature,omitempty" validate:"required,hexadecimal"` Message json.RawMessage `json:"message" validate:"required"` Timestamp uint64 `json:"timestamp" validate:"required,timestamp"` }
type InitiateSessionReq ¶
type InitiateSessionReq struct { User common.Address `json:"user" validate:"required,eth_addr"` Provider common.Address `json:"provider" validate:"required,eth_addr"` Spend lib.BigInt `json:"spend" validate:"required,number" swaggertype:"string"` ProviderUrl string `json:"providerUrl" validate:"required,hostname_port"` BidID common.Hash `json:"bidId" validate:"required,hex32"` }
type IpfsManager ¶
type IpfsManager struct {
// contains filtered or unexported fields
}
func NewIpfsManager ¶
func NewIpfsManager(ipfsAddress string, log lib.ILogger) *IpfsManager
NewIpfsManager connects to the local Kubo (IPFS) node using the RPC client.
func NewIpfsManagerDisabled ¶
func NewIpfsManagerDisabled(log lib.ILogger) *IpfsManager
func (*IpfsManager) AddFile ¶
func (i *IpfsManager) AddFile(ctx context.Context, filePath string, tags []string, id string, modelName string) (*AddFileResult, error)
AddFile adds a file and its metadata to IPFS.
func (*IpfsManager) GetFile ¶
func (i *IpfsManager) GetFile(ctx context.Context, metadataCIDStr string, destinationPath string) error
GetFile downloads a file using GetFileWithProgress with a nil progress callback
func (*IpfsManager) GetFileWithProgress ¶
func (i *IpfsManager) GetFileWithProgress(ctx context.Context, metadataCIDStr string, destinationPath string, progressCallback ProgressCallback) error
GetFileWithProgress downloads a file using its metadata CID with progress reporting
func (*IpfsManager) GetPinnedFiles ¶
func (i *IpfsManager) GetPinnedFiles(ctx context.Context) ([]PinnedFileMetadata, error)
GetPinnedFiles returns metadata for all pinned files. It only returns metadata files, ignoring the actual content files.
func (*IpfsManager) GetVersion ¶
func (i *IpfsManager) GetVersion(ctx context.Context) (string, error)
func (*IpfsManager) IsNodeReady ¶
func (i *IpfsManager) IsNodeReady() error
type IpfsVersionRes ¶
type IpfsVersionRes struct {
Version string `json:"version" validate:"required"`
}
type MORRPCController ¶
type MORRPCController struct {
// contains filtered or unexported fields
}
func NewMORRPCController ¶
func NewMORRPCController(service *ProxyReceiver, validator *validator.Validate, sessionRepo *sessionrepo.SessionRepositoryCached, sessionStorage *storages.SessionStorage, prKey lib.HexString) *MORRPCController
func (*MORRPCController) Handle ¶
func (s *MORRPCController) Handle(ctx context.Context, msg m.RPCMessage, sourceLog lib.ILogger, sendResponse SendResponse) error
type PinnedFileMetadata ¶
type PinnedFileMetadata struct { FileName string `json:"fileName"` FileSize int64 `json:"fileSize"` FileCID string `json:"fileCID"` Tags []string `json:"tags"` ID string `json:"id"` ModelName string `json:"modelName"` MetadataCID string `json:"metadataCID,omitempty"` }
PinnedFileMetadata represents metadata about a file stored in IPFS
type PinnedFileRes ¶
type PinnedFileRes struct { FileName string `json:"fileName"` FileSize int64 `json:"fileSize"` FileCID string `json:"fileCID" validate:"required"` FileCIDHash lib.HexString `json:"fileCIDHash" validate:"required" swaggertype:"string"` Tags []string `json:"tags"` ID string `json:"id"` ModelName string `json:"modelName"` MetadataCID string `json:"metadataCID" validate:"required"` MetadataCIDHash lib.HexString `json:"metadataCIDHash" validate:"required" swaggertype:"string"` }
type PortMapping ¶
type PortMapping struct { HostIP string `json:"hostIp"` HostPort string `json:"hostPort"` ContainerPort string `json:"containerPort"` Protocol string `json:"protocol"` }
PortMapping represents a port mapping for a container
type ProgressCallback ¶
ProgressCallback is a function that reports download progress
type ProgressReader ¶
type ProgressReader struct { Reader io.Reader Total int64 Downloaded int64 OnProgress ProgressCallback Ctx context.Context // Add context for cancellation checks }
ProgressReader is an io.Reader wrapper that reports progress
type PromptHead ¶
type PromptReq ¶
type PromptReq struct { Signature string `json:"signature" validate:"required,hexadecimal"` Message json.RawMessage `json:"message" validate:"required"` Timestamp string `json:"timestamp" validate:"required,timestamp"` }
type ProxyController ¶
type ProxyController struct {
// contains filtered or unexported fields
}
func NewProxyController ¶
func NewProxyController(service *ProxyServiceSender, aiEngine AIEngine, chatStorage gsc.ChatStorageInterface, storeChatContext, forwardChatContext bool, authConfig system.HTTPAuthConfig, ipfsManager *IpfsManager, log lib.ILogger) *ProxyController
func (*ProxyController) AddFile ¶
func (c *ProxyController) AddFile(ctx *gin.Context)
AddFile godoc
@Summary Add a file to IPFS with metadata @Tags ipfs @Produce json @Param request body proxyapi.AddFileReq true "File Path and Metadata" @Success 200 {object} proxyapi.AddIpfsFileRes @Security BasicAuth @Router /ipfs/add [post]
func (*ProxyController) Agents ¶
func (c *ProxyController) Agents(ctx *gin.Context)
GetLocalAgents godoc
@Summary Get local agents @Tags agents @Produce json @Success 200 {object} []aiengine.LocalAgent @Security BasicAuth @Router /v1/agents [get]
func (*ProxyController) AudioSpeech ¶
func (c *ProxyController) AudioSpeech(ctx *gin.Context)
AudioSpeech godoc
@Summary Generate Audio Speech @Description Convert text to speech using TTS model @Tags audio @Produce audio/mpeg @Param session_id header string false "Session ID" format(hex32) @Param model_id header string false "Model ID" format(hex32) @Param chat_id header string false "Chat ID" format(hex32) @Param request body proxyapi.AudioSpeechRequestExample true "Audio speech request parameters" @Success 200 {file} binary @Security BasicAuth @Router /v1/audio/speech [post]
func (*ProxyController) AudioTranscription ¶
func (c *ProxyController) AudioTranscription(ctx *gin.Context)
AudioTranscription godoc
@Summary Transcribe audio file @Description Transcribes audio files to text using AI models @Tags audio @Accept multipart/form-data @Produce json @Param session_id header string false "Session ID" format(hex32) @Param model_id header string false "Model ID" format(hex32) @Param file formData file true "Audio file to transcribe" @Param language formData string false "Language of the audio" @Param prompt formData string false "Optional prompt to guide transcription" @Param response_format formData string false "Response format: json, text, srt, verbose_json, vtt" @Param temperature formData number false "Temperature for sampling" @Param timestamp_granularities[] formData string false "Timestamp granularity: word or segment" @Param stream formData boolean false "Whether to stream the results or not" @Security BasicAuth @Router /v1/audio/transcriptions [post]
func (*ProxyController) BuildDockerImage ¶
func (c *ProxyController) BuildDockerImage(ctx *gin.Context)
BuildDockerImage godoc
@Summary Build a Docker image @Tags docker @Produce json @Param request body proxyapi.DockerBuildReq true "Docker build request" @Success 200 {object} proxyapi.DockerBuildRes @Security BasicAuth @Router /docker/build [post]
func (*ProxyController) CallAgentTool ¶
func (c *ProxyController) CallAgentTool(ctx *gin.Context)
CallAgentTool godoc
@Summary Call agent tool @Tags agents @Produce json @Param session_id header string false "Session ID" format(hex32) @Param agent_id header string false "Agent ID" format(hex32) @Param input body proxyapi.CallAgentToolReq true "Input" @Success 200 {object} interface{} @Security BasicAuth @Router /v1/agents/tools [post]
func (*ProxyController) DeleteChat ¶
func (c *ProxyController) DeleteChat(ctx *gin.Context)
DeleteChat godoc
@Summary Delete chat by id from storage @Tags chat @Produce json @Param id path string true "Chat ID" @Success 200 {object} proxyapi.ResultResponse @Security BasicAuth @Router /v1/chats/{id} [delete]
func (*ProxyController) DownloadFile ¶
func (c *ProxyController) DownloadFile(ctx *gin.Context)
DownloadFile godoc
@Summary Download a file from IPFS @Tags ipfs @Produce json @Param cidHash path string true "cidHash" @Param dest query string true "Destination Path" @Success 200 {object} proxyapi.ResultResponse @Security BasicAuth @Router /ipfs/download/{cidHash} [get]
func (*ProxyController) Embeddings ¶
func (c *ProxyController) Embeddings(ctx *gin.Context)
Embeddings godoc
@Summary Generate embeddings @Description Generate vector embeddings for the provided input @Tags audio @Produce json @Param session_id header string false "Session ID" format(hex32) @Param model_id header string false "Model ID" format(hex32) @Param chat_id header string false "Chat ID" format(hex32) @Param request body proxyapi.EmbeddingsRequestExample true "Embeddings request parameters" @Success 200 {object} string @Security BasicAuth @Router /v1/embeddings [post]
func (*ProxyController) GetAgentTools ¶
func (c *ProxyController) GetAgentTools(ctx *gin.Context)
GetAgentTools godoc
@Summary Get agent tools @Tags agents @Produce json @Param session_id header string false "Session ID" format(hex32) @Param agent_id header string false "Agent ID" format(hex32) @Success 200 {object} []aiengine.AgentTool @Security BasicAuth @Router /v1/agents/tools [get]
func (*ProxyController) GetChat ¶
func (c *ProxyController) GetChat(ctx *gin.Context)
GetChat godoc
@Summary Get chat by id @Tags chat @Produce json @Param id path string true "Chat ID" @Success 200 {object} genericchatstorage.ChatHistory @Security BasicAuth @Router /v1/chats/{id} [get]
func (*ProxyController) GetChats ¶
func (c *ProxyController) GetChats(ctx *gin.Context)
GetChats godoc
@Summary Get all chats stored in the system @Tags chat @Produce json @Success 200 {object} []genericchatstorage.Chat @Security BasicAuth @Router /v1/chats [get]
func (*ProxyController) GetContainer ¶
func (c *ProxyController) GetContainer(ctx *gin.Context)
GetContainer godoc
@Summary Get Docker container info @Tags docker @Produce json @Param id path string true "Container ID" @Success 200 {object} proxyapi.DockerContainerInfoRes @Security BasicAuth @Router /docker/container/{id} [get]
func (*ProxyController) GetContainerLogs ¶
func (c *ProxyController) GetContainerLogs(ctx *gin.Context)
GetContainerLogs godoc
@Summary Get Docker container logs @Tags docker @Produce text/plain @Param id path string true "Container ID" @Param tail query integer false "Number of lines to show from the end" @Param follow query boolean false "Follow log output" @Success 200 {string} string "Log output" @Security BasicAuth @Router /docker/container/{id}/logs [get]
func (*ProxyController) GetDockerVersion ¶
func (c *ProxyController) GetDockerVersion(ctx *gin.Context)
GetDockerVersion godoc
@Summary Get Docker version @Tags docker @Produce json @Success 200 {object} proxyapi.DockerVersionRes @Security BasicAuth @Router /docker/version [get]
func (*ProxyController) GetIpfsVersion ¶
func (c *ProxyController) GetIpfsVersion(ctx *gin.Context)
GetIpfsVersion godoc
@Summary Get IPFS Version @Tags ipfs @Produce json @Success 200 {object} proxyapi.IpfsVersionRes @Security BasicAuth @Router /ipfs/version [get]
func (*ProxyController) GetPinnedFiles ¶
func (c *ProxyController) GetPinnedFiles(ctx *gin.Context)
GetPinnedFiles godoc
@Summary Get all pinned files metadata @Tags ipfs @Produce json @Success 200 {array} proxyapi.PinnedFileRes @Security BasicAuth @Router /ipfs/pin [get]
func (*ProxyController) InitiateSession ¶
func (s *ProxyController) InitiateSession(ctx *gin.Context)
InitiateSession godoc
@Summary Initiate Session with Provider @Description sends a handshake to the provider @Tags chat @Produce json @Param initiateSession body proxyapi.InitiateSessionReq true "Initiate Session" @Success 200 {object} morrpcmesssage.SessionRes @Security BasicAuth @Router /proxy/sessions/initiate [post]
func (*ProxyController) ListContainers ¶
func (c *ProxyController) ListContainers(ctx *gin.Context)
ListContainers godoc
@Summary List Docker containers @Tags docker @Produce json @Param request body proxyapi.DockerListContainersReq true "Docker list containers request" @Success 200 {object} proxyapi.DockerListContainersRes @Security BasicAuth @Router /docker/containers [post]
func (*ProxyController) Models ¶
func (c *ProxyController) Models(ctx *gin.Context)
GetLocalModels godoc
@Summary Get local models @Tags system @Produce json @Success 200 {object} []aiengine.LocalModel @Security BasicAuth @Router /v1/models [get]
func (*ProxyController) Pin ¶
func (c *ProxyController) Pin(ctx *gin.Context)
Pin godoc
@Summary Pin a file to IPFS @Tags ipfs @Produce json @Param cidHash body proxyapi.CIDReq true "cidHash" @Success 200 {object} proxyapi.ResultResponse @Security BasicAuth @Router /ipfs/pin [post]
func (*ProxyController) Ping ¶
func (s *ProxyController) Ping(ctx *gin.Context)
Ping godoc
@Summary Ping Provider @Description sends a ping to the provider on the RPC level @Tags chat @Produce json @Param pingReq body proxyapi.PingReq true "Ping Request" @Success 200 {object} proxyapi.PingRes @Router /proxy/provider/ping [post]
func (*ProxyController) Prompt ¶
func (c *ProxyController) Prompt(ctx *gin.Context)
SendPrompt godoc
@Summary Send Local Or Remote Prompt @Description Send prompt to a local or remote model based on session id in header @Tags chat @Produce text/event-stream @Param session_id header string false "Session ID" format(hex32) @Param model_id header string false "Model ID" format(hex32) @Param chat_id header string false "Chat ID" format(hex32) @Param prompt body proxyapi.ChatCompletionRequestSwaggerExample true "Prompt" @Success 200 {object} string @Security BasicAuth @Router /v1/chat/completions [post]
func (*ProxyController) PruneContainers ¶
func (c *ProxyController) PruneContainers(ctx *gin.Context)
PruneContainers godoc
@Summary Prune stopped Docker containers @Tags docker @Produce json @Success 200 {object} proxyapi.DockerPruneRes @Security BasicAuth @Router /docker/prune/containers [post]
func (*ProxyController) PruneImages ¶
func (c *ProxyController) PruneImages(ctx *gin.Context)
PruneImages godoc
@Summary Prune unused Docker images @Tags docker @Produce json @Success 200 {object} proxyapi.DockerPruneRes @Security BasicAuth @Router /docker/prune/images [post]
func (*ProxyController) RegisterRoutes ¶
func (s *ProxyController) RegisterRoutes(r interfaces.Router)
func (*ProxyController) RemoveContainer ¶
func (c *ProxyController) RemoveContainer(ctx *gin.Context)
RemoveContainer godoc
@Summary Remove a Docker container @Tags docker @Produce json @Param request body proxyapi.DockerContainerActionReq true "Docker container remove request" @Success 200 {object} proxyapi.ResultResponse @Security BasicAuth @Router /docker/container/remove [post]
func (*ProxyController) StartContainer ¶
func (c *ProxyController) StartContainer(ctx *gin.Context)
StartContainer godoc
@Summary Start a Docker container @Tags docker @Produce json @Param request body proxyapi.DockerStartContainerReq true "Docker start container request" @Success 200 {object} proxyapi.DockerStartContainerRes @Security BasicAuth @Router /docker/container/start [post]
func (*ProxyController) StopContainer ¶
func (c *ProxyController) StopContainer(ctx *gin.Context)
StopContainer godoc
@Summary Stop a Docker container @Tags docker @Produce json @Param request body proxyapi.DockerContainerActionReq true "Docker container stop request" @Success 200 {object} proxyapi.ResultResponse @Security BasicAuth @Router /docker/container/stop [post]
func (*ProxyController) StreamBuildDockerImage ¶
func (c *ProxyController) StreamBuildDockerImage(ctx *gin.Context)
StreamBuildDockerImage godoc
@Summary Build a Docker image with progress updates as SSE stream @Tags docker @Produce text/event-stream @Param request body proxyapi.DockerBuildReq true "Docker build request" @Success 200 {object} proxyapi.DockerStreamBuildEvent @Security BasicAuth @Router /docker/build/stream [post]
func (*ProxyController) StreamContainerLogs ¶
func (c *ProxyController) StreamContainerLogs(ctx *gin.Context)
StreamContainerLogs godoc
@Summary Stream Docker container logs as SSE @Tags docker @Produce text/event-stream @Param id path string true "Container ID" @Param tail query integer false "Number of lines to show from the end" @Success 200 {string} string "Log output events" @Security BasicAuth @Router /docker/container/{id}/logs/stream [get]
func (*ProxyController) StreamDownloadFile ¶
func (c *ProxyController) StreamDownloadFile(ctx *gin.Context)
StreamDownloadFile godoc
@Summary Download a file from IPFS with progress updates as SSE stream @Tags ipfs @Produce text/event-stream @Param cidHash path string true "cidHash" @Param dest query string true "Destination Path" @Success 200 {object} proxyapi.DownloadProgressEvent @Security BasicAuth @Router /ipfs/download/stream/{cidHash} [get]
func (*ProxyController) Unpin ¶
func (c *ProxyController) Unpin(ctx *gin.Context)
Unpin godoc
@Summary Unpin a file from IPFS @Tags ipfs @Produce json @Param cidHash body proxyapi.CIDReq true "cidHash" @Success 200 {object} proxyapi.ResultResponse @Security BasicAuth @Router /ipfs/unpin [post]
func (*ProxyController) UpdateChatTitle ¶
func (c *ProxyController) UpdateChatTitle(ctx *gin.Context)
UpdateChatTitle godoc
@Summary Update chat title by id @Tags chat @Produce json @Param id path string true "Chat ID" @Param title body proxyapi.UpdateChatTitleReq true "Chat Title" @Success 200 {object} proxyapi.ResultResponse @Security BasicAuth @Router /v1/chats/{id} [post]
type ProxyReceiver ¶
type ProxyReceiver struct {
// contains filtered or unexported fields
}
func NewProxyReceiver ¶
func NewProxyReceiver(privateKeyHex, publicKeyHex lib.HexString, sessionStorage *storages.SessionStorage, aiEngine *aiengine.AiEngine, chainID *big.Int, modelConfigLoader *config.ModelConfigLoader, blockchainService BidGetter, sessionRepo *sessionrepo.SessionRepositoryCached) *ProxyReceiver
func (*ProxyReceiver) CallAgentTool ¶
func (s *ProxyReceiver) CallAgentTool(ctx context.Context, msgID string, reqID string, userPubKey string, req *m.CallAgentToolReq, sourceLog lib.ILogger) (*msg.RpcResponse, error)
func (*ProxyReceiver) GetAgentTools ¶
func (s *ProxyReceiver) GetAgentTools(ctx context.Context, msgID string, reqID string, userPubKey string, req *m.GetAgentToolsReq, sourceLog lib.ILogger) (*msg.RpcResponse, error)
func (*ProxyReceiver) SessionPrompt ¶
func (*ProxyReceiver) SessionReport ¶
func (*ProxyReceiver) SessionRequest ¶
func (s *ProxyReceiver) SessionRequest(ctx context.Context, msgID string, reqID string, req *m.SessionReq, log lib.ILogger) (*msg.RpcResponse, error)
type ProxyServiceSender ¶
type ProxyServiceSender struct {
// contains filtered or unexported fields
}
func NewProxySender ¶
func NewProxySender(chainID *big.Int, privateKey interfaces.PrKeyProvider, logStorage *lib.Collection[*interfaces.LogStorage], sessionStorage *storages.SessionStorage, sessionRepo *sessionrepo.SessionRepositoryCached, log lib.ILogger) *ProxyServiceSender
func (*ProxyServiceSender) CallAgentTool ¶
func (*ProxyServiceSender) GetAgentTools ¶
func (*ProxyServiceSender) GetModelIdSession ¶
func (*ProxyServiceSender) GetSessionReportFromProvider ¶
func (p *ProxyServiceSender) GetSessionReportFromProvider(ctx context.Context, sessionID common.Hash) (*msgs.SessionReportRes, error)
func (*ProxyServiceSender) GetSessionReportFromUser ¶
func (*ProxyServiceSender) InitiateSession ¶
func (*ProxyServiceSender) SendAudioSpeech ¶
func (p *ProxyServiceSender) SendAudioSpeech(ctx context.Context, sessionID common.Hash, audioRequest *gcs.AudioSpeechRequest, cb gcs.CompletionCallback) (interface{}, error)
SendAudioSpeech sends audio speech generation request
func (*ProxyServiceSender) SendAudioTranscriptionV2 ¶
func (p *ProxyServiceSender) SendAudioTranscriptionV2(ctx context.Context, sessionID common.Hash, audioRequest *gcs.AudioTranscriptionRequest, cb gcs.CompletionCallback) (interface{}, error)
SendAudioTranscriptionStreamV2 sends audio transcription using streaming chunks to avoid memory issues with large files
func (*ProxyServiceSender) SendEmbeddings ¶
func (p *ProxyServiceSender) SendEmbeddings(ctx context.Context, sessionID common.Hash, embedRequest *gcs.EmbeddingsRequest, cb gcs.CompletionCallback) (interface{}, error)
SendEmbeddings sends an embeddings generation request
func (*ProxyServiceSender) SendPromptV2 ¶
func (p *ProxyServiceSender) SendPromptV2(ctx context.Context, sessionID common.Hash, prompt *gcs.OpenAICompletionRequestExtra, cb gcs.CompletionCallback) (interface{}, error)
func (*ProxyServiceSender) SetSessionService ¶
func (p *ProxyServiceSender) SetSessionService(service SessionService)
type ResponderFlusher ¶
type ResponderFlusher interface { http.ResponseWriter http.Flusher }
type ResultResponse ¶
type ResultResponse struct {
Result bool `json:"result"`
}
type SendResponse ¶
type SendResponse func(*msg.RpcResponse) error
type SessionService ¶
type SessionService interface { OpenSessionByModelId(ctx context.Context, modelID common.Hash, duration *big.Int, isDirectPayment, isFailoverEnabled bool, omitProvider common.Address, agentUsername string) (common.Hash, error) CloseSession(ctx context.Context, sessionID common.Hash) (common.Hash, error) }
type SimpleCapacityManager ¶
type SimpleCapacityManager struct {
// contains filtered or unexported fields
}
func NewSimpleCapacityManager ¶
func NewSimpleCapacityManager(modelConfig *config.ModelConfig, storage *storages.SessionStorage, log lib.ILogger) *SimpleCapacityManager
func (*SimpleCapacityManager) HasCapacity ¶
func (scm *SimpleCapacityManager) HasCapacity(modelID string) bool
type StreamingSession ¶
type StreamingSession struct { StreamID string SessionID string TotalChunks uint32 FileSize uint64 ContentType string TempFilePath string // Path to temporary file where chunks are written ChunkCount uint32 StartTime time.Time LastActivity time.Time }
StreamingSession represents an active audio streaming session
type StreamingSessionManager ¶
type StreamingSessionManager struct {
// contains filtered or unexported fields
}
StreamingSessionManager manages active streaming sessions
func NewStreamingSessionManager ¶
func NewStreamingSessionManager() *StreamingSessionManager
func (*StreamingSessionManager) CleanupExpiredSessions ¶
func (sm *StreamingSessionManager) CleanupExpiredSessions()
func (*StreamingSessionManager) CreateSession ¶
func (sm *StreamingSessionManager) CreateSession(streamID, sessionID string, totalChunks uint32, fileSize uint64, contentType string) (*StreamingSession, error)
func (*StreamingSessionManager) GetSession ¶
func (sm *StreamingSessionManager) GetSession(streamID string) (*StreamingSession, bool)
func (*StreamingSessionManager) RemoveSession ¶
func (sm *StreamingSessionManager) RemoveSession(streamID string)
type UpdateChatTitleReq ¶
type UpdateChatTitleReq struct {
Title string `json:"title" validate:"required"`
}