batchai

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FIX_BEGIN      = "!!!!fix_begin!!!!"
	FIX_BEGIN_LINE = FIX_BEGIN + "\n"
	FIX_END        = "!!!!fix_end!!!!"
	FIX_END_LINE   = FIX_END
)
View Source
const (
	TEST_BEGIN      = "!!!!test_begin!!!!"
	TEST_BEGIN_LINE = TEST_BEGIN + "\n"
	TEST_END        = "!!!!test_end!!!!"
	TEST_END_LINE   = TEST_END
)
View Source
const CHECK_REPORT_JSON_FORMAT = `` /* 706-byte string literal not displayed */
View Source
const SYMBOL_JSON_FORMAT = `` /* 206-byte string literal not displayed */
View Source
const TEST_REPORT_JSON_FORMAT = `
{
  "test_file_path": "",
  "amount_of_generated_test_cases": 0,
  "single_test_run_command": ""
}`

Variables

This section is empty.

Functions

func CheckFunc added in v0.1.2

func CheckFunc(x Kontext) func(*cli.Context) error

func CheckUrfaveCommand added in v0.1.2

func CheckUrfaveCommand(x Kontext) *cli.Command

func DefaultConfigDir

func DefaultConfigDir() string

func DefaultConfigMap

func DefaultConfigMap() map[string]any

func ExtractFixedCode

func ExtractFixedCode(input string) (string, string)

func ExtractTestCode added in v0.1.2

func ExtractTestCode(input string) (string, string)

func ListFunc added in v0.1.1

func ListFunc(x Kontext) func(*cli.Context) error

func ListUrfaveCommand added in v0.1.2

func ListUrfaveCommand(x Kontext) *cli.Command

func LoadAngineerEnv

func LoadAngineerEnv(fs afero.Fs)

func ResolveCheckReportFile added in v0.1.2

func ResolveCheckReportFile(cacheDir string, repository string, file string) string

func ResolveOriginalCodeFile

func ResolveOriginalCodeFile(cacheDir string, repository string, file string) string

func ResolveSymbolFile

func ResolveSymbolFile(cacheDir string, repository string, file string) string

func ResolveTestReportFile added in v0.1.2

func ResolveTestReportFile(cacheDir string, repository string, file string) string

func TestFunc added in v0.1.2

func TestFunc(x Kontext) func(*cli.Context) error

func TestUrfaveCommand added in v0.1.2

func TestUrfaveCommand(x Kontext) *cli.Command

Types

type AppArgs

type AppArgs = *AppArgsT

func (AppArgs) WithCliContext

func (me AppArgs) WithCliContext(x Kontext, cliContext *cli.Context) error

type AppArgsT

type AppArgsT struct {
	EnableSymbolReference  bool
	Verbose                bool
	Lang                   string
	TargetPaths            []string
	Repository             string
	Force                  bool
	NumberOfFilesToProcess int
}

type AppConfig

type AppConfig = *AppConfigT

func ConfigWithYaml

func ConfigWithYaml(fs afero.Fs) AppConfig

func (AppConfig) GetExclude

func (me AppConfig) GetExclude() comm.FileMatch

func (AppConfig) GetInclude

func (me AppConfig) GetInclude() comm.FileMatch

func (AppConfig) LoadModel

func (me AppConfig) LoadModel(modelId string) ModelConfig

type AppConfigT

type AppConfigT struct {
	Includes []string      `mapstructure:"includes"`
	Excludes []string      `mapstructure:"excludes"`
	CacheDir string        `mapstructure:"cache_dir"`
	Lang     string        `mapstructure:"lang"`
	Test     TestConfig    `mapstructure:"test"`
	Check    CheckConfig   `mapstructure:"check"`
	Models   []ModelConfig `mapstructure:"models"`
	// contains filtered or unexported fields
}

type BaseAgent added in v0.1.2

type BaseAgent = *BaseAgentT

type BaseAgentT added in v0.1.2

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

