- Added global uses configuration to the assistant, allowing for centralized management of vision, audio, search, and fetch settings. - Updated the Assistant struct and related methods to support the new Uses configuration, improving flexibility in assistant operations. - Refactored the Stream method to utilize the new CompletionResponse type, enhancing response handling. - Introduced new methods for building requests and managing capabilities, streamlining the assistant's interaction with various connectors.
59 lines
1.8 KiB
Go
59 lines
1.8 KiB
Go
package audio
|
|
|
|
import (
|
|
"github.com/yaoapp/yao/agent/context"
|
|
)
|
|
|
|
// PreprocessAudioMessages preprocess messages to handle audio content
|
|
// Removes or converts audio content for models that don't support it
|
|
func PreprocessAudioMessages(messages []context.Message, supportsAudio bool) []context.Message {
|
|
// TODO: Implement audio message preprocessing
|
|
// If supportsAudio is false:
|
|
// - Remove input_audio content parts
|
|
// - Convert to text-only messages
|
|
// - Optionally add audio transcriptions
|
|
// If supportsAudio is true:
|
|
// - Validate audio format
|
|
// - Ensure proper encoding
|
|
return messages
|
|
}
|
|
|
|
// ConvertAudioToText convert audio content to text transcription
|
|
// Used when model doesn't support audio input
|
|
func ConvertAudioToText(audioData string) (string, error) {
|
|
// TODO: Implement audio to text conversion
|
|
// - Call speech-to-text API (Whisper, etc.)
|
|
// - Generate transcription
|
|
// - Return as text content
|
|
return "", nil
|
|
}
|
|
|
|
// ValidateAudioFormat validate audio format and encoding
|
|
func ValidateAudioFormat(audioConfig *context.AudioConfig) error {
|
|
// TODO: Implement audio format validation
|
|
// - Check format (wav, mp3, etc.)
|
|
// - Validate encoding
|
|
// - Check sample rate
|
|
return nil
|
|
}
|
|
|
|
// ExtractAudioFromMessages extract all audio data from messages
|
|
func ExtractAudioFromMessages(messages []context.Message) []string {
|
|
// TODO: Implement audio extraction
|
|
// - Iterate through messages
|
|
// - Find ContentPart with type="input_audio"
|
|
// - Collect all audio data
|
|
return nil
|
|
}
|
|
|
|
// RemoveAudioConfig remove audio configuration from options
|
|
// Used when model doesn't support audio output
|
|
func RemoveAudioConfig(options *context.CompletionOptions) *context.CompletionOptions {
|
|
// TODO: Remove audio config from options
|
|
if options == nil {
|
|
return options
|
|
}
|
|
newOptions := *options
|
|
newOptions.Audio = nil
|
|
return &newOptions
|
|
}
|