Refactor Assistant struct to replace Flows with Workflow and update cloning logic
- Replaced the Flows field in the Assistant struct with a Workflow field to better represent the assistant's functionality. - Updated the Clone method to perform a deep copy of the Workflow instead of Flows. - Adjusted related test cases to reflect the changes in the Assistant struct and ensure proper functionality.
This commit is contained in:
parent
1058598be3
commit
b97933e357
3 changed files with 33 additions and 37 deletions
|
|
@ -239,15 +239,11 @@ func (ast *Assistant) Clone() *Assistant {
|
|||
}
|
||||
}
|
||||
|
||||
// Deep copy flows
|
||||
if ast.Flows != nil {
|
||||
clone.Flows = make([]map[string]interface{}, len(ast.Flows))
|
||||
for i, flow := range ast.Flows {
|
||||
cloneFlow := make(map[string]interface{})
|
||||
for k, v := range flow {
|
||||
cloneFlow[k] = v
|
||||
}
|
||||
clone.Flows[i] = cloneFlow
|
||||
// Deep copy workflow
|
||||
if ast.Workflow != nil {
|
||||
clone.Workflow = make(map[string]interface{})
|
||||
for k, v := range ast.Workflow {
|
||||
clone.Workflow[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ func TestLoad_Clone(t *testing.T) {
|
|||
Automated: true,
|
||||
Options: map[string]interface{}{"key": "value"},
|
||||
Prompts: []Prompt{{Role: "system", Content: "test"}},
|
||||
Flows: []map[string]interface{}{{"step": "test"}},
|
||||
Workflow: map[string]interface{}{"step": "test"},
|
||||
}
|
||||
|
||||
// Clone the assistant
|
||||
|
|
@ -218,15 +218,15 @@ func TestLoad_Clone(t *testing.T) {
|
|||
assert.Equal(t, original.Automated, clone.Automated)
|
||||
assert.Equal(t, original.Options, clone.Options)
|
||||
assert.Equal(t, original.Prompts, clone.Prompts)
|
||||
assert.Equal(t, original.Flows, clone.Flows)
|
||||
assert.Equal(t, original.Workflow, clone.Workflow)
|
||||
|
||||
// Verify deep copy by modifying original
|
||||
original.Tags[0] = "modified"
|
||||
original.Options["key"] = "modified"
|
||||
original.Flows[0]["step"] = "modified"
|
||||
original.Workflow["step"] = "modified"
|
||||
assert.NotEqual(t, original.Tags[0], clone.Tags[0])
|
||||
assert.NotEqual(t, original.Options["key"], clone.Options["key"])
|
||||
assert.NotEqual(t, original.Flows[0]["step"], clone.Flows[0]["step"])
|
||||
assert.NotEqual(t, original.Workflow["step"], clone.Workflow["step"])
|
||||
|
||||
// Test nil case
|
||||
var nilAssistant *Assistant
|
||||
|
|
|
|||
|
|
@ -122,30 +122,30 @@ type QueryParam struct {
|
|||
|
||||
// Assistant the assistant
|
||||
type Assistant struct {
|
||||
ID string `json:"assistant_id"` // Assistant ID
|
||||
Type string `json:"type,omitempty"` // Assistant Type, default is assistant
|
||||
Name string `json:"name,omitempty"` // Assistant Name
|
||||
Avatar string `json:"avatar,omitempty"` // Assistant Avatar
|
||||
Connector string `json:"connector"` // AI Connector
|
||||
Path string `json:"path,omitempty"` // Assistant Path
|
||||
BuiltIn bool `json:"built_in,omitempty"` // Whether this is a built-in assistant
|
||||
Sort int `json:"sort,omitempty"` // Assistant Sort
|
||||
Description string `json:"description,omitempty"` // Assistant Description
|
||||
Tags []string `json:"tags,omitempty"` // Assistant Tags
|
||||
Readonly bool `json:"readonly,omitempty"` // Whether this assistant is readonly
|
||||
Mentionable bool `json:"mentionable,omitempty"` // Whether this assistant is mentionable
|
||||
Automated bool `json:"automated,omitempty"` // Whether this assistant is automated
|
||||
Options map[string]interface{} `json:"options,omitempty"` // AI Options
|
||||
Prompts []Prompt `json:"prompts,omitempty"` // AI Prompts
|
||||
Tools *ToolCalls `json:"tools,omitempty"` // Assistant Tools
|
||||
Flows []map[string]interface{} `json:"flows,omitempty"` // Assistant Flows
|
||||
Placeholder *Placeholder `json:"placeholder,omitempty"` // Assistant Placeholder
|
||||
Locales i18n.Map `json:"locales,omitempty"` // Assistant Locales
|
||||
Search *SearchOption `json:"search,omitempty" yaml:"search,omitempty"` // Whether this assistant supports search
|
||||
Knowledge *KnowledgeOption `json:"knowledge,omitempty" yaml:"knowledge,omitempty"` // Whether this assistant supports knowledge
|
||||
CreatedAt int64 `json:"created_at"` // Creation timestamp
|
||||
UpdatedAt int64 `json:"updated_at"` // Last update timestamp
|
||||
Script *v8.Script `json:"-" yaml:"-"` // Assistant Script
|
||||
ID string `json:"assistant_id"` // Assistant ID
|
||||
Type string `json:"type,omitempty"` // Assistant Type, default is assistant
|
||||
Name string `json:"name,omitempty"` // Assistant Name
|
||||
Avatar string `json:"avatar,omitempty"` // Assistant Avatar
|
||||
Connector string `json:"connector"` // AI Connector
|
||||
Path string `json:"path,omitempty"` // Assistant Path
|
||||
BuiltIn bool `json:"built_in,omitempty"` // Whether this is a built-in assistant
|
||||
Sort int `json:"sort,omitempty"` // Assistant Sort
|
||||
Description string `json:"description,omitempty"` // Assistant Description
|
||||
Tags []string `json:"tags,omitempty"` // Assistant Tags
|
||||
Readonly bool `json:"readonly,omitempty"` // Whether this assistant is readonly
|
||||
Mentionable bool `json:"mentionable,omitempty"` // Whether this assistant is mentionable
|
||||
Automated bool `json:"automated,omitempty"` // Whether this assistant is automated
|
||||
Options map[string]interface{} `json:"options,omitempty"` // AI Options
|
||||
Prompts []Prompt `json:"prompts,omitempty"` // AI Prompts
|
||||
Tools *ToolCalls `json:"tools,omitempty"` // Assistant Tools
|
||||
Workflow map[string]interface{} `json:"workflow,omitempty"` // Assistant Workflow
|
||||
Placeholder *Placeholder `json:"placeholder,omitempty"` // Assistant Placeholder
|
||||
Locales i18n.Map `json:"locales,omitempty"` // Assistant Locales
|
||||
Search *SearchOption `json:"search,omitempty" yaml:"search,omitempty"` // Whether this assistant supports search
|
||||
Knowledge *KnowledgeOption `json:"knowledge,omitempty" yaml:"knowledge,omitempty"` // Whether this assistant supports knowledge
|
||||
CreatedAt int64 `json:"created_at"` // Creation timestamp
|
||||
UpdatedAt int64 `json:"updated_at"` // Last update timestamp
|
||||
Script *v8.Script `json:"-" yaml:"-"` // Assistant Script
|
||||
|
||||
// Internal
|
||||
// ===============================
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue