Skip to content

Commit

Permalink
Merge pull request #774 from trheyi/main
Browse files Browse the repository at this point in the history
Neo initialization to enable ‘moapi’ connector and default model support
  • Loading branch information
trheyi authored Nov 5, 2024
2 parents c1d40e7 + 61a292c commit dd49ae4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
15 changes: 13 additions & 2 deletions neo/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 11 additions & 2 deletions neo/command/driver/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion neo/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit dd49ae4

Please sign in to comment.