Merge pull request #623 from trheyi/main
refactor: Update AI connector handling and add support for Moapi models
This commit is contained in:
commit
078c38bf06
2 changed files with 13 additions and 3 deletions
14
aigc/aigc.go
14
aigc/aigc.go
|
|
@ -2,6 +2,7 @@ package aigc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"github.com/yaoapp/gou/connector"
|
"github.com/yaoapp/gou/connector"
|
||||||
|
|
@ -96,8 +97,17 @@ func (ai *DSL) Call(content string, user string, option map[string]interface{})
|
||||||
// NewAI create a new AI
|
// NewAI create a new AI
|
||||||
func (ai *DSL) newAI() (AI, error) {
|
func (ai *DSL) newAI() (AI, error) {
|
||||||
|
|
||||||
if ai.Connector == "" {
|
if ai.Connector == "" || strings.HasPrefix(ai.Connector, "moapi") {
|
||||||
return nil, fmt.Errorf("%s connector is required", ai.ID)
|
model := "gpt-3.5-turbo"
|
||||||
|
if ai.Connector != "" {
|
||||||
|
model = strings.TrimPrefix(ai.Connector, "moapi:")
|
||||||
|
}
|
||||||
|
|
||||||
|
mo, err := openai.NewMoapi(model)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return mo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := connector.Select(ai.Connector)
|
conn, err := connector.Select(ai.Connector)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
type DSL struct {
|
type DSL struct {
|
||||||
ID string `json:"-" yaml:"-"`
|
ID string `json:"-" yaml:"-"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Connector string `json:"connector"`
|
Connector string `json:"connector,omitempty"`
|
||||||
Process string `json:"process,omitempty"`
|
Process string `json:"process,omitempty"`
|
||||||
Prompts []Prompt `json:"prompts"`
|
Prompts []Prompt `json:"prompts"`
|
||||||
Optional Optional `json:"optional,omitempty"`
|
Optional Optional `json:"optional,omitempty"`
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue