llm

package
v0.0.0-...-d928f88 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 14 Imported by: 0 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

This section is empty.

Variables

This section is empty.

Functions

func BuildPRReviewPrompt

func BuildPRReviewPrompt(payload *queue.PRReviewTaskPayload, files []*github.CommitFile) string

Types

type AIClient

type AIClient interface {
	GenerateReviewForPR(ctx context.Context, prompt string) (string, error)
	GenerateSampleReviewForPR() (string, error)
}

AIClient is the main interface for AI-powered code review (OpenAI, REST LLM, etc.)

func NewClient

func NewClient(cfg *config.Config) (AIClient, error)

NewClient returns an AIClient based on configuration (OpenAI, REST LLM, etc.)

type FileGroup

type FileGroup struct {
	Path     string        `json:"path"`
	Comments []LineComment `json:"comments"`
}

type LLMClient

type LLMClient interface {
	// AnalyzeCode takes code and returns a review or suggestions.
	AnalyzeCode(code string) (string, error)
}

LLMClient defines the interface for interacting with an LLM service (e.g., HuggingFace, Ollama, etc.)

type LineComment

type LineComment struct {
	Line     LineRange `json:"line"`
	Body     string    `json:"body"`
	Category []string  `json:"category,omitempty"`
}

type LineRange

type LineRange struct {
	S int `json:"s"` // start line
	E int `json:"e"` // end line
}

type OpenAIClient

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

func NewOpenAIClient

func NewOpenAIClient(cfg *config.Config) *OpenAIClient

NewOpenAIClient initializes the singleton instance

func (*OpenAIClient) GenerateReviewForPR

func (c *OpenAIClient) GenerateReviewForPR(ctx context.Context, prompt string) (string, error)

func (*OpenAIClient) GenerateSampleReviewForPR

func (c *OpenAIClient) GenerateSampleReviewForPR() (string, error)

use this for development(no need to call AI API to get review json)

type PRReviewResponse

type PRReviewResponse struct {
	Summary  string      `json:"summary,omitempty"`
	Action   string      `json:"action"` // COMMENT, APPROVE, REQUEST_CHANGES
	Comments []FileGroup `json:"comments"`
}

func ParseReviewResponse

func ParseReviewResponse(jsonStr string) (*PRReviewResponse, error)

type RESTLLMClient

type RESTLLMClient struct {
	Endpoint  string
	AuthToken string // Optional: for HuggingFace, etc.
}

RESTLLMClient is a client that calls an external LLM REST API (Python, HuggingFace, Ollama, etc.)

func (*RESTLLMClient) AnalyzeCode

func (c *RESTLLMClient) AnalyzeCode(code string) (string, error)

AnalyzeCode sends code to the LLM REST API and returns the response.

func (*RESTLLMClient) GenerateReviewForPR

func (c *RESTLLMClient) GenerateReviewForPR(ctx context.Context, prompt string) (string, error)

Example usage of LLM integration in Go

func ExampleLLMUsage() {
    // Configure your LLM endpoint (e.g., HuggingFace Inference API, Ollama, etc.)
    llmClient := &RESTLLMClient{Endpoint: "http://localhost:11434/api/generate"}
    code := "func add(a int, b int) int { return a + b }"
    result, err := llmClient.AnalyzeCode(code)
    if err != nil {
        fmt.Println("LLM error:", err)
        return
    }
    fmt.Println("LLM review result:", result)
}

Ensure RESTLLMClient implements AIClient for code review integration

func (*RESTLLMClient) GenerateSampleReviewForPR

func (c *RESTLLMClient) GenerateSampleReviewForPR() (string, error)

type SonarQubeClient

type SonarQubeClient struct {
	Endpoint string
	Token    string
}

--- SonarQube Integration (Static Analysis) --- See: server/go-static-analyzers-research.md for research and recommendations.

SonarQubeClient connects to a real SonarQube server via REST API.

func (*SonarQubeClient) AnalyzeCode

func (c *SonarQubeClient) AnalyzeCode(projectKey string) (string, error)

AnalyzeCode triggers SonarQube analysis and fetches results.

func (*SonarQubeClient) GenerateReviewForPR

func (c *SonarQubeClient) GenerateReviewForPR(ctx context.Context, prompt string) (string, error)

Ensure SonarQubeClient implements AIClient for code review integration

func (*SonarQubeClient) GenerateSampleReviewForPR

func (c *SonarQubeClient) GenerateSampleReviewForPR() (string, error)

Jump to

Keyboard shortcuts

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