feat: Integrate AIGC & OpenAI with Moapi service
This commit is contained in:
parent
db397f8cda
commit
953d592669
3 changed files with 18 additions and 4 deletions
|
|
@ -99,7 +99,7 @@ func (ai *DSL) newAI() (AI, error) {
|
|||
|
||||
if ai.Connector == "" || strings.HasPrefix(ai.Connector, "moapi") {
|
||||
model := "gpt-3.5-turbo"
|
||||
if ai.Connector != "" {
|
||||
if strings.HasPrefix(ai.Connector, "moapi:") {
|
||||
model = strings.TrimPrefix(ai.Connector, "moapi:")
|
||||
}
|
||||
|
||||
|
|
|
|||
10
neo/neo.go
10
neo/neo.go
|
|
@ -343,12 +343,16 @@ func (neo *DSL) write(msg *message.JSON, w io.Writer, ctx command.Context, messa
|
|||
args := []interface{}{ctx, messages, msg, string(content)}
|
||||
p, err := process.Of(neo.Write, args...)
|
||||
if err != nil {
|
||||
return err
|
||||
log.Error("Neo custom write process error: %s", err.Error())
|
||||
msg.Write(w)
|
||||
return nil
|
||||
}
|
||||
|
||||
res, err := p.WithSID(ctx.Sid).Exec()
|
||||
if err != nil {
|
||||
return err
|
||||
log.Error("Neo custom write error: %s", err.Error())
|
||||
msg.Write(w)
|
||||
return nil
|
||||
}
|
||||
|
||||
if res == nil {
|
||||
|
|
@ -549,7 +553,7 @@ func (neo *DSL) newAI() error {
|
|||
|
||||
if neo.Connector == "" || strings.HasPrefix(neo.Connector, "moapi") {
|
||||
model := "gpt-3.5-turbo"
|
||||
if neo.Connector != "" {
|
||||
if strings.HasPrefix(neo.Connector, "moapi:") {
|
||||
model = strings.TrimPrefix(neo.Connector, "moapi:")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,16 @@ type OpenAI struct {
|
|||
|
||||
// New create a new OpenAI instance by connector id
|
||||
func New(id string) (*OpenAI, error) {
|
||||
|
||||
// Moapi integration
|
||||
if id == "" || strings.HasPrefix(id, "moapi") {
|
||||
model := "gpt-3.5-turbo"
|
||||
if strings.HasPrefix(id, "moapi:") {
|
||||
model = strings.TrimPrefix(id, "moapi:")
|
||||
}
|
||||
return NewMoapi(model)
|
||||
}
|
||||
|
||||
c, err := connector.Select(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue