Documentation ¶
Overview ¶
package clients provides the clients for the external services used by the application.
Index ¶
- Constants
- func IsDoNotEditFile(data []byte) bool
- func ModelToContextWindow(model ModelType) int
- func Shuffle(slice interface{})
- type APIType
- type CodeFilter
- type GithubClient
- func (gc *GithubClient) AddCommentToPullRequestReview(ctx context.Context, owner, repo string, prNumber int, ...) (*github.PullRequestComment, error)
- func (gc *GithubClient) AddCommitToBranch(ctx context.Context, owner, repo, branch, filePath, commitMessage string, ...) error
- func (gc *GithubClient) CreateBranch(ctx context.Context, owner, repo, newBranch, baseBranch string) error
- func (gc *GithubClient) CreatePullRequest(ctx context.Context, owner, repo, title, head, base, body string) (*github.PullRequest, error)
- func (gc *GithubClient) GetCommitCode(context context.Context, owner, repo, commitSHA string, codeFilter CodeFilter) (map[string]string, error)
- func (gc *GithubClient) GetLatestCommitFromBranch(ctx context.Context, owner, repo, branch string) (string, error)
- func (gc *GithubClient) GetPRCode(ctx context.Context, owner, repo string, prNumber int, ...) (map[string]string, error)
- func (gc *GithubClient) GetPRDiff(ctx context.Context, owner, repo string, prNumber int) (string, error)
- func (gc *GithubClient) GetPRPatch(ctx context.Context, owner, repo string, prNumber int) (string, error)
- func (gc *GithubClient) ListPullRequests(ctx context.Context, owner, repo string, opts *github.PullRequestListOptions) ([]*github.PullRequest, error)
- func (gc *GithubClient) MergePullRequest(ctx context.Context, owner, repo string, prNumber int, commitMessage string) (*github.PullRequestMergeResult, error)
- type ModelType
- type OllamaClient
- type OpenAIClient
- type Side
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func IsDoNotEditFile ¶
IsDoNotEditFile checks if the file has a DO NOT EDIT comment.
func ModelToContextWindow ¶
ModelToContextWindow returns the context window size for the given model.
Types ¶
type CodeFilter ¶
type CodeFilter struct {
FileRegexPattern string
}
CodeFilter is used to filter files based on a regex pattern.
type GithubClient ¶
type GithubClient struct {
// contains filtered or unexported fields
}
func NewGithubClient ¶
func NewGithubClient(token string, logger zerolog.Logger) *GithubClient
NewGithubClient creates a new instance of the GithubClient.
func (*GithubClient) AddCommentToPullRequestReview ¶
func (gc *GithubClient) AddCommentToPullRequestReview(ctx context.Context, owner, repo string, prNumber int, commentBody, commitID, path string, startLine, line int, startSide, side Side) (*github.PullRequestComment, error)
AddCommentToPullRequestReview adds a comment to a pull request review.
Parameters:
- ctx: The context for the API request.
- owner: The owner of the repository.
- repo: The repository name.
- prNumber: The pull request number.
- commentBody: The content of the comment to be added.
- commitID: The SHA of the commit to comment on.
- path: The file path in the repository where the comment should be added.
- position: The position in the diff where the comment should be added.
Returns:
- The created PullRequestComment object.
- An error if any occurred during the API request.
func (*GithubClient) AddCommitToBranch ¶
func (gc *GithubClient) AddCommitToBranch(ctx context.Context, owner, repo, branch, filePath, commitMessage string, fileContent []byte) error
AddCommitToBranch adds a commit to the specified branch.
func (*GithubClient) CreateBranch ¶
func (gc *GithubClient) CreateBranch(ctx context.Context, owner, repo, newBranch, baseBranch string) error
CreateBranch creates a new branch from the specified base branch.
func (*GithubClient) CreatePullRequest ¶
func (gc *GithubClient) CreatePullRequest(ctx context.Context, owner, repo, title, head, base, body string) (*github.PullRequest, error)
CreatePullRequest creates a new pull request.
func (*GithubClient) GetCommitCode ¶
func (gc *GithubClient) GetCommitCode(context context.Context, owner, repo, commitSHA string, codeFilter CodeFilter) (map[string]string, error)
GetCommitCode gets the code from a commit.
func (*GithubClient) GetLatestCommitFromBranch ¶
func (gc *GithubClient) GetLatestCommitFromBranch(ctx context.Context, owner, repo, branch string) (string, error)
GetLatestCommitFromBranch gets the latest commit SHA from a branch.
func (*GithubClient) GetPRCode ¶
func (gc *GithubClient) GetPRCode(ctx context.Context, owner, repo string, prNumber int, opts *github.ListOptions, codeFilter CodeFilter) (map[string]string, error)
GetPRCode gets the code from a pull request.
func (*GithubClient) GetPRPatch ¶
func (*GithubClient) ListPullRequests ¶
func (gc *GithubClient) ListPullRequests(ctx context.Context, owner, repo string, opts *github.PullRequestListOptions) ([]*github.PullRequest, error)
ListPullRequests lists all pull requests in a repository.
func (*GithubClient) MergePullRequest ¶
func (gc *GithubClient) MergePullRequest(ctx context.Context, owner, repo string, prNumber int, commitMessage string) (*github.PullRequestMergeResult, error)
MergePullRequest merges a pull request.
type OllamaClient ¶ added in v0.2.0
type OllamaClient struct {
// contains filtered or unexported fields
}
func NewOllamaClient ¶ added in v0.2.0
func NewOllamaClient(cfg openai.ClientConfig) *OllamaClient
func (*OllamaClient) CreateChatCompletion ¶ added in v0.2.0
func (c *OllamaClient) CreateChatCompletion(ctx context.Context, request openai.ChatCompletionRequest) (response openai.ChatCompletionResponse, err error)
curl http://localhost:11434/api/chat -d '{ "model": "llama3.2", "messages": [ { "role": "user", "content": "why is the sky blue?" } ] }'
type OpenAIClient ¶
type OpenAIClient struct {
// contains filtered or unexported fields
}
func NewCustomOpenAIClient ¶
func NewCustomOpenAIClient(authToken, baseURL string, apiType APIType) *OpenAIClient
func NewOpenAIClient ¶
func NewOpenAIClient(apiKey string) *OpenAIClient
NewOpenAIClient creates a new instance of the OpenAIClient.
func (*OpenAIClient) GenerateChatCompletion ¶
func (oc *OpenAIClient) GenerateChatCompletion(ctx context.Context, messages []openai.ChatCompletionMessage, model ModelType) (string, error)
GenerateChatCompletion generates a chat completion based on the provided messages.
Parameters:
- ctx: The context for the API request.
- messages: The list of messages to use as input for the chat completion.
Returns:
- The generated chat completion.
- An error if any occurred during the API request.