type BaseMetrics added in v0.1.2

type BaseMetrics = *BaseMetricsT

func NewBaseMetrics added in v0.1.2

func NewBaseMetrics() BaseMetrics

func (BaseMetrics) PreparePrint added in v0.1.2

func (me BaseMetrics) PreparePrint(console comm.Console)

type BaseMetricsT added in v0.1.2

type BaseMetricsT struct {
	ModelUsageMetricsT

	Files     int
	Processed int
	Succeeded int
	Ignored   int
	Failed    int
	Skipped   int
}

type BaseModelCommand added in v0.1.2

type BaseModelCommand = *BaseModelCommandT

func NewBaseModelCommand added in v0.1.2

func NewBaseModelCommand(x Kontext) BaseModelCommand

type BaseModelCommandT added in v0.1.2

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

type ChatMemory

type ChatMemory = *ChatMemoryT

func NewChatMemory

func NewChatMemory() ChatMemory

func (ChatMemory) AddAssistantMessage

func (me ChatMemory) AddAssistantMessage(content string) ChatMemory

func (ChatMemory) AddSystemMessage

func (me ChatMemory) AddSystemMessage(content string) ChatMemory

func (ChatMemory) AddUserMessage

func (me ChatMemory) AddUserMessage(content string) ChatMemory

func (ChatMemory) Format

func (me ChatMemory) Format() string

func (ChatMemory) ToChatCompletionMessageParamUnion

func (me ChatMemory) ToChatCompletionMessageParamUnion() []openai.ChatCompletionMessageParamUnion

type ChatMemoryT

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

type ChatMessage

type ChatMessage = *ChatMessageT

func NewAssistantMessage

func NewAssistantMessage(content string) ChatMessage

func NewSystemMessage

func NewSystemMessage(content string) ChatMessage

func NewUserMessage

func NewUserMessage(content string) ChatMessage

func (ChatMessage) Format

func (me ChatMessage) Format() string

func (ChatMessage) ToChatCompletionMessageParamUnion

func (me ChatMessage) ToChatCompletionMessageParamUnion() openai.ChatCompletionMessageParamUnion

type ChatMessageT

type ChatMessageT struct {
	Role    string
	Content string
}

type CheckAgent added in v0.1.2

type CheckAgent = *CheckAgentT

func NewCheckAgent added in v0.1.2

func NewCheckAgent(reportManager CheckReportManager,
	codeFileManager CodeFileManager,
	symbolManager SymbolManager,
	modelService ModelService,
	codeFile string,
) CheckAgent

func (CheckAgent) Run added in v0.1.2

func (me CheckAgent) Run(x Kontext, checkArgs CheckArgs, resultChan chan<- CheckResult, wg *sync.WaitGroup)

type CheckAgentT added in v0.1.2

type CheckAgentT struct {
	SymbolAwareAgentT
	// contains filtered or unexported fields
}

type CheckArgs added in v0.1.2

type CheckArgs = *CheckArgsT

func (CheckArgs) WithCliContext added in v0.1.2

func (me CheckArgs) WithCliContext(x Kontext, cliContext *cli.Context) error

type CheckArgsT added in v0.1.2

type CheckArgsT struct {
	Fix bool
}

type CheckCommand added in v0.1.2

type CheckCommand = *CheckCommandT

func NewCheckCommand added in v0.1.2

func NewCheckCommand(x Kontext) CheckCommand

func (CheckCommand) Check added in v0.1.2

func (me CheckCommand) Check(x Kontext, checkArgs CheckArgs)

type CheckCommandT added in v0.1.2

type CheckCommandT struct {
	BaseModelCommandT
	// contains filtered or unexported fields
}

type CheckConfig added in v0.1.2

type CheckConfig = *CheckConfigT

func (CheckConfig) Init added in v0.1.2

func (me CheckConfig) Init(config AppConfig)

func (CheckConfig) RenderPrompt added in v0.1.2

func (me CheckConfig) RenderPrompt(codeToCheck string, codeFile string) string

type CheckConfigT added in v0.1.2

type CheckConfigT struct {
	AppConfig AppConfig
	ModelId   string      `mapstructure:"model_id"`
	Severity  string      `mapstructure:"severity"`
	Prompt    CheckPrompt `mapstructure:"prompt"`
}

type CheckIssue added in v0.1.2

type CheckIssue = *CheckIssueT

func (CheckIssue) Print added in v0.1.2

func (me CheckIssue) Print(console comm.Console)

type CheckIssueT added in v0.1.2

type CheckIssueT struct {
	ShortDescription     string   `json:"short_description"`
	DetailedExplaination string   `json:"detailed_explaination"`
	Suggestion           string   `json:"suggestion"`
	IssueLineBegin       int      `json:"issue_line_begin"`
	IssueLineEnd         int      `json:"issue_line_end"`
	IssueReferenceUrls   []string `json:"issue_reference_urls"`
	Severity             string   `json:"severity"`
	SeverityReason       string   `json:"severity_reason"`
}

type CheckMetrics added in v0.1.2

type CheckMetrics = *CheckMetricsT

func NewCheckMetrics added in v0.1.2

func NewCheckMetrics() CheckMetrics

func (CheckMetrics) Print added in v0.1.2

func (me CheckMetrics) Print(console comm.Console)

type CheckMetricsT added in v0.1.2

type CheckMetricsT struct {
	BaseMetricsT

	HasIssue   int
	TotalIssue int
}

type CheckPrompt added in v0.1.2

type CheckPrompt = *CheckPromptT

func (CheckPrompt) Generate added in v0.1.2

func (me CheckPrompt) Generate(vars CheckPromptVariables) string

func (CheckPrompt) Init added in v0.1.2

func (me CheckPrompt) Init(config AppConfig)

type CheckPromptT added in v0.1.2

type CheckPromptT struct {
	Rules    []string `mapstructure:"rules"`
	Template string   `mapstructure:"template"`
}

type CheckPromptVariables added in v0.1.2

type CheckPromptVariables = *CheckPromptVariablesT

func NewCheckPromptVariables added in v0.1.2

func NewCheckPromptVariables() CheckPromptVariables

func (CheckPromptVariables) WithCodeToCheck added in v0.1.2

func (me CheckPromptVariables) WithCodeToCheck(codeToCheck string) CheckPromptVariables

func (CheckPromptVariables) WithLang added in v0.1.2

func (CheckPromptVariables) WithPath added in v0.1.2

func (CheckPromptVariables) WithSeverity added in v0.1.2

func (me CheckPromptVariables) WithSeverity(severity string) CheckPromptVariables

type CheckPromptVariablesT added in v0.1.2

type CheckPromptVariablesT struct {
	Data map[string]any
}

type CheckReport added in v0.1.2

type CheckReport = *CheckReportT

func ExtractCheckReport added in v0.1.2

func ExtractCheckReport(answer string, isGolang bool) CheckReport

func (CheckReport) Print added in v0.1.2

func (me CheckReport) Print(console comm.Console, originalCode string)

type CheckReportManager added in v0.1.2

type CheckReportManager = *CheckReportManagerT

func NewCheckReportManager added in v0.1.2

func NewCheckReportManager() CheckReportManager

func (CheckReportManager) LoadReport added in v0.1.2

func (me CheckReportManager) LoadReport(x Kontext, file string) CheckReport

func (CheckReportManager) SaveReport added in v0.1.2

func (me CheckReportManager) SaveReport(x Kontext, file string, report CheckReport) string

type CheckReportManagerT added in v0.1.2

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

type CheckReportT added in v0.1.2

type CheckReportT struct {
	HasIssue          bool              `json:"has_issue"`
	OverallSeverity   string            `json:"overall_severity"`
	Issues            []CheckIssue      `json:"issues"`
	FixedCode         string            `json:"fixed_code"`
	Path              string            `json:"path"`
	ModelUsageMetrics ModelUsageMetrics `json:"model_usage_metrics"`
}

type CheckResult added in v0.1.2

type CheckResult = *CheckResultT

type CheckResultT added in v0.1.2

type CheckResultT struct {
	Report  CheckReport
	Skipped bool
	Failed  bool
}

type CodeFile

type CodeFile = *CodeFileT

func (CodeFile) IsChanged

func (me CodeFile) IsChanged() bool

type CodeFileManager

type CodeFileManager = *CodeFileManagerT

func NewCodeFileManager

func NewCodeFileManager() CodeFileManager

func (CodeFileManager) Load

func (me CodeFileManager) Load(x Kontext, file string) CodeFile

func (CodeFileManager) Save

func (me CodeFileManager) Save(x Kontext, file string, newCode string)

type CodeFileManagerT

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

type CodeFileT

type CodeFileT struct {
	Original string
	Latest   string
}

type Kontext

type Kontext = *KontextT

func NewKontext

func NewKontext(fs afero.Fs) Kontext

type KontextT

type KontextT struct {
	Context context.Context
	Fs      afero.Fs
	Args    AppArgs
	Config  AppConfig
}

type ListCommand added in v0.1.1

type ListCommand = *ListCommandT

func NewListCommand added in v0.1.1

func NewListCommand() ListCommand

func (ListCommand) CollectFiles added in v0.1.1

func (me ListCommand) CollectFiles(x Kontext, c comm.Console, dirPath string) ([]string, int, int)

func (ListCommand) CollectTargetFiles added in v0.1.1

func (me ListCommand) CollectTargetFiles(x Kontext, c comm.Console) ([]string, int, int)

func (ListCommand) CollectWorkingFiles added in v0.1.1

func (me ListCommand) CollectWorkingFiles(x Kontext, c comm.Console) ([]string, int, int, []string)

func (ListCommand) List added in v0.1.1

func (me ListCommand) List(x Kontext)

type ListCommandT added in v0.1.1

type ListCommandT struct{}

type ModelClient

type ModelClient = *ModelClientT

func NewModelClient

func NewModelClient(config ModelConfig) ModelClient

func (ModelClient) Chat

type ModelClientT

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

type ModelConfig

type ModelConfig = *ModelConfigT

func (ModelConfig) Init

func (me ModelConfig) Init(config AppConfig)

type ModelConfigT

type ModelConfigT struct {
	Id                      string        `mapstructure:"id,omitempty"`
	Name                    string        `mapstructure:"name,omitempty"`
	Temperature             float64       `mapstructure:"temperature,omitempty"`
	MaxOutputTokens         int           `mapstructure:"max_output_tokens"`
	ContextWindow           int           `mapstructure:"context_window"`
	TikTokenEnabled         bool          `mapstructure:"tik_token_enabled"`
	ApiKey                  string        `mapstructure:"api_key"`
	BaseUrl                 string        `mapstructure:"base_url"`
	Timeout                 time.Duration `mapstructure:"timeout,omitempty" default:"10s"`
	ProxyUrl                string        `mapstructure:"proxy_url,omitempty"`
	ProxyUser               string        `mapstructure:"proxy_user,omitempty"`
	ProxyPass               string        `mapstructure:"proxy_pass,omitempty"`
	ProxyInsecureSkipVerify bool          `mapstructure:"proxy_insecure_skip_verify" default:"false"`
	CheckPrompt             CheckPrompt   `mapstructure:"check_prompt"`
	TestPrompt              TestPrompt    `mapstructure:"test_prompt"`
	MaxConcurrentRequests   int           `mapstructure:"max_concurrent_requests"`
}

type ModelService

type ModelService = *ModelServiceT

func NewModelService

func NewModelService(config AppConfig) ModelService

func (ModelService) Chat

func (me ModelService) Chat(x Kontext, modelId string, memory ChatMemory) (string, ModelUsageMetrics)

func (ModelService) Decode

func (me ModelService) Decode(tokens []uint) string

func (ModelService) Encode

func (me ModelService) Encode(msg string) ([]uint, []string)

type ModelServiceT

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

type ModelUsageMetrics

type ModelUsageMetrics = *ModelUsageMetricsT

func NewModelUsageMetrics

func NewModelUsageMetrics() ModelUsageMetrics

func (ModelUsageMetrics) IncreaseUsage

func (me ModelUsageMetrics) IncreaseUsage(usage ModelUsageMetrics)

func (ModelUsageMetrics) Print

func (me ModelUsageMetrics) Print(console comm.Console, color comm.Color)

type ModelUsageMetricsT

type ModelUsageMetricsT struct {
	Duration              time.Duration
	EvaluatedPromptTokens int
	OpenAiUsage           *openai.CompletionUsage
}

type Symbol

type Symbol = *SymbolT

func (Symbol) IsSame

func (me Symbol) IsSame(that Symbol) bool

type SymbolAgent

type SymbolAgent = *SymbolAgentT

func NewSymbolAgent

func NewSymbolAgent(symbolManager SymbolManager,
	codeFileManager CodeFileManager,
	modelService ModelService,
	file string,
) SymbolAgent

func (SymbolAgent) Run

func (me SymbolAgent) Run(x Kontext, resultChan chan<- []Symbol, wg *sync.WaitGroup)

type SymbolAgentT

type SymbolAgentT struct {
	BaseAgentT
	// contains filtered or unexported fields
}

type SymbolAwareAgent added in v0.1.2

type SymbolAwareAgent = *SymbolAwareAgentT

type SymbolAwareAgentT added in v0.1.2

type SymbolAwareAgentT struct {
	BaseAgentT
	// contains filtered or unexported fields
}

type SymbolManager

type SymbolManager = *SymbolManagerT

func NewSymbolManager

func NewSymbolManager() SymbolManager

func (SymbolManager) Load

func (me SymbolManager) Load(x Kontext, file string) []Symbol

func (SymbolManager) LoadAll

func (me SymbolManager) LoadAll(x Kontext, files []string)

func (SymbolManager) Lookup

func (me SymbolManager) Lookup(x Kontext, symbolNames []string, excludedFile string) []Symbol

func (SymbolManager) Save

func (me SymbolManager) Save(x Kontext, file string, symbols []Symbol)

type SymbolManagerT

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

type SymbolT

type SymbolT struct {
	Name  string `json:"name"`
	Path  string `json:"path"`
	Lines string `json:"lines"`
}

type TestAgent added in v0.1.2

type TestAgent = *TestAgentT

func NewTestAgent added in v0.1.2

func NewTestAgent(reportManager TestReportManager,
	codeFileManager CodeFileManager,
	symbolManager SymbolManager,
	modelService ModelService,
	codeFile string,
) TestAgent

func (TestAgent) Run added in v0.1.2

func (me TestAgent) Run(x Kontext, testArgs TestArgs, resultChan chan<- TestResult, wg *sync.WaitGroup)

type TestAgentT added in v0.1.2

type TestAgentT struct {
	SymbolAwareAgentT
	// contains filtered or unexported fields
}

type TestArgs added in v0.1.2

type TestArgs = *TestArgsT

func (TestArgs) WithCliContext added in v0.1.2

func (me TestArgs) WithCliContext(x Kontext, cliContext *cli.Context) error

type TestArgsT added in v0.1.2

type TestArgsT struct {
	Libraries []string
	Update    bool
}

type TestCommand added in v0.1.2

type TestCommand = *TestCommandT

func NewTestCommand added in v0.1.2

func NewTestCommand(x Kontext) TestCommand

func (TestCommand) Test added in v0.1.2

func (me TestCommand) Test(x Kontext, testArgs TestArgs)

type TestCommandT added in v0.1.2

type TestCommandT struct {
	BaseModelCommandT
	// contains filtered or unexported fields
}

type TestConfig added in v0.1.2

type TestConfig = *TestConfigT

func (TestConfig) Init added in v0.1.2

func (me TestConfig) Init(config AppConfig)

func (TestConfig) RenderPrompt added in v0.1.2

func (me TestConfig) RenderPrompt(libraries []string, codeToTest string, codeFile string, exstingTestCode string) string

type TestConfigT added in v0.1.2

type TestConfigT struct {
	AppConfig AppConfig
	ModelId   string     `mapstructure:"model_id"`
	Prompt    TestPrompt `mapstructure:"prompt"`
}

type TestMetrics added in v0.1.2

type TestMetrics = *TestMetricsT

func NewTestMetrics added in v0.1.2

func NewTestMetrics() TestMetrics

func (TestMetrics) Print added in v0.1.2

func (me TestMetrics) Print(console comm.Console)

type TestMetricsT added in v0.1.2

type TestMetricsT struct {
	BaseMetricsT

	TotalTestCases int
}

type TestPrompt added in v0.1.2

type TestPrompt = *TestPromptT

func (TestPrompt) Generate added in v0.1.2

func (me TestPrompt) Generate(vars TestPromptVariables) string

func (TestPrompt) Init added in v0.1.2

func (me TestPrompt) Init(config AppConfig)

type TestPromptT added in v0.1.2

type TestPromptT struct {
	Rules    []string `mapstructure:"rules"`
	Template string   `mapstructure:"template"`
}

type TestPromptVariables added in v0.1.2

type TestPromptVariables = *TestPromptVariablesT

func NewTestPromptVariables added in v0.1.2

func NewTestPromptVariables() TestPromptVariables

func (TestPromptVariables) WithCodeToTest added in v0.1.2

func (me TestPromptVariables) WithCodeToTest(codeToTest string) TestPromptVariables

func (TestPromptVariables) WithExistingTestCode added in v0.1.2

func (me TestPromptVariables) WithExistingTestCode(existingTestCode string) TestPromptVariables

func (TestPromptVariables) WithLang added in v0.1.2

func (TestPromptVariables) WithLibraries added in v0.1.2

func (me TestPromptVariables) WithLibraries(libraries []string) TestPromptVariables

func (TestPromptVariables) WithPath added in v0.1.2

type TestPromptVariablesT added in v0.1.2

type TestPromptVariablesT struct {
	Data map[string]any
}

type TestReport added in v0.1.2

type TestReport = *TestReportT

func ExtractTestReport added in v0.1.2

func ExtractTestReport(answer string, isGolang bool) TestReport

func (TestReport) Print added in v0.1.2

func (me TestReport) Print(console comm.Console)

type TestReportManager added in v0.1.2

type TestReportManager = *TestReportManagerT

func NewTestReportManager added in v0.1.2

func NewTestReportManager() TestReportManager

func (TestReportManager) LoadReport added in v0.1.2

func (me TestReportManager) LoadReport(x Kontext, file string) TestReport

func (TestReportManager) SaveReport added in v0.1.2

func (me TestReportManager) SaveReport(x Kontext, file string, report TestReport) string

type TestReportManagerT added in v0.1.2

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

type TestReportT added in v0.1.2

type TestReportT struct {
	Path              string `json:"path"`
	ModelUsageMetrics ModelUsageMetrics

	TestFilePath               string `json:"test_file_path"`
	TestCode                   string `json:"test_code"`
	AmountOfGeneratedTestCases int    `json:"amount_of_generated_test_cases"`
	SingleTestRunCommand       string `json:"single_test_run_command"`
}

type TestResult added in v0.1.2

type TestResult = *TestResultT

type TestResultT added in v0.1.2

type TestResultT struct {
	Skipped bool
	Failed  bool
	Report  TestReport
}

Jump to

Keyboard shortcuts

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