Neo initialization to enable ‘moapi’ connector and default model support
This commit is contained in:
parent
16234df9d6
commit
61a292c7a6
3 changed files with 26 additions and 5 deletions
|
|
@ -110,8 +110,19 @@ func (cmd *Command) save() error {
|
|||
// NewAI create a new AI
|
||||
func (cmd *Command) newAI() (aigc.AI, error) {
|
||||
|
||||
if cmd.Connector == "" {
|
||||
return nil, fmt.Errorf("%s connector is required", cmd.ID)
|
||||
if cmd.Connector == "" || strings.HasPrefix(cmd.Connector, "moapi") {
|
||||
model := "gpt-3.5-turbo"
|
||||
if strings.HasPrefix(cmd.Connector, "moapi:") {
|
||||
model = strings.TrimPrefix(cmd.Connector, "moapi:")
|
||||
}
|
||||
|
||||
ai, err := openai.NewMoapi(model)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cmd.AI = ai
|
||||
return cmd.AI, nil
|
||||
}
|
||||
|
||||
conn, err := connector.Select(cmd.Connector)
|
||||
|
|
|
|||
|
|
@ -198,8 +198,17 @@ func (driver *Memory) GetCommands() ([]Command, error) {
|
|||
// NewAI create a new AI
|
||||
func (driver *Memory) newAI() (aigc.AI, error) {
|
||||
|
||||
if driver.model == "" {
|
||||
return nil, fmt.Errorf("%s connector is required", driver.model)
|
||||
if driver.model == "" || strings.HasPrefix(driver.model, "moapi") {
|
||||
model := "gpt-3.5-turbo"
|
||||
if strings.HasPrefix(driver.model, "moapi:") {
|
||||
model = strings.TrimPrefix(driver.model, "moapi:")
|
||||
}
|
||||
|
||||
ai, err := openai.NewMoapi(model)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ai, nil
|
||||
}
|
||||
|
||||
conn, err := connector.Select(driver.model)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,8 @@ func Load(cfg config.Config) error {
|
|||
if parser == "" || parser == "default" {
|
||||
parser = setting.Connector
|
||||
}
|
||||
store, err := driver.NewMemory(setting.Command.Parser, nil)
|
||||
|
||||
store, err := driver.NewMemory(parser, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue