assistant

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJobQueueFull   = fmt.Errorf("job queue is full")
	ErrJobQueueClosed = fmt.Errorf("job queue is closed")
)
View Source
var ErrnoAssistantMarker = fmt.Errorf("\n%s%s\n\n",
	`No Go code requiring AI assistant generation was detected. To trigger the AI assistant, ensure the following conditions are met:
    1. Define a function in Go code.
    2. Add detailed function comments (used as AI prompts).
    3. Add panic("implement me") inside the function body.

Example:`, fmt.Sprintf(`

    %s
    func MyFuncName() {
        %s
    }`, color.HiCyanString("// Describe the specific functionality of the function"), color.HiCyanString(`panic("implement me")`)))

nolint

Functions

func ChatCommand added in v1.13.0

func ChatCommand() *cobra.Command

ChatCommand chat with AI Assistant

func CleanUpAssistantCode added in v1.13.0

func CleanUpAssistantCode() *cobra.Command

CleanUpAssistantCode clean up all assistant generated code

func GenerateCommand

func GenerateCommand() *cobra.Command

GenerateCommand command

func MergeAssistantCode added in v1.13.0

func MergeAssistantCode() *cobra.Command

MergeAssistantCode merge AI assistant generated code into source Go file

Types

type Job added in v1.13.0

type Job struct {
	ID   int
	Task Task
}

Job represents a task

type Reply added in v1.13.0

type Reply struct {
	JobID     int      `json:"jobID"`
	ErrMsg    string   `json:"errMsg"`
	SrcFile   string   `json:"srcFile"`
	Functions []string `json:"functions"`
	Prompt    string   `json:"prompt"`

	Contents map[string]string `json:"contents"` // reply contents
}

Reply execute assistant task result

type Result added in v1.13.0

type Result struct {
	JobID     int
	Value     interface{}
	Err       error
	StartTime time.Time
	EndTime   time.Time
}

Result represents the execution result of a task

type Task added in v1.13.0

type Task interface {
	Execute(ctx context.Context) (interface{}, error)
}

Task is interface for Job

type WorkerPool added in v1.13.0

type WorkerPool struct {
	// contains filtered or unexported fields
}

WorkerPool represents a worker pool

func NewWorkerPool added in v1.13.0

func NewWorkerPool(ctx context.Context, workerSize int, jobQueueSize int) (*WorkerPool, error)

NewWorkerPool creates a new worker pool

func (*WorkerPool) Results added in v1.13.0

func (wp *WorkerPool) Results() <-chan Result

Results returns the result channel

func (*WorkerPool) Start added in v1.13.0

func (wp *WorkerPool) Start()

Start starts the worker pool

func (*WorkerPool) Stop added in v1.13.0

func (wp *WorkerPool) Stop()

Stop stops the worker pool

func (*WorkerPool) Submit added in v1.13.0

func (wp *WorkerPool) Submit(job Job, timeout time.Duration) error

Submit submits a task to the worker pool

func (*WorkerPool) Wait added in v1.13.0

func (wp *WorkerPool) Wait()

Wait waits for all workers to complete and closes the result channel

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL