{"modulePath":"github.com/luispater/anyAIProxyAPI","version":"v1.2.3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api\n\n## Variables\n\n```go\nvar RequestMutex sync.Mutex\n```\n\n```go\nvar ScreenshotMutex sync.Mutex\n```\n\n## Types\n\n```go\ntype APIHandlers struct {\n\t// contains filtered or unexported fields\n}\n```\nAPIHandlers contains the handlers for API endpoints\n\n```go\nfunc NewAPIHandlers(appConfig *config.AppConfig, queue *RequestQueue, pages map[string]playwright.Page, debug bool) *APIHandlers\n```\nNewAPIHandlers creates a new API handlers instance\n\n```go\nfunc (h *APIHandlers) ChatCompletions(c *gin.Context)\n```\nChatCompletions handles the /v1/chat/completions endpoint\n\n```go\nfunc (h *APIHandlers) TakeScreenshot(c *gin.Context)\n```\n\n```go\ntype ChatProcessor struct {\n\t// contains filtered or unexported fields\n}\n```\nChatProcessor implements TaskProcessor interface\n\n```go\nfunc NewChatProcessor(appConfig *config.AppConfig, pages map[string]playwright.Page, proxies map[string]*proxy.Proxy, debug bool) *ChatProcessor\n```\nNewChatProcessor creates a new chat processor\n\n```go\nfunc (cp *ChatProcessor) ProcessTask(ctx context.Context, task *RequestTask) *TaskResponse\n```\nProcessTask processes a chat completion task\n\n```go\ntype ErrorDetail struct {\n\tMessage string `json:\"message\"`\n\tType    string `json:\"type\"`\n\tCode    string `json:\"code,omitempty\"`\n}\n```\nErrorDetail represents error details\n\n```go\ntype ErrorResponse struct {\n\tError ErrorDetail `json:\"error\"`\n}\n```\nErrorResponse represents an error response\n\n```go\ntype Prompt struct {\n\tRole        string\n\tContentType string\n\tContent     string\n}\n```\n\n```go\ntype RequestQueue struct {\n\t// contains filtered or unexported fields\n}\n```\nRequestQueue manages the sequential processing of chat completion requests\n\n```go\nfunc NewRequestQueue(processor TaskProcessor) *RequestQueue\n```\nNewRequestQueue creates a new request queue\n\n```go\nfunc (q *RequestQueue) AddTask(task *RequestTask) error\n```\nAddTask adds a new task to the queue\n\n```go\nfunc (q *RequestQueue) GetQueueLength() int\n```\nGetQueueLength returns the current number of tasks in the queue\n\n```go\nfunc (q *RequestQueue) IsRunning() bool\n```\nIsRunning returns whether the queue is currently running\n\n```go\nfunc (q *RequestQueue) Start() error\n```\nStart begins processing requests from the queue\n\n```go\nfunc (q *RequestQueue) Stop() error\n```\nStop stops the request queue and waits for current task to complete\n\n```go\ntype RequestTask struct {\n\tID           string             `json:\"id\"`\n\tRequest      string             `json:\"request\"`\n\tResponse     chan *TaskResponse `json:\"-\"`\n\tCreatedAt    time.Time          `json:\"created_at\"`\n\tContext      *gin.Context       `json:\"context\"`\n\tInstanceName string             `json:\"instance_name\"`\n}\n```\nRequestTask represents a queued request task\n\n```go\ntype Server struct {\n\t// contains filtered or unexported fields\n}\n```\nServer represents the API server\n\n```go\nfunc NewServer(config *ServerConfig, appConfig *config.AppConfig) *Server\n```\nNewServer creates a new API server instance\n\n```go\nfunc (s *Server) Start() error\n```\nStart starts the API server\n\n```go\nfunc (s *Server) Stop(ctx context.Context) error\n```\nStop gracefully stops the API server\n\n```go\ntype ServerConfig struct {\n\tPort   string\n\tDebug  bool\n\tPages  map[string]playwright.Page\n\tProxys map[string]*proxy.Proxy\n}\n```\nServerConfig contains configuration for the API server\n\n```go\ntype TaskProcessor interface {\n\tProcessTask(ctx context.Context, task *RequestTask) *TaskResponse\n}\n```\nTaskProcessor defines the interface for processing tasks\n\n```go\ntype TaskResponse struct {\n\tSuccess  bool        `json:\"success\"`\n\tResponse string      `json:\"response,omitempty\"`\n\tStream   chan string `json:\"-\"`\n\tError    error       `json:\"error,omitempty\"`\n\tRunner   *runner.RunnerManager\n}\n```\nTaskResponse represents the response from processing a task\n\n","path":"github.com/luispater/anyAIProxyAPI/internal/api","name":"api","synopsis":"","isRedistributable":true}
