- Updated the Stream, BuildContent, and LLM execution methods to accept an Options parameter, allowing for more flexible context handling. - Removed debug print statements to clean up the code and improve readability. - Enhanced locale handling in the loadMap function to automatically inject assistant name and description into all locales, ensuring better localization support. - Introduced output skipping functionality in context options to manage internal A2A calls more effectively. - Improved output writer resolution logic to prioritize context settings, enhancing output management during agent calls.
31 lines
1 KiB
Go
31 lines
1 KiB
Go
package assistant
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/yaoapp/yao/agent/content"
|
|
"github.com/yaoapp/yao/agent/context"
|
|
)
|
|
|
|
// BuildContent processes messages through Vision function to convert extended content types
|
|
// (file, data) to standard LLM-compatible types (text, image_url, input_audio)
|
|
//
|
|
// This should be called after BuildRequest and before executing LLM call
|
|
func (ast *Assistant) BuildContent(ctx *context.Context, messages []context.Message, options *context.CompletionOptions, opts *context.Options) ([]context.Message, error) {
|
|
// Get connector and capabilities
|
|
_, capabilities, err := ast.GetConnector(ctx, opts)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to get connector: %w", err)
|
|
}
|
|
|
|
// Get Uses configuration from options (already merged in BuildRequest)
|
|
uses := options.Uses
|
|
|
|
// Process content through Vision function
|
|
processedMessages, err := content.Vision(ctx, capabilities, messages, uses)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to process content: %w", err)
|
|
}
|
|
|
|
return processedMessages, nil
|
|
}
|