mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-05-05 17:57:47 +08:00
RAGFlow go API server (#13240)
# RAGFlow Go Implementation Plan 🚀 This repository tracks the progress of porting RAGFlow to Go. We'll implement core features and provide performance comparisons between Python and Go versions. ## Implementation Checklist - [x] User Management APIs - [x] Dataset Management Operations - [x] Retrieval Test - [x] Chat Management Operations - [x] Infinity Go SDK --------- Signed-off-by: Jin Hai <haijin.chn@gmail.com> Co-authored-by: Yingfeng Zhang <yingfeng.zhang@gmail.com>
This commit is contained in:
54
internal/model/api.go
Normal file
54
internal/model/api.go
Normal file
@ -0,0 +1,54 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
// APIToken API token model
|
||||
type APIToken struct {
|
||||
TenantID string `gorm:"column:tenant_id;size:32;not null;primaryKey" json:"tenant_id"`
|
||||
Token string `gorm:"column:token;size:255;not null;primaryKey" json:"token"`
|
||||
DialogID *string `gorm:"column:dialog_id;size:32;index" json:"dialog_id,omitempty"`
|
||||
Source *string `gorm:"column:source;size:16;index" json:"source,omitempty"`
|
||||
Beta *string `gorm:"column:beta;size:255;index" json:"beta,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (APIToken) TableName() string {
|
||||
return "api_token"
|
||||
}
|
||||
|
||||
// API4Conversation API for conversation model
|
||||
type API4Conversation struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
DialogID string `gorm:"column:dialog_id;size:32;not null;index" json:"dialog_id"`
|
||||
UserID string `gorm:"column:user_id;size:255;not null;index" json:"user_id"`
|
||||
Message JSONMap `gorm:"column:message;type:json" json:"message,omitempty"`
|
||||
Reference JSONMap `gorm:"column:reference;type:json;default:'[]'" json:"reference"`
|
||||
Tokens int64 `gorm:"column:tokens;default:0" json:"tokens"`
|
||||
Source *string `gorm:"column:source;size:16;index" json:"source,omitempty"`
|
||||
DSL JSONMap `gorm:"column:dsl;type:json" json:"dsl,omitempty"`
|
||||
Duration float64 `gorm:"column:duration;default:0;index" json:"duration"`
|
||||
Round int64 `gorm:"column:round;default:0;index" json:"round"`
|
||||
ThumbUp int64 `gorm:"column:thumb_up;default:0;index" json:"thumb_up"`
|
||||
Errors *string `gorm:"column:errors;type:longtext" json:"errors,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (API4Conversation) TableName() string {
|
||||
return "api_4_conversation"
|
||||
}
|
||||
79
internal/model/base.go
Normal file
79
internal/model/base.go
Normal file
@ -0,0 +1,79 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
// BaseModel base model
|
||||
type BaseModel struct {
|
||||
CreateTime int64 `gorm:"column:create_time;index" json:"create_time"`
|
||||
CreateDate *time.Time `gorm:"column:create_date;index" json:"create_date,omitempty"`
|
||||
UpdateTime *int64 `gorm:"column:update_time;index" json:"update_time,omitempty"`
|
||||
UpdateDate *time.Time `gorm:"column:update_date;index" json:"update_date,omitempty"`
|
||||
}
|
||||
|
||||
// JSONMap is a map type that can store JSON data
|
||||
type JSONMap map[string]interface{}
|
||||
|
||||
// Value implements driver.Valuer interface
|
||||
func (j JSONMap) Value() (driver.Value, error) {
|
||||
if j == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return json.Marshal(j)
|
||||
}
|
||||
|
||||
// Scan implements sql.Scanner interface
|
||||
func (j *JSONMap) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
*j = nil
|
||||
return nil
|
||||
}
|
||||
b, ok := value.([]byte)
|
||||
if !ok {
|
||||
return json.Unmarshal([]byte(value.(string)), j)
|
||||
}
|
||||
return json.Unmarshal(b, j)
|
||||
}
|
||||
|
||||
// JSONSlice is a slice type that can store JSON array data
|
||||
type JSONSlice []interface{}
|
||||
|
||||
// Value implements driver.Valuer interface
|
||||
func (j JSONSlice) Value() (driver.Value, error) {
|
||||
if j == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return json.Marshal(j)
|
||||
}
|
||||
|
||||
// Scan implements sql.Scanner interface
|
||||
func (j *JSONSlice) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
*j = nil
|
||||
return nil
|
||||
}
|
||||
b, ok := value.([]byte)
|
||||
if !ok {
|
||||
return json.Unmarshal([]byte(value.(string)), j)
|
||||
}
|
||||
return json.Unmarshal(b, j)
|
||||
}
|
||||
68
internal/model/canvas.go
Normal file
68
internal/model/canvas.go
Normal file
@ -0,0 +1,68 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
// UserCanvas user canvas model
|
||||
type UserCanvas struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
Avatar *string `gorm:"column:avatar;type:longtext" json:"avatar,omitempty"`
|
||||
UserID string `gorm:"column:user_id;size:255;not null;index" json:"user_id"`
|
||||
Title *string `gorm:"column:title;size:255" json:"title,omitempty"`
|
||||
Permission string `gorm:"column:permission;size:16;not null;default:me;index" json:"permission"`
|
||||
Description *string `gorm:"column:description;type:longtext" json:"description,omitempty"`
|
||||
CanvasType *string `gorm:"column:canvas_type;size:32;index" json:"canvas_type,omitempty"`
|
||||
CanvasCategory string `gorm:"column:canvas_category;size:32;not null;default:agent_canvas;index" json:"canvas_category"`
|
||||
DSL JSONMap `gorm:"column:dsl;type:json" json:"dsl,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (UserCanvas) TableName() string {
|
||||
return "user_canvas"
|
||||
}
|
||||
|
||||
// CanvasTemplate canvas template model
|
||||
type CanvasTemplate struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
Avatar *string `gorm:"column:avatar;type:longtext" json:"avatar,omitempty"`
|
||||
Title JSONMap `gorm:"column:title;type:json;default:'{}'" json:"title"`
|
||||
Description JSONMap `gorm:"column:description;type:json;default:'{}'" json:"description"`
|
||||
CanvasType *string `gorm:"column:canvas_type;size:32;index" json:"canvas_type,omitempty"`
|
||||
CanvasCategory string `gorm:"column:canvas_category;size:32;not null;default:agent_canvas;index" json:"canvas_category"`
|
||||
DSL JSONMap `gorm:"column:dsl;type:json" json:"dsl,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (CanvasTemplate) TableName() string {
|
||||
return "canvas_template"
|
||||
}
|
||||
|
||||
// UserCanvasVersion user canvas version model
|
||||
type UserCanvasVersion struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
UserCanvasID string `gorm:"column:user_canvas_id;size:255;not null;index" json:"user_canvas_id"`
|
||||
Title *string `gorm:"column:title;size:255" json:"title,omitempty"`
|
||||
Description *string `gorm:"column:description;type:longtext" json:"description,omitempty"`
|
||||
DSL JSONMap `gorm:"column:dsl;type:json" json:"dsl,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (UserCanvasVersion) TableName() string {
|
||||
return "user_canvas_version"
|
||||
}
|
||||
64
internal/model/chat.go
Normal file
64
internal/model/chat.go
Normal file
@ -0,0 +1,64 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// Chat chat model (mapped to dialog table)
|
||||
type Chat struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
TenantID string `gorm:"column:tenant_id;size:32;not null;index" json:"tenant_id"`
|
||||
Name *string `gorm:"column:name;size:255;index" json:"name,omitempty"`
|
||||
Description *string `gorm:"column:description;type:longtext" json:"description,omitempty"`
|
||||
Icon *string `gorm:"column:icon;type:longtext" json:"icon,omitempty"`
|
||||
Language *string `gorm:"column:language;size:32;index" json:"language,omitempty"`
|
||||
LLMID string `gorm:"column:llm_id;size:128;not null" json:"llm_id"`
|
||||
LLMSetting JSONMap `gorm:"column:llm_setting;type:json;not null;default:'{\"temperature\":0.1,\"top_p\":0.3,\"frequency_penalty\":0.7,\"presence_penalty\":0.4,\"max_tokens\":512}'" json:"llm_setting"`
|
||||
PromptType string `gorm:"column:prompt_type;size:16;not null;default:simple;index" json:"prompt_type"`
|
||||
PromptConfig JSONMap `gorm:"column:prompt_config;type:json;not null;default:'{\"system\":\"\",\"prologue\":\"Hi! I'm your assistant. What can I do for you?\",\"parameters\":[],\"empty_response\":\"Sorry! No relevant content was found in the knowledge base!\"}'" json:"prompt_config"`
|
||||
MetaDataFilter *JSONMap `gorm:"column:meta_data_filter;type:json" json:"meta_data_filter,omitempty"`
|
||||
SimilarityThreshold float64 `gorm:"column:similarity_threshold;default:0.2" json:"similarity_threshold"`
|
||||
VectorSimilarityWeight float64 `gorm:"column:vector_similarity_weight;default:0.3" json:"vector_similarity_weight"`
|
||||
TopN int64 `gorm:"column:top_n;default:6" json:"top_n"`
|
||||
TopK int64 `gorm:"column:top_k;default:1024" json:"top_k"`
|
||||
DoRefer string `gorm:"column:do_refer;size:1;not null;default:1" json:"do_refer"`
|
||||
RerankID string `gorm:"column:rerank_id;size:128;not null;default:''" json:"rerank_id"`
|
||||
KBIDs JSONSlice `gorm:"column:kb_ids;type:json;not null;default:'[]'" json:"kb_ids"`
|
||||
Status *string `gorm:"column:status;size:1;index" json:"status,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (Chat) TableName() string {
|
||||
return "dialog"
|
||||
}
|
||||
|
||||
// Conversation conversation model
|
||||
type ChatSession struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
DialogID string `gorm:"column:dialog_id;size:32;not null;index" json:"dialog_id"`
|
||||
Name *string `gorm:"column:name;size:255;index" json:"name,omitempty"`
|
||||
Message json.RawMessage `gorm:"column:message;type:json" json:"message,omitempty"`
|
||||
Reference json.RawMessage `gorm:"column:reference;type:json;default:'[]'" json:"reference"`
|
||||
UserID *string `gorm:"column:user_id;size:255;index" json:"user_id,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (ChatSession) TableName() string {
|
||||
return "conversation"
|
||||
}
|
||||
78
internal/model/connector.go
Normal file
78
internal/model/connector.go
Normal file
@ -0,0 +1,78 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
import "time"
|
||||
|
||||
// Connector connector model
|
||||
type Connector struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
TenantID string `gorm:"column:tenant_id;size:32;not null;index" json:"tenant_id"`
|
||||
Name string `gorm:"column:name;size:128;not null" json:"name"`
|
||||
Source string `gorm:"column:source;size:128;not null;index" json:"source"`
|
||||
InputType string `gorm:"column:input_type;size:128;not null;index" json:"input_type"`
|
||||
Config JSONMap `gorm:"column:config;type:json;not null;default:'{}'" json:"config"`
|
||||
RefreshFreq int64 `gorm:"column:refresh_freq;default:0" json:"refresh_freq"`
|
||||
PruneFreq int64 `gorm:"column:prune_freq;default:0" json:"prune_freq"`
|
||||
TimeoutSecs int64 `gorm:"column:timeout_secs;default:3600" json:"timeout_secs"`
|
||||
IndexingStart *time.Time `gorm:"column:indexing_start;index" json:"indexing_start,omitempty"`
|
||||
Status string `gorm:"column:status;size:16;not null;default:schedule;index" json:"status"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (Connector) TableName() string {
|
||||
return "connector"
|
||||
}
|
||||
|
||||
// Connector2Kb connector to knowledge base mapping model
|
||||
type Connector2Kb struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
ConnectorID string `gorm:"column:connector_id;size:32;not null;index" json:"connector_id"`
|
||||
KbID string `gorm:"column:kb_id;size:32;not null;index" json:"kb_id"`
|
||||
AutoParse string `gorm:"column:auto_parse;size:1;not null;default:1" json:"auto_parse"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (Connector2Kb) TableName() string {
|
||||
return "connector2kb"
|
||||
}
|
||||
|
||||
// SyncLogs sync logs model
|
||||
type SyncLogs struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
ConnectorID string `gorm:"column:connector_id;size:32;index" json:"connector_id"`
|
||||
Status string `gorm:"column:status;size:128;not null;index" json:"status"`
|
||||
FromBeginning *string `gorm:"column:from_beginning;size:1" json:"from_beginning,omitempty"`
|
||||
NewDocsIndexed int64 `gorm:"column:new_docs_indexed;default:0" json:"new_docs_indexed"`
|
||||
TotalDocsIndexed int64 `gorm:"column:total_docs_indexed;default:0" json:"total_docs_indexed"`
|
||||
DocsRemovedFromIndex int64 `gorm:"column:docs_removed_from_index;default:0" json:"docs_removed_from_index"`
|
||||
ErrorMsg string `gorm:"column:error_msg;type:longtext;not null;default:''" json:"error_msg"`
|
||||
ErrorCount int64 `gorm:"column:error_count;default:0" json:"error_count"`
|
||||
FullExceptionTrace *string `gorm:"column:full_exception_trace;type:longtext" json:"full_exception_trace,omitempty"`
|
||||
TimeStarted *time.Time `gorm:"column:time_started;index" json:"time_started,omitempty"`
|
||||
PollRangeStart *string `gorm:"column:poll_range_start;size:255;index" json:"poll_range_start,omitempty"`
|
||||
PollRangeEnd *string `gorm:"column:poll_range_end;size:255;index" json:"poll_range_end,omitempty"`
|
||||
KbID string `gorm:"column:kb_id;size:32;not null;index" json:"kb_id"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (SyncLogs) TableName() string {
|
||||
return "sync_logs"
|
||||
}
|
||||
51
internal/model/document.go
Normal file
51
internal/model/document.go
Normal file
@ -0,0 +1,51 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
import "time"
|
||||
|
||||
// Document document model
|
||||
type Document struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
Thumbnail *string `gorm:"column:thumbnail;type:longtext" json:"thumbnail,omitempty"`
|
||||
KbID string `gorm:"column:kb_id;size:256;not null;index" json:"kb_id"`
|
||||
ParserID string `gorm:"column:parser_id;size:32;not null;index" json:"parser_id"`
|
||||
PipelineID *string `gorm:"column:pipeline_id;size:32;index" json:"pipeline_id,omitempty"`
|
||||
ParserConfig JSONMap `gorm:"column:parser_config;type:json;not null;default:'{\"pages\":[[1,1000000]],\"table_context_size\":0,\"image_context_size\":0}'" json:"parser_config"`
|
||||
SourceType string `gorm:"column:source_type;size:128;not null;default:local;index" json:"source_type"`
|
||||
Type string `gorm:"column:type;size:32;not null;index" json:"type"`
|
||||
CreatedBy string `gorm:"column:created_by;size:32;not null;index" json:"created_by"`
|
||||
Name *string `gorm:"column:name;size:255;index" json:"name,omitempty"`
|
||||
Location *string `gorm:"column:location;size:255;index" json:"location,omitempty"`
|
||||
Size int64 `gorm:"column:size;default:0;index" json:"size"`
|
||||
TokenNum int64 `gorm:"column:token_num;default:0;index" json:"token_num"`
|
||||
ChunkNum int64 `gorm:"column:chunk_num;default:0;index" json:"chunk_num"`
|
||||
Progress float64 `gorm:"column:progress;default:0;index" json:"progress"`
|
||||
ProgressMsg *string `gorm:"column:progress_msg;type:longtext" json:"progress_msg,omitempty"`
|
||||
ProcessBeginAt *time.Time `gorm:"column:process_begin_at;index" json:"process_begin_at,omitempty"`
|
||||
ProcessDuration float64 `gorm:"column:process_duration;default:0" json:"process_duration"`
|
||||
MetaFields *JSONMap `gorm:"column:meta_fields;type:json" json:"meta_fields,omitempty"`
|
||||
Suffix string `gorm:"column:suffix;size:32;not null;index" json:"suffix"`
|
||||
Run *string `gorm:"column:run;size:1;index" json:"run,omitempty"`
|
||||
Status *string `gorm:"column:status;size:1;index" json:"status,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (Document) TableName() string {
|
||||
return "document"
|
||||
}
|
||||
87
internal/model/evaluation.go
Normal file
87
internal/model/evaluation.go
Normal file
@ -0,0 +1,87 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
// EvaluationDataset evaluation dataset model
|
||||
type EvaluationDataset struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
TenantID string `gorm:"column:tenant_id;size:32;not null;index" json:"tenant_id"`
|
||||
Name string `gorm:"column:name;size:255;not null;index" json:"name"`
|
||||
Description *string `gorm:"column:description;type:longtext" json:"description,omitempty"`
|
||||
KbIDs JSONMap `gorm:"column:kb_ids;type:json;not null" json:"kb_ids"`
|
||||
CreatedBy string `gorm:"column:created_by;size:32;not null;index" json:"created_by"`
|
||||
Status int64 `gorm:"column:status;default:1;index" json:"status"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (EvaluationDataset) TableName() string {
|
||||
return "evaluation_datasets"
|
||||
}
|
||||
|
||||
// EvaluationCase evaluation case model
|
||||
type EvaluationCase struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
DatasetID string `gorm:"column:dataset_id;size:32;not null;index" json:"dataset_id"`
|
||||
Question string `gorm:"column:question;type:longtext;not null" json:"question"`
|
||||
ReferenceAnswer *string `gorm:"column:reference_answer;type:longtext" json:"reference_answer,omitempty"`
|
||||
RelevantDocIDs *JSONMap `gorm:"column:relevant_doc_ids;type:json" json:"relevant_doc_ids,omitempty"`
|
||||
RelevantChunkIDs *JSONMap `gorm:"column:relevant_chunk_ids;type:json" json:"relevant_chunk_ids,omitempty"`
|
||||
Metadata *JSONMap `gorm:"column:metadata;type:json" json:"metadata,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (EvaluationCase) TableName() string {
|
||||
return "evaluation_cases"
|
||||
}
|
||||
|
||||
// EvaluationRun evaluation run model
|
||||
type EvaluationRun struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
DatasetID string `gorm:"column:dataset_id;size:32;not null;index" json:"dataset_id"`
|
||||
DialogID string `gorm:"column:dialog_id;size:32;not null;index" json:"dialog_id"`
|
||||
Name string `gorm:"column:name;size:255;not null" json:"name"`
|
||||
ConfigSnapshot JSONMap `gorm:"column:config_snapshot;type:json;not null" json:"config_snapshot"`
|
||||
MetricsSummary *JSONMap `gorm:"column:metrics_summary;type:json" json:"metrics_summary,omitempty"`
|
||||
Status string `gorm:"column:status;size:32;not null;default:PENDING" json:"status"`
|
||||
CreatedBy string `gorm:"column:created_by;size:32;not null;index" json:"created_by"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (EvaluationRun) TableName() string {
|
||||
return "evaluation_runs"
|
||||
}
|
||||
|
||||
// EvaluationResult evaluation result model
|
||||
type EvaluationResult struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
RunID string `gorm:"column:run_id;size:32;not null;index" json:"run_id"`
|
||||
CaseID string `gorm:"column:case_id;size:32;not null;index" json:"case_id"`
|
||||
GeneratedAnswer string `gorm:"column:generated_answer;type:longtext;not null" json:"generated_answer"`
|
||||
RetrievedChunks JSONMap `gorm:"column:retrieved_chunks;type:json;not null" json:"retrieved_chunks"`
|
||||
Metrics JSONMap `gorm:"column:metrics;type:json;not null" json:"metrics"`
|
||||
ExecutionTime float64 `gorm:"column:execution_time;not null" json:"execution_time"`
|
||||
TokenUsage *JSONMap `gorm:"column:token_usage;type:json" json:"token_usage,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (EvaluationResult) TableName() string {
|
||||
return "evaluation_results"
|
||||
}
|
||||
49
internal/model/file.go
Normal file
49
internal/model/file.go
Normal file
@ -0,0 +1,49 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
// File file model
|
||||
type File struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
ParentID string `gorm:"column:parent_id;size:32;not null;index" json:"parent_id"`
|
||||
TenantID string `gorm:"column:tenant_id;size:32;not null;index" json:"tenant_id"`
|
||||
CreatedBy string `gorm:"column:created_by;size:32;not null;index" json:"created_by"`
|
||||
Name string `gorm:"column:name;size:255;not null;index" json:"name"`
|
||||
Location *string `gorm:"column:location;size:255;index" json:"location,omitempty"`
|
||||
Size int64 `gorm:"column:size;default:0;index" json:"size"`
|
||||
Type string `gorm:"column:type;size:32;not null;index" json:"type"`
|
||||
SourceType string `gorm:"column:source_type;size:128;not null;default:'';index" json:"source_type"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (File) TableName() string {
|
||||
return "file"
|
||||
}
|
||||
|
||||
// File2Document file to document mapping model
|
||||
type File2Document struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
FileID *string `gorm:"column:file_id;size:32;index" json:"file_id,omitempty"`
|
||||
DocumentID *string `gorm:"column:document_id;size:32;index" json:"document_id,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (File2Document) TableName() string {
|
||||
return "file2document"
|
||||
}
|
||||
70
internal/model/kb.go
Normal file
70
internal/model/kb.go
Normal file
@ -0,0 +1,70 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
import "time"
|
||||
|
||||
// Knowledgebase knowledge base model
|
||||
type Knowledgebase struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
Avatar *string `gorm:"column:avatar;type:longtext" json:"avatar,omitempty"`
|
||||
TenantID string `gorm:"column:tenant_id;size:32;not null;index" json:"tenant_id"`
|
||||
Name string `gorm:"column:name;size:128;not null;index" json:"name"`
|
||||
Language *string `gorm:"column:language;size:32;index" json:"language,omitempty"`
|
||||
Description *string `gorm:"column:description;type:longtext" json:"description,omitempty"`
|
||||
EmbdID string `gorm:"column:embd_id;size:128;not null;index" json:"embd_id"`
|
||||
Permission string `gorm:"column:permission;size:16;not null;default:me;index" json:"permission"`
|
||||
CreatedBy string `gorm:"column:created_by;size:32;not null;index" json:"created_by"`
|
||||
DocNum int64 `gorm:"column:doc_num;default:0;index" json:"doc_num"`
|
||||
TokenNum int64 `gorm:"column:token_num;default:0;index" json:"token_num"`
|
||||
ChunkNum int64 `gorm:"column:chunk_num;default:0;index" json:"chunk_num"`
|
||||
SimilarityThreshold float64 `gorm:"column:similarity_threshold;default:0.2;index" json:"similarity_threshold"`
|
||||
VectorSimilarityWeight float64 `gorm:"column:vector_similarity_weight;default:0.3;index" json:"vector_similarity_weight"`
|
||||
ParserID string `gorm:"column:parser_id;size:32;not null;default:naive;index" json:"parser_id"`
|
||||
PipelineID *string `gorm:"column:pipeline_id;size:32;index" json:"pipeline_id,omitempty"`
|
||||
ParserConfig JSONMap `gorm:"column:parser_config;type:json;not null;default:'{\"pages\":[[1,1000000]],\"table_context_size\":0,\"image_context_size\":0}'" json:"parser_config"`
|
||||
Pagerank int64 `gorm:"column:pagerank;default:0" json:"pagerank"`
|
||||
GraphragTaskID *string `gorm:"column:graphrag_task_id;size:32;index" json:"graphrag_task_id,omitempty"`
|
||||
GraphragTaskFinishAt *time.Time `gorm:"column:graphrag_task_finish_at" json:"graphrag_task_finish_at,omitempty"`
|
||||
RaptorTaskID *string `gorm:"column:raptor_task_id;size:32;index" json:"raptor_task_id,omitempty"`
|
||||
RaptorTaskFinishAt *time.Time `gorm:"column:raptor_task_finish_at" json:"raptor_task_finish_at,omitempty"`
|
||||
MindmapTaskID *string `gorm:"column:mindmap_task_id;size:32;index" json:"mindmap_task_id,omitempty"`
|
||||
MindmapTaskFinishAt *time.Time `gorm:"column:mindmap_task_finish_at" json:"mindmap_task_finish_at,omitempty"`
|
||||
Status *string `gorm:"column:status;size:1;index" json:"status,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (Knowledgebase) TableName() string {
|
||||
return "knowledgebase"
|
||||
}
|
||||
|
||||
// InvitationCode invitation code model
|
||||
type InvitationCode struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
Code string `gorm:"column:code;size:32;not null;index" json:"code"`
|
||||
VisitTime *time.Time `gorm:"column:visit_time;index" json:"visit_time,omitempty"`
|
||||
UserID *string `gorm:"column:user_id;size:32;index" json:"user_id,omitempty"`
|
||||
TenantID *string `gorm:"column:tenant_id;size:32;index" json:"tenant_id,omitempty"`
|
||||
Status *string `gorm:"column:status;size:1;index" json:"status,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (InvitationCode) TableName() string {
|
||||
return "invitation_code"
|
||||
}
|
||||
76
internal/model/llm.go
Normal file
76
internal/model/llm.go
Normal file
@ -0,0 +1,76 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
// LLMFactories LLM factory model
|
||||
type LLMFactories struct {
|
||||
Name string `gorm:"column:name;primaryKey;size:128" json:"name"`
|
||||
Logo *string `gorm:"column:logo;type:longtext" json:"logo,omitempty"`
|
||||
Tags string `gorm:"column:tags;size:255;not null;index" json:"tags"`
|
||||
Rank int64 `gorm:"column:rank;default:0" json:"rank"`
|
||||
Status *string `gorm:"column:status;size:1;index" json:"status,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (LLMFactories) TableName() string {
|
||||
return "llm_factories"
|
||||
}
|
||||
|
||||
// LLM LLM model
|
||||
type LLM struct {
|
||||
LLMName string `gorm:"column:llm_name;size:128;not null;primaryKey" json:"llm_name"`
|
||||
ModelType string `gorm:"column:model_type;size:128;not null;index" json:"model_type"`
|
||||
FID string `gorm:"column:fid;size:128;not null;primaryKey" json:"fid"`
|
||||
MaxTokens int64 `gorm:"column:max_tokens;default:0" json:"max_tokens"`
|
||||
Tags string `gorm:"column:tags;size:255;not null;index" json:"tags"`
|
||||
IsTools bool `gorm:"column:is_tools;default:false" json:"is_tools"`
|
||||
Status *string `gorm:"column:status;size:1;index" json:"status,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (LLM) TableName() string {
|
||||
return "llm"
|
||||
}
|
||||
|
||||
// TenantLangfuse tenant langfuse model
|
||||
type TenantLangfuse struct {
|
||||
TenantID string `gorm:"column:tenant_id;primaryKey;size:32" json:"tenant_id"`
|
||||
SecretKey string `gorm:"column:secret_key;size:2048;not null;index" json:"secret_key"`
|
||||
PublicKey string `gorm:"column:public_key;size:2048;not null;index" json:"public_key"`
|
||||
Host string `gorm:"column:host;size:128;not null;index" json:"host"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (TenantLangfuse) TableName() string {
|
||||
return "tenant_langfuse"
|
||||
}
|
||||
|
||||
// MyLLM represents LLM information for a tenant with factory details
|
||||
type MyLLM struct {
|
||||
LLMFactory string `gorm:"column:llm_factory" json:"llm_factory"`
|
||||
Logo *string `gorm:"column:logo" json:"logo,omitempty"`
|
||||
Tags string `gorm:"column:tags" json:"tags"`
|
||||
ModelType string `gorm:"column:model_type" json:"model_type"`
|
||||
LLMName string `gorm:"column:llm_name" json:"llm_name"`
|
||||
UsedTokens int64 `gorm:"column:used_tokens" json:"used_tokens"`
|
||||
Status string `gorm:"column:status" json:"status"`
|
||||
APIBase string `gorm:"column:api_base" json:"api_base,omitempty"`
|
||||
MaxTokens int64 `gorm:"column:max_tokens" json:"max_tokens,omitempty"`
|
||||
}
|
||||
35
internal/model/mcp.go
Normal file
35
internal/model/mcp.go
Normal file
@ -0,0 +1,35 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
// MCPServer MCP server model
|
||||
type MCPServer struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
Name string `gorm:"column:name;size:255;not null" json:"name"`
|
||||
TenantID string `gorm:"column:tenant_id;size:32;not null;index" json:"tenant_id"`
|
||||
URL string `gorm:"column:url;size:2048;not null" json:"url"`
|
||||
ServerType string `gorm:"column:server_type;size:32;not null" json:"server_type"`
|
||||
Description *string `gorm:"column:description;type:longtext" json:"description,omitempty"`
|
||||
Variables JSONMap `gorm:"column:variables;type:json;default:'{}'" json:"variables,omitempty"`
|
||||
Headers JSONMap `gorm:"column:headers;type:json;default:'{}'" json:"headers,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (MCPServer) TableName() string {
|
||||
return "mcp_server"
|
||||
}
|
||||
42
internal/model/memory.go
Normal file
42
internal/model/memory.go
Normal file
@ -0,0 +1,42 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
// Memory memory model
|
||||
type Memory struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
Name string `gorm:"column:name;size:128;not null" json:"name"`
|
||||
Avatar *string `gorm:"column:avatar;type:longtext" json:"avatar,omitempty"`
|
||||
TenantID string `gorm:"column:tenant_id;size:32;not null;index" json:"tenant_id"`
|
||||
MemoryType int64 `gorm:"column:memory_type;default:1;index" json:"memory_type"`
|
||||
StorageType string `gorm:"column:storage_type;size:32;not null;default:table;index" json:"storage_type"`
|
||||
EmbdID string `gorm:"column:embd_id;size:128;not null" json:"embd_id"`
|
||||
LLMID string `gorm:"column:llm_id;size:128;not null" json:"llm_id"`
|
||||
Permissions string `gorm:"column:permissions;size:16;not null;default:me;index" json:"permissions"`
|
||||
Description *string `gorm:"column:description;type:longtext" json:"description,omitempty"`
|
||||
MemorySize int64 `gorm:"column:memory_size;default:5242880;not null" json:"memory_size"`
|
||||
ForgettingPolicy string `gorm:"column:forgetting_policy;size:32;not null;default:FIFO" json:"forgetting_policy"`
|
||||
Temperature float64 `gorm:"column:temperature;default:0.5;not null" json:"temperature"`
|
||||
SystemPrompt *string `gorm:"column:system_prompt;type:longtext" json:"system_prompt,omitempty"`
|
||||
UserPrompt *string `gorm:"column:user_prompt;type:longtext" json:"user_prompt,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (Memory) TableName() string {
|
||||
return "memory"
|
||||
}
|
||||
49
internal/model/pipeline.go
Normal file
49
internal/model/pipeline.go
Normal file
@ -0,0 +1,49 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
import "time"
|
||||
|
||||
// PipelineOperationLog pipeline operation log model
|
||||
type PipelineOperationLog struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
DocumentID string `gorm:"column:document_id;size:32;index" json:"document_id"`
|
||||
TenantID string `gorm:"column:tenant_id;size:32;not null;index" json:"tenant_id"`
|
||||
KbID string `gorm:"column:kb_id;size:32;not null;index" json:"kb_id"`
|
||||
PipelineID *string `gorm:"column:pipeline_id;size:32;index" json:"pipeline_id,omitempty"`
|
||||
PipelineTitle *string `gorm:"column:pipeline_title;size:32;index" json:"pipeline_title,omitempty"`
|
||||
ParserID string `gorm:"column:parser_id;size:32;not null;index" json:"parser_id"`
|
||||
DocumentName string `gorm:"column:document_name;size:255;not null" json:"document_name"`
|
||||
DocumentSuffix string `gorm:"column:document_suffix;size:255;not null" json:"document_suffix"`
|
||||
DocumentType string `gorm:"column:document_type;size:255;not null" json:"document_type"`
|
||||
SourceFrom string `gorm:"column:source_from;size:255;not null" json:"source_from"`
|
||||
Progress float64 `gorm:"column:progress;default:0;index" json:"progress"`
|
||||
ProgressMsg *string `gorm:"column:progress_msg;type:longtext" json:"progress_msg,omitempty"`
|
||||
ProcessBeginAt *time.Time `gorm:"column:process_begin_at;index" json:"process_begin_at,omitempty"`
|
||||
ProcessDuration float64 `gorm:"column:process_duration;default:0" json:"process_duration"`
|
||||
DSL JSONMap `gorm:"column:dsl;type:json" json:"dsl,omitempty"`
|
||||
TaskType string `gorm:"column:task_type;size:32;not null;default:''" json:"task_type"`
|
||||
OperationStatus string `gorm:"column:operation_status;size:32;not null" json:"operation_status"`
|
||||
Avatar *string `gorm:"column:avatar;type:longtext" json:"avatar,omitempty"`
|
||||
Status *string `gorm:"column:status;size:1;index" json:"status,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (PipelineOperationLog) TableName() string {
|
||||
return "pipeline_operation_log"
|
||||
}
|
||||
35
internal/model/search.go
Normal file
35
internal/model/search.go
Normal file
@ -0,0 +1,35 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
// Search search model
|
||||
type Search struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
Avatar *string `gorm:"column:avatar;type:longtext" json:"avatar,omitempty"`
|
||||
TenantID string `gorm:"column:tenant_id;size:32;not null;index" json:"tenant_id"`
|
||||
Name string `gorm:"column:name;size:128;not null;index" json:"name"`
|
||||
Description *string `gorm:"column:description;type:longtext" json:"description,omitempty"`
|
||||
CreatedBy string `gorm:"column:created_by;size:32;not null;index" json:"created_by"`
|
||||
SearchConfig JSONMap `gorm:"column:search_config;type:json;not null;default:'{\"kb_ids\":[],\"doc_ids\":[],\"similarity_threshold\":0.2,\"vector_similarity_weight\":0.3,\"use_kg\":false,\"rerank_id\":\"\",\"top_k\":1024,\"summary\":false,\"chat_id\":\"\",\"chat_settingcross_languages\":[],\"highlight\":false,\"keyword\":false,\"web_search\":false,\"related_search\":false,\"query_mindmap\":false}'" json:"search_config"`
|
||||
Status *string `gorm:"column:status;size:1;index" json:"status,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (Search) TableName() string {
|
||||
return "search"
|
||||
}
|
||||
30
internal/model/system.go
Normal file
30
internal/model/system.go
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
// SystemSettings system settings model
|
||||
type SystemSettings struct {
|
||||
Name string `gorm:"column:name;primaryKey;size:128" json:"name"`
|
||||
Source string `gorm:"column:source;size:32;not null" json:"source"`
|
||||
DataType string `gorm:"column:data_type;size:32;not null" json:"data_type"`
|
||||
Value string `gorm:"column:value;size:1024;not null" json:"value"`
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (SystemSettings) TableName() string {
|
||||
return "system_settings"
|
||||
}
|
||||
42
internal/model/task.go
Normal file
42
internal/model/task.go
Normal file
@ -0,0 +1,42 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
import "time"
|
||||
|
||||
// Task task model
|
||||
type Task struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
DocID string `gorm:"column:doc_id;size:32;not null;index" json:"doc_id"`
|
||||
FromPage int64 `gorm:"column:from_page;default:0" json:"from_page"`
|
||||
ToPage int64 `gorm:"column:to_page;default:100000000" json:"to_page"`
|
||||
TaskType string `gorm:"column:task_type;size:32;not null;default:''" json:"task_type"`
|
||||
Priority int64 `gorm:"column:priority;default:0" json:"priority"`
|
||||
BeginAt *time.Time `gorm:"column:begin_at;index" json:"begin_at,omitempty"`
|
||||
ProcessDuration float64 `gorm:"column:process_duration;default:0" json:"process_duration"`
|
||||
Progress float64 `gorm:"column:progress;default:0;index" json:"progress"`
|
||||
ProgressMsg *string `gorm:"column:progress_msg;type:longtext" json:"progress_msg,omitempty"`
|
||||
RetryCount int64 `gorm:"column:retry_count;default:0" json:"retry_count"`
|
||||
Digest *string `gorm:"column:digest;type:longtext" json:"digest,omitempty"`
|
||||
ChunkIDs *string `gorm:"column:chunk_ids;type:longtext" json:"chunk_ids,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (Task) TableName() string {
|
||||
return "task"
|
||||
}
|
||||
39
internal/model/tenant.go
Normal file
39
internal/model/tenant.go
Normal file
@ -0,0 +1,39 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
// Tenant tenant model
|
||||
type Tenant struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
Name *string `gorm:"column:name;size:100;index" json:"name,omitempty"`
|
||||
PublicKey *string `gorm:"column:public_key;size:255;index" json:"public_key,omitempty"`
|
||||
LLMID string `gorm:"column:llm_id;size:128;not null;index" json:"llm_id"`
|
||||
EmbDID string `gorm:"column:embd_id;size:128;not null;index" json:"embd_id"`
|
||||
ASRID string `gorm:"column:asr_id;size:128;not null;index" json:"asr_id"`
|
||||
Img2TxtID string `gorm:"column:img2txt_id;size:128;not null;index" json:"img2txt_id"`
|
||||
RerankID string `gorm:"column:rerank_id;size:128;not null;index" json:"rerank_id"`
|
||||
TTSID *string `gorm:"column:tts_id;size:256;index" json:"tts_id,omitempty"`
|
||||
ParserIDs string `gorm:"column:parser_ids;size:256;not null" json:"parser_ids"`
|
||||
Credit int64 `gorm:"column:credit;default:512;index" json:"credit"`
|
||||
Status *string `gorm:"column:status;size:1;index" json:"status,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (Tenant) TableName() string {
|
||||
return "tenant"
|
||||
}
|
||||
36
internal/model/tenant_llm.go
Normal file
36
internal/model/tenant_llm.go
Normal file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
// TenantLLM tenant LLM model
|
||||
type TenantLLM struct {
|
||||
TenantID string `gorm:"column:tenant_id;size:32;not null;primaryKey" json:"tenant_id"`
|
||||
LLMFactory string `gorm:"column:llm_factory;size:128;not null;primaryKey" json:"llm_factory"`
|
||||
ModelType string `gorm:"column:model_type;size:128;not null;index" json:"model_type"`
|
||||
LLMName string `gorm:"column:llm_name;size:128;not null;primaryKey;default:\"\"" json:"llm_name"`
|
||||
APIKey string `gorm:"column:api_key;type:longtext" json:"api_key,omitempty"`
|
||||
APIBase string `gorm:"column:api_base;size:255" json:"api_base,omitempty"`
|
||||
MaxTokens int64 `gorm:"column:max_tokens;default:8192;index" json:"max_tokens"`
|
||||
UsedTokens int64 `gorm:"column:used_tokens;default:0;index" json:"used_tokens"`
|
||||
Status string `gorm:"column:status;size:1;not null;default:1;index" json:"status"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (TenantLLM) TableName() string {
|
||||
return "tenant_llm"
|
||||
}
|
||||
71
internal/model/types.go
Normal file
71
internal/model/types.go
Normal file
@ -0,0 +1,71 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
// ModelType represents the type of model
|
||||
type ModelType string
|
||||
|
||||
const (
|
||||
// ModelTypeChat chat model
|
||||
ModelTypeChat ModelType = "chat"
|
||||
// ModelTypeEmbedding embedding model
|
||||
ModelTypeEmbedding ModelType = "embedding"
|
||||
// ModelTypeSpeech2Text speech to text model
|
||||
ModelTypeSpeech2Text ModelType = "speech2text"
|
||||
// ModelTypeImage2Text image to text model
|
||||
ModelTypeImage2Text ModelType = "image2text"
|
||||
// ModelTypeRerank rerank model
|
||||
ModelTypeRerank ModelType = "rerank"
|
||||
// ModelTypeTTS text to speech model
|
||||
ModelTypeTTS ModelType = "tts"
|
||||
// ModelTypeOCR optical character recognition model
|
||||
ModelTypeOCR ModelType = "ocr"
|
||||
)
|
||||
|
||||
// EmbeddingModel interface for embedding models
|
||||
type EmbeddingModel interface {
|
||||
// Encode encodes a list of texts into embeddings
|
||||
Encode(texts []string) ([][]float64, error)
|
||||
// EncodeQuery encodes a single query string into embedding
|
||||
EncodeQuery(query string) ([]float64, error)
|
||||
}
|
||||
|
||||
// ChatModel interface for chat models
|
||||
type ChatModel interface {
|
||||
// Chat sends a message and returns response
|
||||
Chat(system string, history []map[string]string, genConf map[string]interface{}) (string, error)
|
||||
// ChatStreamly sends a message and streams response
|
||||
ChatStreamly(system string, history []map[string]string, genConf map[string]interface{}) (<-chan string, error)
|
||||
}
|
||||
|
||||
// RerankModel interface for rerank models
|
||||
type RerankModel interface {
|
||||
// Similarity calculates similarity between query and texts
|
||||
Similarity(query string, texts []string) ([]float64, error)
|
||||
}
|
||||
|
||||
// ModelConfig represents configuration for a model
|
||||
type ModelConfig struct {
|
||||
TenantID string `json:"tenant_id"`
|
||||
LLMFactory string `json:"llm_factory"`
|
||||
ModelType ModelType `json:"model_type"`
|
||||
LLMName string `json:"llm_name"`
|
||||
APIKey string `json:"api_key"`
|
||||
APIBase string `json:"api_base"`
|
||||
MaxTokens int64 `json:"max_tokens"`
|
||||
IsTools bool `json:"is_tools"`
|
||||
}
|
||||
45
internal/model/user.go
Normal file
45
internal/model/user.go
Normal file
@ -0,0 +1,45 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
import "time"
|
||||
|
||||
// User user model
|
||||
type User struct {
|
||||
ID string `gorm:"column:id;size:32;primaryKey" json:"id"`
|
||||
AccessToken *string `gorm:"column:access_token;size:255;index" json:"access_token,omitempty"`
|
||||
Nickname string `gorm:"column:nickname;size:100;not null;index" json:"nickname"`
|
||||
Password *string `gorm:"column:password;size:255;index" json:"-"`
|
||||
Email string `gorm:"column:email;size:255;not null;index" json:"email"`
|
||||
Avatar *string `gorm:"column:avatar;type:longtext" json:"avatar,omitempty"`
|
||||
Language *string `gorm:"column:language;size:32;index" json:"language,omitempty"`
|
||||
ColorSchema *string `gorm:"column:color_schema;size:32;index" json:"color_schema,omitempty"`
|
||||
Timezone *string `gorm:"column:timezone;size:64;index" json:"timezone,omitempty"`
|
||||
LastLoginTime *time.Time `gorm:"column:last_login_time;index" json:"last_login_time,omitempty"`
|
||||
IsAuthenticated string `gorm:"column:is_authenticated;size:1;not null;default:1;index" json:"is_authenticated"`
|
||||
IsActive string `gorm:"column:is_active;size:1;not null;default:1;index" json:"is_active"`
|
||||
IsAnonymous string `gorm:"column:is_anonymous;size:1;not null;default:0;index" json:"is_anonymous"`
|
||||
LoginChannel *string `gorm:"column:login_channel;index" json:"login_channel,omitempty"`
|
||||
Status *string `gorm:"column:status;size:1;default:1;index" json:"status"`
|
||||
IsSuperuser *bool `gorm:"column:is_superuser;index" json:"is_superuser,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (User) TableName() string {
|
||||
return "user"
|
||||
}
|
||||
33
internal/model/user_tenant.go
Normal file
33
internal/model/user_tenant.go
Normal file
@ -0,0 +1,33 @@
|
||||
//
|
||||
// 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 model
|
||||
|
||||
// UserTenant user tenant relationship model
|
||||
type UserTenant struct {
|
||||
ID string `gorm:"column:id;primaryKey;size:32" json:"id"`
|
||||
UserID string `gorm:"column:user_id;size:32;not null;index" json:"user_id"`
|
||||
TenantID string `gorm:"column:tenant_id;size:32;not null;index" json:"tenant_id"`
|
||||
Role string `gorm:"column:role;size:32;not null;index" json:"role"`
|
||||
InvitedBy string `gorm:"column:invited_by;size:32;not null;index" json:"invited_by"`
|
||||
Status *string `gorm:"column:status;size:1;index" json:"status,omitempty"`
|
||||
BaseModel
|
||||
}
|
||||
|
||||
// TableName specify table name
|
||||
func (UserTenant) TableName() string {
|
||||
return "user_tenant"
|
||||
}
|
||||
Reference in New Issue
Block a user