48 lines
927 B
Go
48 lines
927 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/inngest/inngestgo"
|
|
|
|
openrouter "github.com/OpenRouterTeam/go-sdk"
|
|
"github.com/OpenRouterTeam/go-sdk/models/components"
|
|
)
|
|
|
|
func main() {
|
|
client, err := inngestgo.NewClient(inngestgo.ClientOpts{
|
|
AppID: "worker",
|
|
})
|
|
|
|
if err != nil {
|
|
panic("Couldn't initialize inngest client")
|
|
}
|
|
|
|
_, err = inngestgo.CreateFunction(
|
|
client,
|
|
inngestgo.FunctionOpts{
|
|
ID: "create-new-fish",
|
|
},
|
|
inngestgo.CronTriggerWithJitter("0 0 * * *", time.Duration(60)*time.Minute),
|
|
CreateNewFishCron,
|
|
)
|
|
|
|
http.ListenAndServe(":3000", client.Serve())
|
|
}
|
|
|
|
func CreateNewFish(ctx context.Context) {
|
|
s := openrouter.New(
|
|
openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
|
|
)
|
|
|
|
res, err := s.Chat.Send(ctx, components.ChatRequest{})
|
|
}
|
|
|
|
func CreateNewFishCron(ctx context.Context, input inngestgo.Input[any]) (any, error) {
|
|
CreateNewFish()
|
|
return nil, nil
|
|
}
|