ai

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	LANG_JP              = "ja"
	PROMPT_SYSTEM_MSG_EN = "You are a helpful security advisor. Please explain this in a way that a non-security expert can understand."
	PROMPT_SYSTEM_MSG_JP = "" /* 174-byte string literal not displayed */
	PROMPT_SUMMARY_EN    = `` /* 679-byte string literal not displayed */

	PROMPT_SUMMARY_JP = `` /* 1024-byte string literal not displayed */

	FINDING_FORMAT_FOR_AI = `` /* 136-byte string literal not displayed */

	RECOMMEND_FORMAT_FOR_AI = `
Detail: %s

Recommendation: %s
`
)
View Source
const (
	CACHE_SIZE       = 200 * 1024 * 1024 // 200MB
	CACHE_EXPIRE_SEC = 3600
	CACHE_KEY_FORMAT = "OpenAICache/%s"
)
View Source
const MAX_TOOL_USE_COUNT = 30
View Source
const (
	REPORT_PROMPT = `` /* 2528-byte string literal not displayed */

)
View Source
const TOOL_GENERATE_SQL_INSTRUCTION = `` /* 2331-byte string literal not displayed */

Variables

Functions

func ConvertSchema added in v0.16.0

func ConvertSchema[T any](output string, schema T) (*T, error)

ConvertSchema

func GetFindingDataTool added in v0.16.0

func GetFindingDataTool() responses.ToolUnionParam

GetFindingDataTool returns the get_finding_data function tool definition

Types

type AIClient

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

func (*AIClient) AskAISummaryFromFinding

func (a *AIClient) AskAISummaryFromFinding(ctx context.Context, f *model.Finding, r *model.Recommend, lang string) (string, error)

func (*AIClient) AskAISummaryStreamFromFinding added in v0.10.0

func (a *AIClient) AskAISummaryStreamFromFinding(
	ctx context.Context, f *model.Finding, r *model.Recommend, lang string, stream finding.FindingService_GetAISummaryStreamServer,
) error

func (*AIClient) ChatAI added in v0.15.0

func (a *AIClient) ChatAI(ctx context.Context, req *ai.ChatAIRequest) (*ai.ChatAIResponse, error)

func (*AIClient) GenerateReport added in v0.16.0

func (*AIClient) GetFindingDataFunction added in v0.16.0

func (a *AIClient) GetFindingDataFunction(ctx context.Context, params GetFindingDataParams) ([]map[string]any, error)

GetFindingDataFunction handles the get_finding_data function call

type AIService

type AIService interface {
	ChatAI(ctx context.Context, req *ai.ChatAIRequest) (*ai.ChatAIResponse, error)
	GenerateReport(ctx context.Context, req *ai.GenerateReportRequest) (*ai.GenerateReportResponse, error)
	AskAISummaryFromFinding(ctx context.Context, f *model.Finding, r *model.Recommend, lang string) (string, error)
	AskAISummaryStreamFromFinding(
		ctx context.Context,
		f *model.Finding,
		r *model.Recommend,
		lang string,
		stream finding.FindingService_GetAISummaryStreamServer,
	) error
}

func NewAIClient

func NewAIClient(repository db.FindingRepository, token, model, reasoningModel string, logger logging.Logger) AIService

type FunctionCallInfo added in v0.16.0

type FunctionCallInfo struct {
	Name      string
	Arguments string
	CallID    string
}

FunctionCallInfo represents a function call extracted from response

type GenerateSQLOutput added in v0.16.0

type GenerateSQLOutput struct {
	SQL string `json:"sql"`
}

type GetFindingDataParams added in v0.16.0

type GetFindingDataParams struct {
	ProjectID uint32 `json:"project_id"`
	Prompt    string `json:"prompt"`
	Limit     uint32 `json:"limit"`
	Offset    uint32 `json:"offset"`
}

GetFindingDataParams represents the parameters for get_finding_data function

type StreamSender added in v0.16.0

type StreamSender[T any] interface {
	Send(T) error
}

StreamSender is a generic interface for sending data in a stream

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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