Skip to content

Commit

Permalink
lint: Fix up linting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
tmc committed Mar 24, 2024
1 parent 165b905 commit a7ffcc6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,3 @@ linters-settings:
ignore-file-rules:
- "**/*_test.go"
- "**/mock/**/*.go"
run:
skip-dirs:
- 'exp'
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tmc/langgraphgo

go 1.21.5
go 1.22

require github.com/tmc/langchaingo v0.1.7

Expand Down
17 changes: 8 additions & 9 deletions graph/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func ExampleMessageGraph() {
llms.TextParts(schema.ChatMessageTypeAI, r.Choices[0].Content),
), nil
})
g.AddNode(graph.END, func(ctx context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) {
g.AddNode(graph.END, func(_ context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) {
return state, nil
})

Expand Down Expand Up @@ -69,10 +69,10 @@ func TestMessageGraph(t *testing.T) {
name: "Simple graph",
buildGraph: func() *graph.MessageGraph {
g := graph.NewMessageGraph()
g.AddNode("node1", func(ctx context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) {
g.AddNode("node1", func(_ context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) {
return append(state, llms.TextParts(schema.ChatMessageTypeAI, "Node 1")), nil
})
g.AddNode("node2", func(ctx context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) {
g.AddNode("node2", func(_ context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) {
return append(state, llms.TextParts(schema.ChatMessageTypeAI, "Node 2")), nil
})
g.AddEdge("node1", "node2")
Expand All @@ -92,7 +92,7 @@ func TestMessageGraph(t *testing.T) {
name: "Entry point not set",
buildGraph: func() *graph.MessageGraph {
g := graph.NewMessageGraph()
g.AddNode("node1", func(ctx context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) {
g.AddNode("node1", func(_ context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) {
return state, nil
})
return g
Expand All @@ -103,7 +103,7 @@ func TestMessageGraph(t *testing.T) {
name: "Node not found",
buildGraph: func() *graph.MessageGraph {
g := graph.NewMessageGraph()
g.AddNode("node1", func(ctx context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) {
g.AddNode("node1", func(_ context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) {
return state, nil
})
g.AddEdge("node1", "node2")
Expand All @@ -116,7 +116,7 @@ func TestMessageGraph(t *testing.T) {
name: "No outgoing edge",
buildGraph: func() *graph.MessageGraph {
g := graph.NewMessageGraph()
g.AddNode("node1", func(ctx context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) {
g.AddNode("node1", func(_ context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) {
return state, nil
})
g.SetEntryPoint("node1")
Expand All @@ -128,19 +128,18 @@ func TestMessageGraph(t *testing.T) {
name: "Error in node function",
buildGraph: func() *graph.MessageGraph {
g := graph.NewMessageGraph()
g.AddNode("node1", func(ctx context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) {
g.AddNode("node1", func(_ context.Context, _ []llms.MessageContent) ([]llms.MessageContent, error) {
return nil, errors.New("node error")
})
g.AddEdge("node1", graph.END)
g.SetEntryPoint("node1")
return g
},
expectedError: fmt.Errorf("error in node node1: node error"),
expectedError: errors.New("error in node node1: node error"),
},
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
g := tc.buildGraph()
Expand Down

0 comments on commit a7ffcc6

Please sign in to comment.