yao/aigc/types.go
Max 7bee60c67c refactor: Update AI connector handling and add support for Moapi models
The code changes in `aigc.go` and `types.go` refactor the AI connector handling in the `DSL` struct. The `Connector` field now accepts an optional `moapi` prefix, allowing for the selection of Moapi models. If the `Connector` field starts with `moapi`, the code initializes a new Moapi instance with the specified model. Additionally, the `Connector` field is now marked as `omitempty` in the `types.go` file.

This update improves the flexibility of the AI connector configuration and enables the use of Moapi models in the AI system.
2024-06-15 15:57:36 +08:00

41 lines
1.2 KiB
Go

package aigc
import (
"context"
"github.com/yaoapp/kun/exception"
)
// DSL the connector DSL
type DSL struct {
ID string `json:"-" yaml:"-"`
Name string `json:"name,omitempty"`
Connector string `json:"connector,omitempty"`
Process string `json:"process,omitempty"`
Prompts []Prompt `json:"prompts"`
Optional Optional `json:"optional,omitempty"`
AI AI `json:"-" yaml:"-"`
}
// Prompt a prompt
type Prompt struct {
Role string `json:"role"`
Content string `json:"content"`
Name string `json:"name,omitempty"`
}
// Optional optional
type Optional struct {
Autopilot bool `json:"autopilot,omitempty"`
JSON bool `json:"json,omitempty"`
}
// AI the AI interface
type AI interface {
ChatCompletions(messages []map[string]interface{}, option map[string]interface{}, cb func(data []byte) int) (interface{}, *exception.Exception)
ChatCompletionsWith(ctx context.Context, messages []map[string]interface{}, option map[string]interface{}, cb func(data []byte) int) (interface{}, *exception.Exception)
GetContent(response interface{}) (string, *exception.Exception)
Embeddings(input interface{}, user string) (interface{}, *exception.Exception)
Tiktoken(input string) (int, error)
MaxToken() int
}