Skip to content

Commit

Permalink
feat(devops): add eino devops examples
Browse files Browse the repository at this point in the history
  • Loading branch information
liujian-bytedance committed Jan 21, 2025
1 parent ba14795 commit 05f2cb6
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
49 changes: 48 additions & 1 deletion devops/debug/graph/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package graph

import (
"context"

Check failure on line 20 in devops/debug/graph/graph.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not properly formatted (goimports)

"github.com/cloudwego/eino/compose"

"github.com/cloudwego/eino-examples/internal/logs"
Expand Down Expand Up @@ -61,3 +60,51 @@ func RegisterSimpleGraph(ctx context.Context) {

logs.Infof("eino simple graph output is: %v", message)
}

type NodeInfo struct {
Message string
}

func RegisterGraphOfInterfaceType(ctx context.Context) {
g := compose.NewGraph[any, string]()

_ = g.AddLambdaNode("node_1", compose.InvokableLambda(func(ctx context.Context, input *NodeInfo) (output string, err error) {
if input == nil {
return "", nil
}
return input.Message + " process by node_1,", nil
}))

_ = g.AddLambdaNode("node_2", compose.InvokableLambda(func(ctx context.Context, input string) (output string, err error) {
return input + " process by node_2,", nil
}))

_ = g.AddLambdaNode("node_3", compose.InvokableLambda(func(ctx context.Context, input string) (output string, err error) {
return input + " process by node_3,", nil
}))

_ = g.AddEdge(compose.START, "node_1")

_ = g.AddEdge("node_1", "node_2")

_ = g.AddEdge("node_2", "node_3")

_ = g.AddEdge("node_3", compose.END)

r, err := g.Compile(ctx)
if err != nil {
logs.Errorf("compile graph failed, err=%v", err)
return
}

message, err := r.Invoke(ctx, &NodeInfo{
Message: "test data",
})

if err != nil {
logs.Errorf("invoke graph failed, err=%v", err)
return
}

logs.Infof("eino simple graph output is: %v", message)
}
5 changes: 3 additions & 2 deletions devops/debug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ import (
func main() {
ctx := context.Background()

// Init eino devops server
err := devops.Init(ctx)
err := devops.Init(ctx, devops.AppendType(&graph.NodeInfo{}))
if err != nil {
logs.Errorf("[eino dev] init failed, err=%v", err)
return
Expand All @@ -44,6 +43,8 @@ func main() {
graph.RegisterSimpleGraph(ctx)
graph.RegisterSimpleStateGraph(ctx)

graph.RegisterGraphOfInterfaceType(ctx)

// Blocking process exits
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250114173536-ca9322ed9f9a
github.com/cloudwego/eino-ext/components/retriever/volc_vikingdb v0.0.0-20250108030439-1493aa120cb1
github.com/cloudwego/eino-ext/components/tool/duckduckgo v0.0.0-20250116120445-4165a5358a34
github.com/cloudwego/eino-ext/devops v0.0.0-20250116071241-3f1eaaafd49c
github.com/cloudwego/eino-ext/devops v0.0.0-20250120131302-5fded775a2a2
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/getkin/kin-openapi v0.118.0
github.com/ollama/ollama v0.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ github.com/cloudwego/eino-ext/components/retriever/volc_vikingdb v0.0.0-20250108
github.com/cloudwego/eino-ext/components/retriever/volc_vikingdb v0.0.0-20250108030439-1493aa120cb1/go.mod h1:lj6h0MYtiEGwWDVdkOd4VmZBF7JVWV5bNxv0/r2C+W0=
github.com/cloudwego/eino-ext/components/tool/duckduckgo v0.0.0-20250116120445-4165a5358a34 h1:uiAF49aHUfOW3hT8dJzrrrCt7dTqoSlUynp18C5QKPU=
github.com/cloudwego/eino-ext/components/tool/duckduckgo v0.0.0-20250116120445-4165a5358a34/go.mod h1:Do8C+KMH+3PiF/jYV/8oFQz+UvCTrThswB9fZWiqfgI=
github.com/cloudwego/eino-ext/devops v0.0.0-20250116071241-3f1eaaafd49c h1:WslgauCA6SisgAPn7cNlhHrmJsX5Fq/tG+87oYCTH3s=
github.com/cloudwego/eino-ext/devops v0.0.0-20250116071241-3f1eaaafd49c/go.mod h1:MzPGghc4J7rSevtxeZpqAejpaFbkoCNzG6AQLG93WmE=
github.com/cloudwego/eino-ext/devops v0.0.0-20250120131302-5fded775a2a2 h1:qAfETnvohhxHt+E1f9KCz7l4tcZGmLuJyEIGhBpO42w=
github.com/cloudwego/eino-ext/devops v0.0.0-20250120131302-5fded775a2a2/go.mod h1:++GgqYXdxPJYxbXzK/613wxaK7Blg3XlqZU/gH8CPXU=
github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250114173020-562b40c138d3 h1:DHeeScM7IOmh8YxbLLNu5FrUMuylDfnsuZ3QLTEThq0=
github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250114173020-562b40c138d3/go.mod h1:H5UK9sjotuBaZCO6CFvPRaYDBBfRz/MSFR9ZNEmwgCo=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
Expand Down

0 comments on commit 05f2cb6

Please sign in to comment.