Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIHandlers ¶
type APIHandlers struct {
// contains filtered or unexported fields
}
APIHandlers contains the handlers for API endpoints
func NewAPIHandlers ¶
func NewAPIHandlers(appConfig *config.AppConfig, queue *RequestQueue, pages map[string]playwright.Page, debug bool) *APIHandlers
NewAPIHandlers creates a new API handlers instance
func (*APIHandlers) ChatCompletions ¶
func (h *APIHandlers) ChatCompletions(c *gin.Context)
ChatCompletions handles the /v1/chat/completions endpoint
type ChatProcessor ¶
type ChatProcessor struct {
// contains filtered or unexported fields
}
ChatProcessor implements TaskProcessor interface
func NewChatProcessor ¶
func NewChatProcessor(appConfig *config.AppConfig, pages map[string]playwright.Page, proxies map[string]*proxy.Proxy, debug bool) *ChatProcessor
NewChatProcessor creates a new chat processor
func (*ChatProcessor) ProcessTask ¶
func (cp *ChatProcessor) ProcessTask(ctx context.Context, task *RequestTask) *TaskResponse
ProcessTask processes a chat completion task
type ErrorDetail ¶
type ErrorDetail struct {
Message string `json:"message"`
Type string `json:"type"`
Code string `json:"code,omitempty"`
}
ErrorDetail represents error details
type ErrorResponse ¶
type ErrorResponse struct {
Error ErrorDetail `json:"error"`
}
ErrorResponse represents an error response
type RequestQueue ¶
type RequestQueue struct {
// contains filtered or unexported fields
}
RequestQueue manages the sequential processing of chat completion requests
func NewRequestQueue ¶
func NewRequestQueue(processor TaskProcessor) *RequestQueue
NewRequestQueue creates a new request queue
func (*RequestQueue) AddTask ¶
func (q *RequestQueue) AddTask(task *RequestTask) error
AddTask adds a new task to the queue
func (*RequestQueue) GetQueueLength ¶
func (q *RequestQueue) GetQueueLength() int
GetQueueLength returns the current number of tasks in the queue
func (*RequestQueue) IsRunning ¶
func (q *RequestQueue) IsRunning() bool
IsRunning returns whether the queue is currently running
func (*RequestQueue) Start ¶
func (q *RequestQueue) Start() error
Start begins processing requests from the queue
func (*RequestQueue) Stop ¶
func (q *RequestQueue) Stop() error
Stop stops the request queue and waits for current task to complete
type RequestTask ¶
type RequestTask struct {
ID string `json:"id"`
Request string `json:"request"`
Response chan *TaskResponse `json:"-"`
CreatedAt time.Time `json:"created_at"`
Context *gin.Context `json:"context"`
InstanceName string `json:"instance_name"`
}
RequestTask represents a queued request task
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the API server
type ServerConfig ¶
type ServerConfig struct {
Port string
Debug bool
Pages map[string]playwright.Page
Proxys map[string]*proxy.Proxy
}
ServerConfig contains configuration for the API server
type TaskProcessor ¶
type TaskProcessor interface {
ProcessTask(ctx context.Context, task *RequestTask) *TaskResponse
}
TaskProcessor defines the interface for processing tasks
type TaskResponse ¶
type TaskResponse struct {
Success bool `json:"success"`
Response string `json:"response,omitempty"`
Stream chan string `json:"-"`
Error error `json:"error,omitempty"`
Runner *runner.RunnerManager
}
TaskResponse represents the response from processing a task