diff --git a/neo/load.go b/neo/load.go index ef45f86a..34cf3704 100644 --- a/neo/load.go +++ b/neo/load.go @@ -38,7 +38,7 @@ func Load(cfg config.Config) error { Option: map[string]interface{}{}, Allows: []string{}, StoreSetting: store.Setting{ - Table: "yao_neo_conversation", + Prefix: "yao_neo_", Connector: "default", }, } diff --git a/neo/store/types.go b/neo/store/types.go index 925c5ecd..1d6a889b 100644 --- a/neo/store/types.go +++ b/neo/store/types.go @@ -5,7 +5,7 @@ package store type Setting struct { Connector string `json:"connector,omitempty"` // Name of the connector used to specify data storage method UserField string `json:"user_field,omitempty"` // User ID field name, defaults to "user_id" - Table string `json:"table,omitempty"` // Database table name + Prefix string `json:"prefix,omitempty"` // Database table name prefix MaxSize int `json:"max_size,omitempty" yaml:"max_size,omitempty"` // Maximum storage size limit TTL int `json:"ttl,omitempty" yaml:"ttl,omitempty"` // Time To Live in seconds } diff --git a/neo/store/xun.go b/neo/store/xun.go index 05c9c068..aadb4583 100644 --- a/neo/store/xun.go +++ b/neo/store/xun.go @@ -99,7 +99,7 @@ func (conv *Xun) clean() { } if nums > 0 { - log.Trace("Clean the conversation table: %s %d", conv.setting.Table, nums) + log.Trace("Clean the conversation table: %s %d", conv.setting.Prefix, nums) } } @@ -283,15 +283,15 @@ func (conv *Xun) getUserID(sid string) (string, error) { } func (conv *Xun) getHistoryTable() string { - return conv.setting.Table + "_history" + return conv.setting.Prefix + "history" } func (conv *Xun) getChatTable() string { - return conv.setting.Table + "_chat" + return conv.setting.Prefix + "chat" } func (conv *Xun) getAssistantTable() string { - return conv.setting.Table + "_assistant" + return conv.setting.Prefix + "assistant" } // UpdateChatTitle update the chat title diff --git a/neo/store/xun_test.go b/neo/store/xun_test.go index dc42de04..4dbd936a 100644 --- a/neo/store/xun_test.go +++ b/neo/store/xun_test.go @@ -40,7 +40,7 @@ func TestNewXunDefault(t *testing.T) { store, err := NewXun(Setting{ Connector: "default", - Table: "__unit_test_conversation", + Prefix: "__unit_test_conversation_", }) if err != nil { @@ -139,7 +139,7 @@ func TestNewXunConnector(t *testing.T) { store, err := NewXun(Setting{ Connector: "mysql", - Table: "__unit_test_conversation", + Prefix: "__unit_test_conversation_", }) if err != nil { @@ -201,7 +201,7 @@ func TestXunSaveAndGetHistory(t *testing.T) { store, err := NewXun(Setting{ Connector: "default", - Table: "__unit_test_conversation", + Prefix: "__unit_test_conversation_", TTL: 3600, }) @@ -239,7 +239,7 @@ func TestXunSaveAndGetHistoryWithCID(t *testing.T) { store, err := NewXun(Setting{ Connector: "default", - Table: "__unit_test_conversation", + Prefix: "__unit_test_conversation_", TTL: 3600, }) @@ -308,7 +308,7 @@ func TestXunGetChats(t *testing.T) { store, err := NewXun(Setting{ Connector: "default", - Table: "__unit_test_conversation", + Prefix: "__unit_test_conversation_", }) if err != nil { t.Fatal(err) @@ -364,7 +364,7 @@ func TestXunDeleteChat(t *testing.T) { store, err := NewXun(Setting{ Connector: "default", - Table: "__unit_test_conversation", + Prefix: "__unit_test_conversation_", }) if err != nil { t.Fatal(err) @@ -404,7 +404,7 @@ func TestXunDeleteAllChats(t *testing.T) { store, err := NewXun(Setting{ Connector: "default", - Table: "__unit_test_conversation", + Prefix: "__unit_test_conversation_", }) if err != nil { t.Fatal(err) @@ -455,7 +455,7 @@ func TestXunAssistantCRUD(t *testing.T) { store, err := NewXun(Setting{ Connector: "default", - Table: "__unit_test_conversation", + Prefix: "__unit_test_conversation_", }) if err != nil { t.Fatal(err) @@ -926,7 +926,7 @@ func TestXunAssistantPagination(t *testing.T) { store, err := NewXun(Setting{ Connector: "default", - Table: "__unit_test_conversation", + Prefix: "__unit_test_conversation_", }) if err != nil { t.Fatal(err) @@ -1250,7 +1250,7 @@ func TestGetAssistantTags(t *testing.T) { store, err := NewXun(Setting{ Connector: "default", - Table: "__unit_test_conversation", + Prefix: "__unit_test_conversation_", }) if err != nil { t.Fatal(err)