- Updated the Vision function and associated handlers to accept a forceUses parameter, allowing explicit control over the use of external tools regardless of model capabilities. - Modified the Assistant's BuildContent method to set the AssistantID in the context for better file tracking. - Enhanced the applyCreateResponseOptions method to merge and prioritize Uses and ForceUses configurations from the createResponse. - Added comprehensive tests to validate the adjustment of Uses and ForceUses configurations through hooks, ensuring correct application in content processing.
48 lines
1.7 KiB
Go
48 lines
1.7 KiB
Go
package content
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/yaoapp/gou/connector/openai"
|
|
agentContext "github.com/yaoapp/yao/agent/context"
|
|
)
|
|
|
|
// ExcelHandler handles Microsoft Excel spreadsheets
|
|
type ExcelHandler struct{}
|
|
|
|
// CanHandle checks if this handler can handle the content type
|
|
func (h *ExcelHandler) CanHandle(contentType string, fileType FileType) bool {
|
|
return fileType == FileTypeExcel ||
|
|
contentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
|
|
contentType == "application/vnd.ms-excel" ||
|
|
strings.Contains(contentType, "excel") ||
|
|
strings.Contains(contentType, "spreadsheet")
|
|
}
|
|
|
|
// Handle processes Excel spreadsheet content
|
|
func (h *ExcelHandler) Handle(ctx *agentContext.Context, info *Info, capabilities *openai.Capabilities, uses *agentContext.Uses, forceUses bool) (*Result, error) {
|
|
// TODO: Implement Excel handling
|
|
// 1. Extract data from .xlsx or .xls file
|
|
// 2. Convert to text format (e.g., CSV-like or structured text)
|
|
// 3. Handle multiple sheets
|
|
// 4. Return Result with formatted text
|
|
return nil, fmt.Errorf("not implemented")
|
|
}
|
|
|
|
// extractExcelText extracts text from Excel file
|
|
func extractExcelText(data []byte, contentType string) (string, error) {
|
|
// TODO: Implement Excel text extraction
|
|
// Handle both .xls (old format) and .xlsx (new format)
|
|
// Consider using libraries like:
|
|
// - github.com/360EntSecGroup-Skylar/excelize for .xlsx
|
|
// Format output as readable text or CSV
|
|
return "", fmt.Errorf("not implemented")
|
|
}
|
|
|
|
// formatExcelAsText formats Excel data as readable text
|
|
func formatExcelAsText(sheets map[string][][]string) string {
|
|
// TODO: Format multiple sheets into readable text
|
|
// Include sheet names, headers, and data
|
|
return ""
|
|
}
|