From bf1ae9c01804c32dfdc1e4b066a89378eb8a8a62 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Thu, 12 Mar 2026 15:08:49 +0800 Subject: [PATCH] feat: enhance agent and user information structures - Added support for image attachments in agent Q&A requests, enabling multimodal chat capabilities. - Introduced a new UserInfo struct to represent user information in API responses, improving user data management. - Updated existing request structures to include image handling, enhancing the overall functionality of the chat system. These changes significantly improve the application's ability to handle multimodal interactions and manage user data effectively. --- client/agent.go | 21 +++++++++++---------- client/organization.go | 13 +++++++++++++ client/session.go | 26 ++++++++++++++++++-------- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/client/agent.go b/client/agent.go index f669f4f5..f3773ac2 100644 --- a/client/agent.go +++ b/client/agent.go @@ -22,16 +22,17 @@ type MentionedItem struct { // AgentQARequest agent Q&A request payload. type AgentQARequest struct { - Query string `json:"query"` // Required query text - KnowledgeBaseIDs []string `json:"knowledge_base_ids,omitempty"` // Optional KBs for this query - KnowledgeIDs []string `json:"knowledge_ids,omitempty"` // Optional specific knowledge IDs for this query - AgentEnabled bool `json:"agent_enabled"` // Whether to run in agent mode - AgentID string `json:"agent_id,omitempty"` // Optional custom agent ID - WebSearchEnabled bool `json:"web_search_enabled"` // Whether to enable web search - SummaryModelID string `json:"summary_model_id,omitempty"` // Optional summary model override - MentionedItems []MentionedItem `json:"mentioned_items,omitempty"` // @mentioned knowledge bases and files - DisableTitle bool `json:"disable_title,omitempty"` // Whether to disable auto title generation - MCPServiceIDs []string `json:"mcp_service_ids,omitempty"` // Optional MCP service allow list (deprecated) + Query string `json:"query"` // Required query text + KnowledgeBaseIDs []string `json:"knowledge_base_ids,omitempty"` // Optional KBs for this query + KnowledgeIDs []string `json:"knowledge_ids,omitempty"` // Optional specific knowledge IDs for this query + AgentEnabled bool `json:"agent_enabled"` // Whether to run in agent mode + AgentID string `json:"agent_id,omitempty"` // Optional custom agent ID + WebSearchEnabled bool `json:"web_search_enabled"` // Whether to enable web search + SummaryModelID string `json:"summary_model_id,omitempty"` // Optional summary model override + MentionedItems []MentionedItem `json:"mentioned_items,omitempty"` // @mentioned knowledge bases and files + DisableTitle bool `json:"disable_title,omitempty"` // Whether to disable auto title generation + MCPServiceIDs []string `json:"mcp_service_ids,omitempty"` // Optional MCP service allow list (deprecated) + Images []ImageAttachment `json:"images,omitempty"` // Attached images for multimodal chat } // AgentResponseType defines the type of agent response diff --git a/client/organization.go b/client/organization.go index ee6c4023..a382c537 100644 --- a/client/organization.go +++ b/client/organization.go @@ -126,6 +126,19 @@ type JoinRequestResponse struct { ReviewedAt *time.Time `json:"reviewed_at,omitempty"` } +// UserInfo represents user information for API responses +type UserInfo struct { + ID string `json:"id"` + Username string `json:"username"` + Email string `json:"email"` + Avatar string `json:"avatar"` + TenantID uint64 `json:"tenant_id"` + IsActive bool `json:"is_active"` + CanAccessAllTenants bool `json:"can_access_all_tenants"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` +} + // SharedKnowledgeBaseInfo represents a shared knowledge base type SharedKnowledgeBaseInfo struct { ShareID string `json:"share_id"` diff --git a/client/session.go b/client/session.go index 9ea3621b..831fc4c6 100644 --- a/client/session.go +++ b/client/session.go @@ -198,16 +198,26 @@ func (c *Client) GenerateTitle(ctx context.Context, sessionID string, request *G return response.Data, nil } +// ImageAttachment represents an image in a chat request. +// Frontend sends base64 data in the Data field; the backend saves, runs VLM analysis, +// and populates URL/Caption before proceeding with the chat pipeline. +type ImageAttachment struct { + Data string `json:"data,omitempty"` // base64 data URI (data:image/png;base64,...) + URL string `json:"url,omitempty"` // serving URL after saving to storage + Caption string `json:"caption,omitempty"` // VLM analysis result +} + // KnowledgeQARequest knowledge Q&A request type KnowledgeQARequest struct { - Query string `json:"query"` // Query text for knowledge base search - KnowledgeBaseIDs []string `json:"knowledge_base_ids"` // Selected knowledge base IDs for this request - KnowledgeIDs []string `json:"knowledge_ids"` // Selected knowledge IDs for this request - AgentEnabled bool `json:"agent_enabled"` // Whether agent mode is enabled for this request - AgentID string `json:"agent_id"` // Selected custom agent ID for this request - WebSearchEnabled bool `json:"web_search_enabled"` // Whether web search is enabled for this request - SummaryModelID string `json:"summary_model_id"` // Optional summary model ID (overrides session default) - DisableTitle bool `json:"disable_title"` // Whether to disable auto title generation + Query string `json:"query"` // Query text for knowledge base search + KnowledgeBaseIDs []string `json:"knowledge_base_ids"` // Selected knowledge base IDs for this request + KnowledgeIDs []string `json:"knowledge_ids"` // Selected knowledge IDs for this request + AgentEnabled bool `json:"agent_enabled"` // Whether agent mode is enabled for this request + AgentID string `json:"agent_id"` // Selected custom agent ID for this request + WebSearchEnabled bool `json:"web_search_enabled"` // Whether web search is enabled for this request + SummaryModelID string `json:"summary_model_id"` // Optional summary model ID (overrides session default) + DisableTitle bool `json:"disable_title"` // Whether to disable auto title generation + Images []ImageAttachment `json:"images,omitempty"` // Attached images for multimodal chat } // LLMToolCall represents a function/tool call from the LLM