client

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents an LLM client

func New

func New(config *types.ClientConfig) *Client

New creates a new client with the given config

func (*Client) Chat

func (c *Client) Chat(ctx context.Context, message string, history []types.Message) (*types.CompletionResponse, error)

Chat sends a chat message to the LLM provider with retry logic

func (*Client) GenerateCommitMessage

func (c *Client) GenerateCommitMessage(diff string, prompt string) (string, error)

GenerateCommitMessage generates a commit message for the given diff

func (*Client) GenerateReviewComment added in v0.3.0

func (c *Client) GenerateReviewComment(diff string, prompt string) (string, error)

GenerateReviewComment generates a review comment for the given diff

func (*Client) GenerateReviewCommentStream added in v0.3.0

func (c *Client) GenerateReviewCommentStream(diff string, prompt string, callback func(string) error) error

GenerateReviewCommentStream generates a review comment for the given diff

func (*Client) Stream added in v0.3.0

func (c *Client) Stream(ctx context.Context, message string, callback func(*types.CompletionResponse) error) error

Stream sends a streaming request to the LLM provider and processes the response using the provided callback function.

Parameters:

  • ctx: the context for the request, used for cancellation and timeouts
  • message: the message to send to the LLM provider
  • history: the message history to include in the request
  • callback: a function that processes the CompletionResponse received from the LLM provider

Returns an error if the client cannot be obtained, the request fails, or the callback function returns an error.

func (*Client) TranslateMessage

func (c *Client) TranslateMessage(prompt string, message string, lang string) (string, error)

TranslateMessage translates the given message to the specified language

type ClientInterface added in v0.2.3

type ClientInterface interface {
	Chat(ctx context.Context, message string, history []types.Message) (*types.CompletionResponse, error)
	TranslateMessage(prompt string, message string, lang string) (string, error)
	GenerateCommitMessage(diff string, prompt string) (string, error)
	GenerateReviewComment(diff string, prompt string) (string, error)
	GenerateReviewCommentStream(diff string, prompt string, callback func(string) error) error
}

Jump to

Keyboard shortcuts

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