- Replaced the base assistant package with a local assistant implementation, enhancing modularity and maintainability. - Updated the newAssistantByConnector function to utilize the local assistant, ensuring consistent error handling and improved functionality. - Removed obsolete base assistant files, streamlining the codebase and reducing complexity. - Added a new 'mentionable' field to the assistant table in the Xun implementation, allowing for better management of assistant visibility in mentions.
21 lines
460 B
Go
21 lines
460 B
Go
package local
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
// Chat the chat
|
|
func (ast *Local) Chat(ctx context.Context, messages []map[string]interface{}, option map[string]interface{}, cb func(data []byte) int) error {
|
|
|
|
if ast.openai == nil {
|
|
return fmt.Errorf("api is not initialized")
|
|
}
|
|
|
|
_, ext := ast.openai.ChatCompletionsWith(ctx, messages, option, cb)
|
|
if ext != nil {
|
|
return fmt.Errorf("openai chat completions with error: %s", ext.Message)
|
|
}
|
|
|
|
return nil
|
|
}
|