yao/agent/assistant/build_content.go
Max beb63b77de Enhance Assistant functionality with improved content handling and debugging
- Added support for converting extended types (file, data) to standard LLM types (text, image_url, input_audio) in the Stream method.
- Introduced a new agentCallerWrapper to facilitate agent calls from the content package.
- Implemented ThreadID management for nested agent calls to improve concurrent stream identification.
- Enhanced message handling to include metadata for message_start and message_end events, allowing for better tracking of message states.
- Removed deprecated vision capability checks from the Assistant initialization process, streamlining the codebase.
- Added new content types (file, data) to the context types for improved message content handling.
2025-12-03 21:35:54 +08:00

31 lines
1,015 B
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) ([]context.Message, error) {
// Get connector and capabilities
_, capabilities, err := ast.GetConnector(ctx)
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
}