55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
/*
|
|
* Copyright 2024 CloudWeGo Authors
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package callbacks
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/cloudwego/eino/components"
|
|
"github.com/cloudwego/eino/schema"
|
|
)
|
|
|
|
type RunInfo struct {
|
|
// Name is the graph node name for display purposes, not unique.
|
|
// Passed from compose.WithNodeName().
|
|
Name string
|
|
Type string
|
|
Component components.Component
|
|
}
|
|
|
|
type CallbackInput any
|
|
|
|
type CallbackOutput any
|
|
|
|
type Handler interface {
|
|
OnStart(ctx context.Context, info *RunInfo, input CallbackInput) context.Context
|
|
OnEnd(ctx context.Context, info *RunInfo, output CallbackOutput) context.Context
|
|
|
|
OnError(ctx context.Context, info *RunInfo, err error) context.Context
|
|
|
|
OnStartWithStreamInput(ctx context.Context, info *RunInfo,
|
|
input *schema.StreamReader[CallbackInput]) context.Context
|
|
OnEndWithStreamOutput(ctx context.Context, info *RunInfo,
|
|
output *schema.StreamReader[CallbackOutput]) context.Context
|
|
}
|
|
|
|
type CallbackTiming uint8
|
|
|
|
type TimingChecker interface {
|
|
Needed(ctx context.Context, info *RunInfo, timing CallbackTiming) bool
|
|
}
|