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.
This commit is contained in:
wizardchen
2026-03-12 15:08:49 +08:00
parent 2d3b72e70e
commit bf1ae9c018
3 changed files with 42 additions and 18 deletions
+11 -10
View File
@@ -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
+13
View File
@@ -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"`
+18 -8
View File
@@ -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