26 lines
567 B
Go
26 lines
567 B
Go
package provider
|
|
|
|
import (
|
|
"context"
|
|
"github.com/cloudwego/eino/schema"
|
|
"ai_scheduler/internal/domain/llm"
|
|
)
|
|
|
|
type Adapter interface {
|
|
Generate(ctx context.Context, input []*schema.Message, opts llm.Options) (*schema.Message, error)
|
|
Stream(ctx context.Context, input []*schema.Message, opts llm.Options) (*schema.StreamReader[*schema.Message], error)
|
|
}
|
|
|
|
type Factory func() Adapter
|
|
|
|
var registry = map[string]Factory{}
|
|
|
|
func Register(name string, f Factory) {
|
|
registry[name] = f
|
|
}
|
|
|
|
func Get(name string) Factory {
|
|
return registry[name]
|
|
}
|
|
|