chat

package
v0.0.0-...-78730a9 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

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

Chat handles interactions with LLM APIs (OpenAI, Azure OpenAI, Volc Deepseek V3)

func NewChat

func NewChat(cfg *config.Config) (*Chat, error)

NewChat creates a new Chat instance

func (*Chat) CodeReview

func (c *Chat) CodeReview(ctx context.Context, patch string) (ReviewResult, error)

CodeReview performs a code review on the given patch

type DirectLLMMessage

type DirectLLMMessage = LLMMessage

type DirectLLMRequest

type DirectLLMRequest = LLMRequest

为兼容性保留的类型别名

type DirectLLMResponse

type DirectLLMResponse = LLMResponse

type DirectLLMResponseFormat

type DirectLLMResponseFormat = LLMResponseFormat

type LLMMessage

type LLMMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

LLMMessage 表示 LLM API 的消息

type LLMRequest

type LLMRequest struct {
	Model          string             `json:"model"`
	Messages       []LLMMessage       `json:"messages"`
	Temperature    float32            `json:"temperature,omitempty"`
	TopP           float32            `json:"top_p,omitempty"`
	MaxTokens      int                `json:"max_tokens,omitempty"`
	ResponseFormat *LLMResponseFormat `json:"response_format,omitempty"`
}

LLMRequest 表示发送到 LLM API 的通用请求

type LLMResponse

type LLMResponse struct {
	ID      string `json:"id"`
	Object  string `json:"object"`
	Created int64  `json:"created"`
	Model   string `json:"model"`
	Choices []struct {
		Message struct {
			Role    string `json:"role"`
			Content string `json:"content"`
		} `json:"message"`
		FinishReason string `json:"finish_reason"`
	} `json:"choices"`
	Usage struct {
		PromptTokens     int `json:"prompt_tokens"`
		CompletionTokens int `json:"completion_tokens"`
		TotalTokens      int `json:"total_tokens"`
	} `json:"usage"`
}

LLMResponse 表示从 LLM API 接收的通用响应

type LLMResponseFormat

type LLMResponseFormat struct {
	Type string `json:"type"`
}

LLMResponseFormat 表示 LLM API 的响应格式

type ReviewResult

type ReviewResult struct {
	LGTM          bool   `json:"lgtm"`
	ReviewComment string `json:"review_comment"`
	Summary       string `json:"summary"`     // 代码变更的总结
	Suggestions   string `json:"suggestions"` // 改进建议
	Highlights    string `json:"highlights"`  // 代码亮点
	Risks         string `json:"risks"`       // 潜在风险
}

ReviewResult represents the result of a code review

Jump to

Keyboard shortcuts

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