Skip to content

Commit

Permalink
fix: Fix CI failing
Browse files Browse the repository at this point in the history
  • Loading branch information
damilolaedwards committed Sep 30, 2024
1 parent 121b309 commit b4c59eb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
linters:
disable:
- errcheck
5 changes: 3 additions & 2 deletions api/services/conversation.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"assistant/llm"
"assistant/types"
"context"
"errors"
"fmt"
"sync"
)
Expand Down Expand Up @@ -38,7 +39,7 @@ func NewConversationService(targetContracts string) (*ConversationService, error
}

if numTokens > llm.GetDefaultModel().MaxTokenLen {
return nil, fmt.Errorf("target contracts exceed maximum token length")
return nil, errors.New("target contracts exceed maximum token length")
}

return &ConversationService{
Expand Down Expand Up @@ -98,7 +99,7 @@ func (ch *ConversationService) PromptLLM(ctx context.Context, prompt string, mod
func (ch *ConversationService) GenerateReport(ctx context.Context, data dto.GenerateReportDto, model string) ([]types.Message, error) {
sampleFileUrl, ok := ReportTypes[data.ReportType]
if !ok {
return nil, fmt.Errorf("invalid report type")
return nil, errors.New("invalid report type")
}

reportSample, err := client.FetchFileContent(sampleFileUrl, map[string]string{})
Expand Down
3 changes: 2 additions & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"assistant/config"
"assistant/internal/slither"
"assistant/logging/colors"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -37,7 +38,7 @@ func init() {
func cmdValidateStartArgs(cmd *cobra.Command, args []string) error {
// Make sure we have no positional args
if err := cobra.MaximumNArgs(1)(cmd, args); err != nil {
err = fmt.Errorf("start can only accept one positional argument, target contracts directory")
err = errors.New("start can only accept one positional argument, target contracts directory")
cmdLogger.Error("Failed to validate args to the start command", err)
return err
}
Expand Down
3 changes: 2 additions & 1 deletion internal/slither/slither.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"assistant/utils"
_ "embed"
"encoding/json"
"errors"
"fmt"
"log"
"os"
Expand Down Expand Up @@ -148,7 +149,7 @@ func ParseContracts(projectConfig *config.ProjectConfig) ([]types.Contract, stri
// Check if provided directory is a directory
info, err := os.Stat(projectConfig.TargetContracts.Dir)
if err != nil || !info.IsDir() {
return nil, "", fmt.Errorf("unable to read directory")
return nil, "", errors.New("unable to read directory")
}

err = runSlitherOnLocal(projectConfig.TargetContracts.Dir, projectConfig.TargetContracts.ExcludePaths, projectConfig.TestContracts.Dir, projectConfig.TestContracts.ExcludePaths, projectConfig.SlitherArgs, tmpfile)
Expand Down
12 changes: 7 additions & 5 deletions llm/llm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package llm
import (
"assistant/api/client"
"encoding/json"
"errors"
"fmt"
"golang.org/x/net/context"
"io"
"net/http"
"os"

"golang.org/x/net/context"
)

type Model struct {
Expand Down Expand Up @@ -76,7 +78,7 @@ func AskModel(messages []ApiMessage, model string, ctx context.Context) (string,
return "", err
}
if numTokens > m.MaxTokenLen {
return "", fmt.Errorf(TokenLimitExceeded)
return "", errors.New(TokenLimitExceeded)
}

var requestBody any
Expand Down Expand Up @@ -156,7 +158,7 @@ func handleImageResponse(body []byte) (string, error) {
if errorResponse.Error.Message != "" {
return "", fmt.Errorf("error: %s", errorResponse.Error.Message)
}
return "", fmt.Errorf("no response from model")
return "", errors.New("no response from model")
}

func handleOpenAITextResponse(body []byte) (string, error) {
Expand All @@ -177,7 +179,7 @@ func handleOpenAITextResponse(body []byte) (string, error) {
if errorResponse.Error.Message != "" {
return "", fmt.Errorf("error: %s", errorResponse.Error.Message)
}
return "", fmt.Errorf("no response from model")
return "", errors.New("no response from model")
}

func handleClaudeTextResponse(body []byte) (string, error) {
Expand All @@ -197,7 +199,7 @@ func handleClaudeTextResponse(body []byte) (string, error) {
if errorResponse.Error.Message != "" {
return "", fmt.Errorf("error: %s", errorResponse.Error.Message)
}
return "", fmt.Errorf("no response from model")
return "", errors.New("no response from model")
}

func GetDefaultModel() Model {
Expand Down

0 comments on commit b4c59eb

Please sign in to comment.