diff --git a/gitea/client.go b/gitea/client.go index 575b5bd..12a370c 100644 --- a/gitea/client.go +++ b/gitea/client.go @@ -9,9 +9,11 @@ import ( "log" "net/http" "strings" + "time" ) // Client interacts with the Gitea API. +// A Client is safe for concurrent use by multiple goroutines. type Client struct { baseURL string token string @@ -23,7 +25,7 @@ func NewClient(baseURL, token string) *Client { return &Client{ baseURL: strings.TrimRight(baseURL, "/"), token: token, - http: &http.Client{}, + http: &http.Client{Timeout: 30 * time.Second}, } } @@ -226,7 +228,7 @@ func (c *Client) GetAllFilesInPath(ctx context.Context, owner, repo, path string content, err := c.GetFileContent(ctx, owner, repo, entry.Path) if err != nil { log.Printf("Warning: could not fetch file %s: %v", entry.Path, err) - continue + continue } results[entry.Path] = content case "dir": diff --git a/integration_test.go b/integration_test.go index d0b9055..d3ccce2 100644 --- a/integration_test.go +++ b/integration_test.go @@ -74,8 +74,8 @@ func TestIntegration_FullReviewFlow(t *testing.T) { t.Logf("Diff size: %d bytes", len(diff)) // Step 3: Build prompts - systemPrompt := review.BuildSystemPrompt("") - userPrompt := review.BuildUserPrompt(pr.Title, pr.Body, diff, true, "") + systemPrompt := review.BuildSystemPrompt("", "") + userPrompt := review.BuildUserPrompt(pr.Title, pr.Body, diff, "", true, "") // Step 4: Call LLM llmClient := llm.NewClient(llmBaseURL, llmAPIKey, llmModel) diff --git a/llm/client.go b/llm/client.go index 9117a3d..af7f313 100644 --- a/llm/client.go +++ b/llm/client.go @@ -8,9 +8,11 @@ import ( "io" "net/http" "strings" + "time" ) // Client calls an OpenAI-compatible chat completion API. +// A Client is safe for concurrent use by multiple goroutines after construction. type Client struct { baseURL string apiKey string @@ -25,7 +27,7 @@ func NewClient(baseURL, apiKey, model string) *Client { baseURL: strings.TrimRight(baseURL, "/"), apiKey: apiKey, model: model, - http: &http.Client{}, + http: &http.Client{Timeout: 2 * time.Minute}, } }