Skip to content

Commit

Permalink
some logging cleanup, as well as additional logging around streamed t…
Browse files Browse the repository at this point in the history
…oken limit for retries in builds
  • Loading branch information
danenania committed Apr 1, 2024
1 parent 84c87e0 commit 45236b3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/cli/api/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@ func (a *Api) UpdateSettings(planId, branch string, req shared.UpdateSettingsReq
return nil, &shared.ApiError{Type: shared.ApiErrorTypeOther, Msg: fmt.Sprintf("error marshalling request: %s", err)}
}

log.Println("UpdateSettings", string(reqBytes))
// log.Println("UpdateSettings", string(reqBytes))

request, err := http.NewRequest(http.MethodPut, serverUrl, bytes.NewBuffer(reqBytes))
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions app/server/db/org_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"log"
"strings"

"github.com/davecgh/go-spew/spew"
"github.com/lib/pq"
"github.com/plandex/plandex/shared"
)
Expand Down Expand Up @@ -50,7 +49,7 @@ func GetAccessibleOrgsForUser(user *User) ([]*Org, error) {
orgIds = append(orgIds, invite.OrgId)
}

log.Println(spew.Sdump(orgIds))
// log.Println(spew.Sdump(orgIds))

if len(orgIds) > 0 {
var orgsFromInvites []*Org
Expand Down
7 changes: 3 additions & 4 deletions app/server/model/plan/build_result.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package plan

import (
"log"
"plandex-server/db"
"sort"
"strings"
Expand Down Expand Up @@ -48,8 +47,8 @@ func getPlanResult(params planResultParams) (*db.PlanFileResult, bool) {

new := streamedChange.New

log.Printf("getPlanResult - streamedChange.Old.StartLine: %d\n", streamedChange.Old.StartLine)
log.Printf("getPlanResult - streamedChange.Old.EndLine: %d\n", streamedChange.Old.EndLine)
// log.Printf("getPlanResult - streamedChange.Old.StartLine: %d\n", streamedChange.Old.StartLine)
// log.Printf("getPlanResult - streamedChange.Old.EndLine: %d\n", streamedChange.Old.EndLine)

startLine := streamedChange.Old.StartLine
endLine := streamedChange.Old.EndLine
Expand All @@ -74,7 +73,7 @@ func getPlanResult(params planResultParams) (*db.PlanFileResult, bool) {
old = strings.Join(currentStateLines[startLine-1:endLine], "\n")
}

log.Printf("getPlanResult - old: %s\n", old)
// log.Printf("getPlanResult - old: %s\n", old)

replacement := &shared.Replacement{
Old: old,
Expand Down
8 changes: 8 additions & 0 deletions app/server/model/plan/build_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ func (fileState *activeBuildStreamFileState) listenStream(stream *openai.ChatCom

// After a reasonable threshhold, if buffer has significantly more tokens than original file + proposed changes, something is wrong
if fileState.activeBuild.BufferTokens > 500 && fileState.activeBuild.BufferTokens > int(float64(fileState.activeBuild.CurrentFileTokens+fileState.activeBuild.FileContentTokens)*1.5) {
log.Printf("File %s: Stream buffer tokens too high\n", filePath)
log.Printf("Current file tokens: %d\n", fileState.activeBuild.CurrentFileTokens)
log.Printf("File content tokens: %d\n", fileState.activeBuild.FileContentTokens)
log.Printf("Cutoff: %d\n", int(float64(fileState.activeBuild.CurrentFileTokens+fileState.activeBuild.FileContentTokens)*1.5))
log.Printf("Buffer tokens: %d\n", fileState.activeBuild.BufferTokens)
log.Println("Buffer:")
log.Println(fileState.activeBuild.Buffer)

fileState.retryOrError(fmt.Errorf("stream buffer tokens too high for file '%s'", filePath))
return
}
Expand Down

0 comments on commit 45236b3

Please sign in to comment.