Skip to content

Commit

Permalink
Fixed golangci-lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
darmenliu committed Oct 26, 2024
1 parent 60c2dde commit 33136f4
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: golangci/golangci-lint-action@v4
with:
args: --timeout=4m
version: v1.57.2
version: v1.61.0
build:
runs-on: ubuntu-latest
steps:
Expand Down
7 changes: 5 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,16 @@ func executor(in string) {
}

func main() {

// Initialize a big text display with the letters "Nuwa" and "Terminal"
// "P" is displayed in cyan and "Term" is displayed in light magenta
pterm.DefaultBigText.WithLetters(
err := pterm.DefaultBigText.WithLetters(
putils.LettersFromStringWithStyle("Nuwa", pterm.FgCyan.ToStyle()),
putils.LettersFromStringWithStyle(" Terminal", pterm.FgLightMagenta.ToStyle())).
Render() // Render the big text to the terminal
if err != nil {
pterm.Error.Printf("Can not render the big text to the terminal: %v\n", err)
os.Exit(1)
}

// logger := slog.New(slog.NewTextHandler(os.Stdout, nil))
logger := pterm.DefaultLogger.WithLevel(pterm.LogLevelTrace)
Expand Down
6 changes: 4 additions & 2 deletions pkg/file/file_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ type FileReader interface {
// DefaultFileReader is the default implementation of FileReader.
type DefaultFileReader struct{}

func newDefaultFileReader() FileReader {
// NewDefaultFileReader creates a new instance of DefaultFileReader.
// This function is exported so it can be used by other packages if needed.
func NewDefaultFileReader() FileReader {
return &DefaultFileReader{}
}

Expand All @@ -26,7 +28,7 @@ func (fr *DefaultFileReader) ReadFile(path string) (string, error) {
}

// Usage:
// fr := &DefaultFileReader{}
// fr := file.NewDefaultFileReader()
// content, err := fr.ReadFile("/path/to/file.txt")
// if err != nil {
// // handle error
Expand Down
30 changes: 30 additions & 0 deletions pkg/nmemory/chat_history.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
package nmemory

import (
"context"

"github.com/tmc/langchaingo/llms"
"github.com/tmc/langchaingo/memory"
)

type ChatHistory struct {
history *memory.ChatMessageHistory
}

// NewChatHistory creates a new ChatHistory instance
func NewChatHistory() *ChatHistory {
return &ChatHistory{
history: memory.NewChatMessageHistory(),
}
}

// AddUserMessage adds a user message to the chat history
func (ch *ChatHistory) AddUserMessage(ctx context.Context, content string) error {
return ch.history.AddUserMessage(ctx, content)
}

// AddAIMessage adds an AI message to the chat history
func (ch *ChatHistory) AddAIMessage(ctx context.Context, content string) error {
return ch.history.AddAIMessage(ctx, content)
}

// GetMessages returns all messages in the chat history
func (ch *ChatHistory) GetMessages(ctx context.Context) ([]llms.ChatMessage, error) {
return ch.history.Messages(ctx)
}

// Clear clears all messages from the chat history
func (ch *ChatHistory) Clear(ctx context.Context) error {
return ch.history.Clear(ctx)
}

0 comments on commit 33136f4

Please sign in to comment.