feat(video): update ASR terminology and file type labels for improved clarity
- Changed 'Audio Processing' to 'Audio & Video' in English, Korean, Russian, and Chinese translations to reflect expanded functionality. - Updated ASR configuration titles and descriptions to include video processing capabilities, enhancing user understanding of the feature. - Renamed file type labels from 'Audio Files' to 'Audio & Video' across multiple languages for consistency and clarity. - Enhanced document upload handling in the KnowledgeBase to filter unsupported file types, providing user feedback for filtered images, videos, and audio files. This update improves the internationalization of the application and clarifies the capabilities of the ASR feature.
This commit is contained in:
@@ -29,22 +29,33 @@ func NewOllamaVLM(config *Config, ollamaService *ollama.OllamaService) (*OllamaV
|
||||
}
|
||||
|
||||
// Predict sends an image with a text prompt to the Ollama vision model.
|
||||
func (v *OllamaVLM) Predict(ctx context.Context, imgBytes []byte, prompt string) (string, error) {
|
||||
func (v *OllamaVLM) Predict(ctx context.Context, imgBytesList [][]byte, prompt string) (string, error) {
|
||||
streamFlag := false
|
||||
var images []ollamaapi.ImageData
|
||||
for _, imgBytes := range imgBytesList {
|
||||
if len(imgBytes) > 0 {
|
||||
images = append(images, imgBytes)
|
||||
}
|
||||
}
|
||||
|
||||
chatReq := &ollamaapi.ChatRequest{
|
||||
Model: v.modelName,
|
||||
Messages: []ollamaapi.Message{
|
||||
{
|
||||
Role: "user",
|
||||
Content: prompt,
|
||||
Images: []ollamaapi.ImageData{imgBytes},
|
||||
Images: images,
|
||||
},
|
||||
},
|
||||
Stream: &streamFlag,
|
||||
Options: map[string]interface{}{"temperature": 0.1},
|
||||
}
|
||||
|
||||
logger.Infof(ctx, "[VLM] Calling Ollama API, model=%s, imageSize=%d", v.modelName, len(imgBytes))
|
||||
totalImageSize := 0
|
||||
for _, img := range imgBytesList {
|
||||
totalImageSize += len(img)
|
||||
}
|
||||
logger.Infof(ctx, "[VLM] Calling Ollama API, model=%s, numImages=%d, totalImageSize=%d", v.modelName, len(images), totalImageSize)
|
||||
|
||||
var result string
|
||||
err := v.ollamaService.Chat(ctx, chatReq, func(resp ollamaapi.ChatResponse) error {
|
||||
|
||||
@@ -64,37 +64,49 @@ func NewRemoteAPIVLM(config *Config) (*RemoteAPIVLM, error) {
|
||||
}
|
||||
|
||||
// Predict sends an image with a text prompt to the OpenAI-compatible API.
|
||||
func (v *RemoteAPIVLM) Predict(ctx context.Context, imgBytes []byte, prompt string) (string, error) {
|
||||
mimeType := detectImageMIME(imgBytes)
|
||||
b64 := base64.StdEncoding.EncodeToString(imgBytes)
|
||||
dataURI := fmt.Sprintf("data:%s;base64,%s", mimeType, b64)
|
||||
func (v *RemoteAPIVLM) Predict(ctx context.Context, imgBytesList [][]byte, prompt string) (string, error) {
|
||||
var parts []openai.ChatMessagePart
|
||||
|
||||
// Add text prompt first
|
||||
parts = append(parts, openai.ChatMessagePart{
|
||||
Type: openai.ChatMessagePartTypeText,
|
||||
Text: prompt,
|
||||
})
|
||||
|
||||
// Add images
|
||||
for _, imgBytes := range imgBytesList {
|
||||
if len(imgBytes) > 0 {
|
||||
mimeType := detectImageMIME(imgBytes)
|
||||
b64 := base64.StdEncoding.EncodeToString(imgBytes)
|
||||
dataURI := fmt.Sprintf("data:%s;base64,%s", mimeType, b64)
|
||||
parts = append(parts, openai.ChatMessagePart{
|
||||
Type: openai.ChatMessagePartTypeImageURL,
|
||||
ImageURL: &openai.ChatMessageImageURL{
|
||||
URL: dataURI,
|
||||
Detail: openai.ImageURLDetailAuto,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
req := openai.ChatCompletionRequest{
|
||||
Model: v.modelName,
|
||||
Messages: []openai.ChatCompletionMessage{
|
||||
{
|
||||
Role: openai.ChatMessageRoleUser,
|
||||
MultiContent: []openai.ChatMessagePart{
|
||||
{
|
||||
Type: openai.ChatMessagePartTypeImageURL,
|
||||
ImageURL: &openai.ChatMessageImageURL{
|
||||
URL: dataURI,
|
||||
Detail: openai.ImageURLDetailAuto,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: openai.ChatMessagePartTypeText,
|
||||
Text: prompt,
|
||||
},
|
||||
},
|
||||
Role: openai.ChatMessageRoleUser,
|
||||
MultiContent: parts,
|
||||
},
|
||||
},
|
||||
MaxTokens: defaultMaxToks,
|
||||
Temperature: defaultTemp,
|
||||
}
|
||||
|
||||
logger.Infof(ctx, "[VLM] Calling OpenAI-compatible API, model=%s, baseURL=%s, imageSize=%d",
|
||||
v.modelName, v.baseURL, len(imgBytes))
|
||||
totalImageSize := 0
|
||||
for _, img := range imgBytesList {
|
||||
totalImageSize += len(img)
|
||||
}
|
||||
logger.Infof(ctx, "[VLM] Calling OpenAI-compatible API, model=%s, baseURL=%s, numImages=%d, totalImageSize=%d",
|
||||
v.modelName, v.baseURL, len(imgBytesList), totalImageSize)
|
||||
|
||||
resp, err := v.client.CreateChatCompletion(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
|
||||
// VLM defines the interface for Vision Language Model operations.
|
||||
type VLM interface {
|
||||
// Predict sends an image with a text prompt to the VLM and returns the generated text.
|
||||
Predict(ctx context.Context, imgBytes []byte, prompt string) (string, error)
|
||||
// Predict sends one or more images with a text prompt to the VLM and returns the generated text.
|
||||
Predict(ctx context.Context, imgBytes [][]byte, prompt string) (string, error)
|
||||
|
||||
GetModelName() string
|
||||
GetModelID() string
|
||||
|
||||
Reference in New Issue
Block a user