Refactor AI Agent and AI Config handling across multiple files
- Updated function signatures to accept AI Agent and AI Config as non-pointer types for better clarity and safety. - Modified instances where AI Agent and AI Config were dereferenced to improve code readability. - Removed unnecessary nil checks for AI Agent and AI Config, simplifying the logic. - Adjusted related tests and services to align with the new function signatures. - Cleaned up code in runtime, skills, and executor packages to ensure consistency in handling AI configurations.
This commit is contained in:
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
type CreateTicketGraphTool struct {
|
||||
conversation *models.Conversation
|
||||
aiAgent *models.AIAgent
|
||||
aiAgent models.AIAgent
|
||||
}
|
||||
|
||||
func NewCreateTicketGraphTool() *CreateTicketGraphTool {
|
||||
@@ -37,7 +37,7 @@ func (t *CreateTicketGraphTool) Code() string {
|
||||
}
|
||||
|
||||
func (t *CreateTicketGraphTool) Enabled(ctx registry.Context) bool {
|
||||
return ctx.Conversation != nil && ctx.AIAgent != nil
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *CreateTicketGraphTool) Build(ctx registry.Context) (einotool.BaseTool, error) {
|
||||
@@ -100,7 +100,7 @@ func (t *CreateTicketGraphTool) Info(ctx context.Context) (*schema.ToolInfo, err
|
||||
}
|
||||
|
||||
func (t *CreateTicketGraphTool) InvokableRun(ctx context.Context, argumentsInJSON string, opts ...einotool.Option) (string, error) {
|
||||
if t == nil || t.conversation == nil || t.aiAgent == nil {
|
||||
if t == nil || t.conversation == nil {
|
||||
return "", fmt.Errorf("create ticket graph tool not initialized")
|
||||
}
|
||||
return graphs.NewCreateTicketGraph(t.conversation, t.aiAgent).Run(ctx, argumentsInJSON)
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
type HandoffGraphTool struct {
|
||||
conversation *models.Conversation
|
||||
aiAgent *models.AIAgent
|
||||
aiAgent models.AIAgent
|
||||
}
|
||||
|
||||
func NewHandoffGraphTool() *HandoffGraphTool {
|
||||
@@ -37,7 +37,7 @@ func (t *HandoffGraphTool) Code() string {
|
||||
}
|
||||
|
||||
func (t *HandoffGraphTool) Enabled(ctx registry.Context) bool {
|
||||
return ctx.Conversation != nil && ctx.AIAgent != nil
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *HandoffGraphTool) Build(ctx registry.Context) (einotool.BaseTool, error) {
|
||||
@@ -75,7 +75,7 @@ func (t *HandoffGraphTool) Info(ctx context.Context) (*schema.ToolInfo, error) {
|
||||
}
|
||||
|
||||
func (t *HandoffGraphTool) InvokableRun(ctx context.Context, argumentsInJSON string, opts ...einotool.Option) (string, error) {
|
||||
if t == nil || t.conversation == nil || t.aiAgent == nil {
|
||||
if t == nil || t.conversation == nil {
|
||||
return "", fmt.Errorf("handoff graph tool not initialized")
|
||||
}
|
||||
return graphs.NewHandoffGraph(t.conversation, t.aiAgent).Run(ctx, argumentsInJSON)
|
||||
|
||||
Reference in New Issue
Block a user