This section guides you through adding a custom process to Yao. You can run it using yao run or invoke it via the Process API.
# Create a new process file
mkdir -p /code/root/yao/hello
touch /code/root/yao/hello/hello.go
// /code/root/yao/hello/hello.go
package hello
import (
"github.com/yaoapp/gou/process"
)
func init(){
process.Register("namespace.hello", processHello)
}
func processHello(process *process.Process) inteface{} {
args := process.Args
return map[string]interface{}{"args": process.Args}
}
Import the new process into the main.go file.
package main
import (
"github.com/yaoapp/yao/cmd"
"github.com/yaoapp/yao/utils"
// Import the new process
_ "github.com/yaoapp/yao/hello"
_ "github.com/yaoapp/gou/encoding"
_ "github.com/yaoapp/yao/aigc"
_ "github.com/yaoapp/yao/crypto"
_ "github.com/yaoapp/yao/helper"
_ "github.com/yaoapp/yao/openai"
_ "github.com/yaoapp/yao/wework"
)