fix: address all review findings on PR #14
- gitea.Client: add concurrency safety doc comment - gitea.Client: set 30s HTTP client timeout as safety net - llm.Client: add concurrency safety doc comment - llm.Client: set 2min HTTP client timeout (LLM calls are slow) - gitea/client.go: gofmt to fix indentation - integration_test: update to current BuildSystemPrompt/BuildUserPrompt signatures - integration_test: use strings.SplitN for owner/repo parsing
This commit is contained in:
+4
-2
@@ -9,9 +9,11 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client interacts with the Gitea API.
|
// Client interacts with the Gitea API.
|
||||||
|
// A Client is safe for concurrent use by multiple goroutines.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
baseURL string
|
baseURL string
|
||||||
token string
|
token string
|
||||||
@@ -23,7 +25,7 @@ func NewClient(baseURL, token string) *Client {
|
|||||||
return &Client{
|
return &Client{
|
||||||
baseURL: strings.TrimRight(baseURL, "/"),
|
baseURL: strings.TrimRight(baseURL, "/"),
|
||||||
token: token,
|
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)
|
content, err := c.GetFileContent(ctx, owner, repo, entry.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Warning: could not fetch file %s: %v", entry.Path, err)
|
log.Printf("Warning: could not fetch file %s: %v", entry.Path, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
results[entry.Path] = content
|
results[entry.Path] = content
|
||||||
case "dir":
|
case "dir":
|
||||||
|
|||||||
+2
-2
@@ -74,8 +74,8 @@ func TestIntegration_FullReviewFlow(t *testing.T) {
|
|||||||
t.Logf("Diff size: %d bytes", len(diff))
|
t.Logf("Diff size: %d bytes", len(diff))
|
||||||
|
|
||||||
// Step 3: Build prompts
|
// Step 3: Build prompts
|
||||||
systemPrompt := review.BuildSystemPrompt("")
|
systemPrompt := review.BuildSystemPrompt("", "")
|
||||||
userPrompt := review.BuildUserPrompt(pr.Title, pr.Body, diff, true, "")
|
userPrompt := review.BuildUserPrompt(pr.Title, pr.Body, diff, "", true, "")
|
||||||
|
|
||||||
// Step 4: Call LLM
|
// Step 4: Call LLM
|
||||||
llmClient := llm.NewClient(llmBaseURL, llmAPIKey, llmModel)
|
llmClient := llm.NewClient(llmBaseURL, llmAPIKey, llmModel)
|
||||||
|
|||||||
+3
-1
@@ -8,9 +8,11 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client calls an OpenAI-compatible chat completion API.
|
// Client calls an OpenAI-compatible chat completion API.
|
||||||
|
// A Client is safe for concurrent use by multiple goroutines after construction.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
baseURL string
|
baseURL string
|
||||||
apiKey string
|
apiKey string
|
||||||
@@ -25,7 +27,7 @@ func NewClient(baseURL, apiKey, model string) *Client {
|
|||||||
baseURL: strings.TrimRight(baseURL, "/"),
|
baseURL: strings.TrimRight(baseURL, "/"),
|
||||||
apiKey: apiKey,
|
apiKey: apiKey,
|
||||||
model: model,
|
model: model,
|
||||||
http: &http.Client{},
|
http: &http.Client{Timeout: 2 * time.Minute},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user