Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
//
|
|
|
|
|
// Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
package cli
|
|
|
|
|
|
2026-05-20 20:32:06 +08:00
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"strings"
|
|
|
|
|
)
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
|
|
|
|
|
type ResponseIf interface {
|
|
|
|
|
Type() string
|
|
|
|
|
PrintOut()
|
|
|
|
|
TimeCost() float64
|
|
|
|
|
SetOutputFormat(format OutputFormat)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CommonResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Data []map[string]interface{} `json:"data"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Duration float64
|
2026-04-07 11:30:09 +08:00
|
|
|
OutputFormat OutputFormat
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *CommonResponse) Type() string {
|
|
|
|
|
return "common"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *CommonResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *CommonResponse) SetOutputFormat(format OutputFormat) {
|
2026-04-07 11:30:09 +08:00
|
|
|
r.OutputFormat = format
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *CommonResponse) PrintOut() {
|
|
|
|
|
if r.Code == 0 {
|
2026-04-07 11:30:09 +08:00
|
|
|
PrintTableSimpleByFormat(r.Data, r.OutputFormat)
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
} else {
|
|
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d, %s\n", r.Code, r.Message)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-15 10:10:14 +08:00
|
|
|
type ModelsResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Data map[string][]map[string]interface{} `json:"data"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Duration float64
|
|
|
|
|
OutputFormat OutputFormat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ModelsResponse) Type() string {
|
|
|
|
|
return "models"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ModelsResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ModelsResponse) SetOutputFormat(format OutputFormat) {
|
|
|
|
|
r.OutputFormat = format
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ModelsResponse) PrintOut() {
|
|
|
|
|
if r.Code == 0 {
|
|
|
|
|
models := r.Data["models"]
|
|
|
|
|
PrintTableSimpleByFormat(models, r.OutputFormat)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d, %s\n", r.Code, r.Message)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
type CommonDataResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Data map[string]interface{} `json:"data"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Duration float64
|
2026-04-07 11:30:09 +08:00
|
|
|
OutputFormat OutputFormat
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *CommonDataResponse) Type() string {
|
|
|
|
|
return "show"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *CommonDataResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *CommonDataResponse) SetOutputFormat(format OutputFormat) {
|
2026-04-07 11:30:09 +08:00
|
|
|
r.OutputFormat = format
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *CommonDataResponse) PrintOut() {
|
|
|
|
|
if r.Code == 0 {
|
|
|
|
|
table := make([]map[string]interface{}, 0)
|
2026-06-03 13:23:20 +08:00
|
|
|
for key, value := range r.Data {
|
|
|
|
|
elem := map[string]interface{}{
|
|
|
|
|
"field": key,
|
|
|
|
|
"value": value,
|
|
|
|
|
}
|
|
|
|
|
table = append(table, elem)
|
|
|
|
|
}
|
|
|
|
|
//table = append(table, r.Data)
|
2026-04-07 11:30:09 +08:00
|
|
|
PrintTableSimpleByFormat(table, r.OutputFormat)
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
} else {
|
|
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d, %s\n", r.Code, r.Message)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-15 14:00:45 +08:00
|
|
|
type ListDocumentsResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Data map[string]interface{} `json:"data"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Duration float64
|
|
|
|
|
OutputFormat OutputFormat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ListDocumentsResponse) Type() string {
|
|
|
|
|
return "list_documents"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ListDocumentsResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ListDocumentsResponse) SetOutputFormat(format OutputFormat) {
|
|
|
|
|
r.OutputFormat = format
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ListDocumentsResponse) PrintOut() {
|
|
|
|
|
if r.Code == 0 {
|
|
|
|
|
total := r.Data["total"].(float64)
|
|
|
|
|
fmt.Printf("Total: %0.0f\n", total)
|
|
|
|
|
docs := r.Data["docs"].([]interface{})
|
|
|
|
|
table := make([]map[string]interface{}, 0)
|
|
|
|
|
for _, doc := range docs {
|
|
|
|
|
table = append(table, doc.(map[string]interface{}))
|
|
|
|
|
}
|
|
|
|
|
PrintTableSimpleByFormat(table, r.OutputFormat)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d, %s\n", r.Code, r.Message)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-20 20:32:06 +08:00
|
|
|
type ChunkResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Data map[string]interface{} `json:"data"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Duration float64
|
|
|
|
|
OutputFormat OutputFormat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ChunkResponse) Type() string {
|
|
|
|
|
return "chunk"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ChunkResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ChunkResponse) SetOutputFormat(format OutputFormat) {
|
|
|
|
|
r.OutputFormat = format
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ChunkResponse) PrintOut() {
|
|
|
|
|
if r.Code == 0 {
|
|
|
|
|
for k, v := range r.Data {
|
|
|
|
|
fmt.Printf("%s: %v\n", k, v)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d, %s\n", r.Code, r.Message)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type MetadataResponse struct {
|
2026-06-03 13:23:20 +08:00
|
|
|
Code int `json:"code"`
|
|
|
|
|
Data map[string]interface{} `json:"data"`
|
|
|
|
|
Message string `json:"message"`
|
2026-05-20 20:32:06 +08:00
|
|
|
Duration float64
|
|
|
|
|
OutputFormat OutputFormat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *MetadataResponse) Type() string {
|
|
|
|
|
return "metadata"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *MetadataResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *MetadataResponse) SetOutputFormat(format OutputFormat) {
|
|
|
|
|
r.OutputFormat = format
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *MetadataResponse) PrintOut() {
|
|
|
|
|
if r.Code == 0 {
|
|
|
|
|
// Data is map[field]map[value][]doc_id - print flattened metadata
|
|
|
|
|
if r.Data != nil {
|
|
|
|
|
printFlattenedMetadata(r.Data, r.OutputFormat)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d, %s\n", r.Code, r.Message)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func printFlattenedMetadata(data map[string]interface{}, format OutputFormat) {
|
|
|
|
|
// Convert flattened metadata to table format
|
|
|
|
|
// {field: {value: [doc_ids]}} -> [{field, value, document_ids}, ...]
|
|
|
|
|
tableData := make([]map[string]interface{}, 0)
|
|
|
|
|
for field, values := range data {
|
|
|
|
|
valueMap, ok := values.(map[string]interface{})
|
|
|
|
|
if !ok {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
for value, docIDs := range valueMap {
|
|
|
|
|
var docIDStr string
|
|
|
|
|
switch v := docIDs.(type) {
|
|
|
|
|
case []string:
|
|
|
|
|
docIDStr = strings.Join(v, ", ")
|
|
|
|
|
case []interface{}:
|
|
|
|
|
docStrs := make([]string, 0, len(v))
|
|
|
|
|
for _, d := range v {
|
|
|
|
|
if s, ok := d.(string); ok {
|
|
|
|
|
docStrs = append(docStrs, s)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
docIDStr = strings.Join(docStrs, ", ")
|
|
|
|
|
default:
|
|
|
|
|
docIDStr = fmt.Sprintf("%v", docIDs)
|
|
|
|
|
}
|
|
|
|
|
tableData = append(tableData, map[string]interface{}{
|
2026-06-03 13:23:20 +08:00
|
|
|
"field": field,
|
|
|
|
|
"value": value,
|
2026-05-20 20:32:06 +08:00
|
|
|
"document_ids": docIDStr,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
PrintTableSimpleByFormat(tableData, format)
|
|
|
|
|
}
|
|
|
|
|
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
type SimpleResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Duration float64
|
2026-04-07 11:30:09 +08:00
|
|
|
OutputFormat OutputFormat
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *SimpleResponse) Type() string {
|
|
|
|
|
return "simple"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *SimpleResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *SimpleResponse) SetOutputFormat(format OutputFormat) {
|
2026-04-07 11:30:09 +08:00
|
|
|
r.OutputFormat = format
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *SimpleResponse) PrintOut() {
|
|
|
|
|
if r.Code == 0 {
|
|
|
|
|
fmt.Println("SUCCESS")
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d, %s\n", r.Code, r.Message)
|
2026-05-18 01:08:45 -10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type MessageResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Duration float64
|
|
|
|
|
OutputFormat OutputFormat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *MessageResponse) Type() string {
|
|
|
|
|
return "message"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *MessageResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *MessageResponse) SetOutputFormat(format OutputFormat) {
|
|
|
|
|
r.OutputFormat = format
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *MessageResponse) PrintOut() {
|
|
|
|
|
if r.Code == 0 {
|
|
|
|
|
fmt.Println(r.Message)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d, %s\n", r.Code, r.Message)
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
}
|
2026-04-02 20:20:35 +08:00
|
|
|
|
2026-04-21 16:52:32 +08:00
|
|
|
type NonStreamResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
ReasoningContent string `json:"reasoning_content"`
|
|
|
|
|
Answer string `json:"answer"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Duration float64
|
|
|
|
|
OutputFormat OutputFormat
|
2026-04-02 20:20:35 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-21 16:52:32 +08:00
|
|
|
func (r *NonStreamResponse) Type() string {
|
|
|
|
|
return "non_stream_message"
|
2026-04-02 20:20:35 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-21 16:52:32 +08:00
|
|
|
func (r *NonStreamResponse) TimeCost() float64 {
|
2026-04-02 20:20:35 +08:00
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-21 16:52:32 +08:00
|
|
|
func (r *NonStreamResponse) SetOutputFormat(format OutputFormat) {
|
2026-04-07 11:30:09 +08:00
|
|
|
r.OutputFormat = format
|
2026-04-02 20:20:35 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-21 16:52:32 +08:00
|
|
|
func (r *NonStreamResponse) PrintOut() {
|
2026-04-02 20:20:35 +08:00
|
|
|
if r.Code == 0 {
|
2026-04-21 16:52:32 +08:00
|
|
|
if r.ReasoningContent != "" {
|
|
|
|
|
fmt.Printf("Thinking: %s\n", r.ReasoningContent)
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("Answer: %s\n", r.Answer)
|
2026-04-24 20:59:30 +08:00
|
|
|
fmt.Printf("Time: %f\n", r.Duration)
|
2026-04-02 20:20:35 +08:00
|
|
|
} else {
|
|
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d, %s\n", r.Code, r.Message)
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-03 18:11:23 +08:00
|
|
|
|
|
|
|
|
type StreamMessageResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Duration float64
|
2026-04-07 11:30:09 +08:00
|
|
|
OutputFormat OutputFormat
|
2026-04-03 18:11:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *StreamMessageResponse) Type() string {
|
|
|
|
|
return "stream_message"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *StreamMessageResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *StreamMessageResponse) SetOutputFormat(format OutputFormat) {
|
2026-04-07 11:30:09 +08:00
|
|
|
r.OutputFormat = format
|
2026-04-03 18:11:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *StreamMessageResponse) PrintOut() {
|
2026-04-24 20:59:30 +08:00
|
|
|
if r.Code == 0 {
|
|
|
|
|
fmt.Printf("Time: %f\n", r.Duration)
|
|
|
|
|
} else {
|
2026-04-03 18:11:23 +08:00
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d, %s\n", r.Code, r.Message)
|
|
|
|
|
}
|
|
|
|
|
}
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
|
|
|
|
|
type RegisterResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Duration float64
|
2026-04-07 11:30:09 +08:00
|
|
|
OutputFormat OutputFormat
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *RegisterResponse) Type() string {
|
|
|
|
|
return "register"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *RegisterResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *RegisterResponse) SetOutputFormat(format OutputFormat) {
|
2026-04-07 11:30:09 +08:00
|
|
|
r.OutputFormat = format
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *RegisterResponse) PrintOut() {
|
|
|
|
|
if r.Code == 0 {
|
|
|
|
|
fmt.Println("Register successfully")
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d, %s\n", r.Code, r.Message)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type BenchmarkResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Duration float64 `json:"duration"`
|
|
|
|
|
SuccessCount int `json:"success_count"`
|
|
|
|
|
FailureCount int `json:"failure_count"`
|
|
|
|
|
Concurrency int
|
2026-04-07 11:30:09 +08:00
|
|
|
OutputFormat OutputFormat
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *BenchmarkResponse) Type() string {
|
|
|
|
|
return "benchmark"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *BenchmarkResponse) SetOutputFormat(format OutputFormat) {
|
2026-04-07 11:30:09 +08:00
|
|
|
r.OutputFormat = format
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *BenchmarkResponse) PrintOut() {
|
|
|
|
|
if r.Code != 0 {
|
|
|
|
|
fmt.Printf("ERROR, Code: %d\n", r.Code)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iterations := r.SuccessCount + r.FailureCount
|
|
|
|
|
if r.Concurrency == 1 {
|
|
|
|
|
if iterations == 1 {
|
|
|
|
|
fmt.Printf("Latency: %fs\n", r.Duration)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf("Latency: %fs, QPS: %.1f, SUCCESS: %d, FAILURE: %d\n", r.Duration, float64(iterations)/r.Duration, r.SuccessCount, r.FailureCount)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf("Concurrency: %d, Latency: %fs, QPS: %.1f, SUCCESS: %d, FAILURE: %d\n", r.Concurrency, r.Duration, float64(iterations)/r.Duration, r.SuccessCount, r.FailureCount)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *BenchmarkResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type KeyValueResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Key string `json:"key"`
|
|
|
|
|
Value string `json:"data"`
|
|
|
|
|
Duration float64
|
2026-04-07 11:30:09 +08:00
|
|
|
OutputFormat OutputFormat
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *KeyValueResponse) Type() string {
|
|
|
|
|
return "data"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *KeyValueResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *KeyValueResponse) SetOutputFormat(format OutputFormat) {
|
2026-04-07 11:30:09 +08:00
|
|
|
r.OutputFormat = format
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *KeyValueResponse) PrintOut() {
|
|
|
|
|
if r.Code == 0 {
|
|
|
|
|
table := make([]map[string]interface{}, 0)
|
|
|
|
|
// insert r.key and r.value into table
|
|
|
|
|
table = append(table, map[string]interface{}{
|
|
|
|
|
"key": r.Key,
|
|
|
|
|
"value": r.Value,
|
|
|
|
|
})
|
2026-04-07 11:30:09 +08:00
|
|
|
PrintTableSimpleByFormat(table, r.OutputFormat)
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
} else {
|
|
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d\n", r.Code)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-11 14:45:30 +08:00
|
|
|
type EmbeddingData struct {
|
|
|
|
|
Index int `json:"index"`
|
|
|
|
|
Embedding []float64 `json:"embedding"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type EmbeddingsResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Data []EmbeddingData `json:"data"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Duration float64
|
|
|
|
|
OutputFormat OutputFormat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *EmbeddingsResponse) Type() string {
|
|
|
|
|
return "common"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *EmbeddingsResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *EmbeddingsResponse) SetOutputFormat(format OutputFormat) {
|
|
|
|
|
r.OutputFormat = format
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *EmbeddingsResponse) PrintOut() {
|
|
|
|
|
var data []map[string]interface{}
|
|
|
|
|
for _, embedding := range r.Data {
|
|
|
|
|
data = append(data, map[string]interface{}{
|
|
|
|
|
"index": formatValue(embedding.Index),
|
|
|
|
|
"dimension": len(embedding.Embedding),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if r.Code == 0 {
|
|
|
|
|
PrintTableSimpleByFormat(data, r.OutputFormat)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d, %s\n", r.Code, r.Message)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-15 12:29:52 +08:00
|
|
|
type SegmentResponse struct {
|
|
|
|
|
Segments []map[string]interface{} `json:"segments"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type TaskResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Data map[string]interface{} `json:"data"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Duration float64
|
|
|
|
|
OutputFormat OutputFormat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *TaskResponse) Type() string {
|
|
|
|
|
return "task"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *TaskResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *TaskResponse) SetOutputFormat(format OutputFormat) {
|
|
|
|
|
r.OutputFormat = format
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *TaskResponse) PrintOut() {
|
|
|
|
|
if r.Code == 0 {
|
|
|
|
|
segmentsRaw := r.Data["segments"].([]interface{})
|
|
|
|
|
segments := make([]map[string]interface{}, len(segmentsRaw))
|
|
|
|
|
for i, v := range segmentsRaw {
|
|
|
|
|
segments[i] = v.(map[string]interface{})
|
|
|
|
|
}
|
|
|
|
|
PrintTableSimpleByFormat(segments, r.OutputFormat)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("ERROR")
|
|
|
|
|
fmt.Printf("%d, %s\n", r.Code, r.Message)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-12 17:58:36 +08:00
|
|
|
type ExplainResponse struct {
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Duration float64
|
|
|
|
|
OutputFormat OutputFormat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ExplainResponse) Type() string {
|
|
|
|
|
return "explain"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ExplainResponse) TimeCost() float64 {
|
|
|
|
|
return r.Duration
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ExplainResponse) SetOutputFormat(format OutputFormat) {
|
|
|
|
|
r.OutputFormat = format
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *ExplainResponse) PrintOut() {
|
|
|
|
|
if r.Code == 0 {
|
|
|
|
|
fmt.Printf("\n%s\n", r.Message)
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf("ERROR %d\n", r.Code)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-09 17:00:10 +08:00
|
|
|
// FileSystemResponse wraps the raw text output from executeFilesystem().
|
|
|
|
|
type FileSystemResponse struct {
|
|
|
|
|
Output string
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
Duration float64
|
2026-04-07 11:30:09 +08:00
|
|
|
OutputFormat OutputFormat
|
Refactor Go server model provider reading and access (#13831)
### What problem does this PR solve?
1. Refactor model provider json file format
2. Use memory data structure to replace database
3. Add CLI command to access
```
RAGFlow(user)> list pool models from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
| map[] | 256000 | [llm] | grok-4 |
| map[] | 131072 | [llm] | grok-3 |
| map[] | 131072 | [llm] | grok-3-fast |
| map[] | 131072 | [llm] | grok-3-mini |
| map[] | 131072 | [llm] | grok-3-mini-mini-fast |
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+-----------------------+
RAGFlow(user)> show pool model 'grok-2-vision' from 'xai';
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| features | max_tokens | model_types | name |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
| map[multimodal:map[enabled:true input_modalities:[image] output_modalities:[text]]] | 32768 | [vlm] | grok-2-vision |
+-------------------------------------------------------------------------------------+------------+-------------+---------------+
RAGFlow(user)> list pool providers;
+--------+------------------------------------------------------------+---------------------------+
| name | tags | url |
+--------+------------------------------------------------------------+---------------------------+
| OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | https://api.openai.com/v1 |
| xAI | LLM | https://api.x.ai/v1 |
+--------+------------------------------------------------------------+---------------------------+
RAGFlow(user)> show pool provider 'openai';
+---------------------------+--------+------------------------------------------------------------+--------------+
| base_url | name | tags | total_models |
+---------------------------+--------+------------------------------------------------------------+--------------+
| https://api.openai.com/v1 | OpenAI | LLM,TEXT EMBEDDING,TTS,TEXT RE-RANK,SPEECH2TEXT,MODERATION | 27 |
+---------------------------+--------+------------------------------------------------------------+--------------+
```
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- [x] Refactoring
---------
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-03-30 12:00:49 +08:00
|
|
|
}
|
|
|
|
|
|
2026-06-09 17:00:10 +08:00
|
|
|
func (r *FileSystemResponse) Type() string { return "filesystem" }
|
|
|
|
|
func (r *FileSystemResponse) TimeCost() float64 { return r.Duration }
|
|
|
|
|
func (r *FileSystemResponse) SetOutputFormat(format OutputFormat) { r.OutputFormat = format }
|
|
|
|
|
func (r *FileSystemResponse) PrintOut() {
|
|
|
|
|
fmt.Print(r.Output)
|
2026-04-30 12:36:03 +08:00
|
|
|
}
|