From 9a0ad73f4c0e6efa74cf25362ff6235742d3031e Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 19 May 2025 18:15:36 +0800 Subject: [PATCH] Enhance Context struct by adding Locale and Theme fields - Introduced Locale and Theme fields to the Context struct for improved customization options. - Updated the Map method to include these new fields in the returned data. --- neo/context/context.go | 54 ++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/neo/context/context.go b/neo/context/context.go index 2fc69eef..5253391c 100644 --- a/neo/context/context.go +++ b/neo/context/context.go @@ -12,27 +12,33 @@ import ( // Context the context type Context struct { context.Context - Sid string `json:"sid" yaml:"-"` // Session ID - ChatID string `json:"chat_id,omitempty"` // Chat ID, use to select chat - AssistantID string `json:"assistant_id,omitempty"` // Assistant ID, use to select assistant - Stack string `json:"stack,omitempty"` // will be removed in the future - Path string `json:"pathname,omitempty"` // wiil be rename to path - FormData map[string]interface{} `json:"formdata,omitempty"` - Field *Field `json:"field,omitempty"` - Namespace string `json:"namespace,omitempty"` - Config map[string]interface{} `json:"config,omitempty"` - Signal interface{} `json:"signal,omitempty"` - Silent bool `json:"silent,omitempty"` // Silent mode - ClientType string `json:"client_type,omitempty"` // The request client type. SDK, Desktop, Web, JSSDK, etc. the default is Web - HistoryVisible bool `json:"history_visible,omitempty"` // History visible, default is true, if false, the history will not be displayed in the UI - Retry bool `json:"retry,omitempty"` // Retry mode - RetryTimes uint8 `json:"retry_times,omitempty"` // Retry times - Upload *FileUpload `json:"upload,omitempty"` - Vision bool `json:"vision,omitempty"` // Vision support - Search bool `json:"search,omitempty"` // Search support - RAG bool `json:"rag,omitempty"` // RAG support - Args []interface{} `json:"args,omitempty"` // Arguments for call - SharedSpace plan.Space `json:"-"` // Shared space + Sid string `json:"sid" yaml:"-"` // Session ID + ChatID string `json:"chat_id,omitempty"` // Chat ID, use to select chat + AssistantID string `json:"assistant_id,omitempty"` // Assistant ID, use to select assistant + Stack string `json:"stack,omitempty"` // will be removed in the future + Path string `json:"pathname,omitempty"` // wiil be rename to path + FormData map[string]interface{} `json:"formdata,omitempty"` + Field *Field `json:"field,omitempty"` + Namespace string `json:"namespace,omitempty"` + Config map[string]interface{} `json:"config,omitempty"` + Signal interface{} `json:"signal,omitempty"` + + Locale string `json:"locale,omitempty"` // Locale + Theme string `json:"theme,omitempty"` // Theme + + Silent bool `json:"silent,omitempty"` // Silent mode + ClientType string `json:"client_type,omitempty"` // The request client type. SDK, Desktop, Web, JSSDK, etc. the default is Web + HistoryVisible bool `json:"history_visible,omitempty"` // History visible, default is true, if false, the history will not be displayed in the UI + Retry bool `json:"retry,omitempty"` // Retry mode + RetryTimes uint8 `json:"retry_times,omitempty"` // Retry times + Upload *FileUpload `json:"upload,omitempty"` // Will be removed in the future + + Vision bool `json:"vision,omitempty"` // Vision support + Search bool `json:"search,omitempty"` // Search support + RAG bool `json:"rag,omitempty"` // RAG support + + Args []interface{} `json:"args,omitempty"` // Arguments for call + SharedSpace plan.Space `json:"-"` // Shared space } // Field the context field @@ -244,5 +250,11 @@ func (ctx *Context) Map() map[string]interface{} { data["upload"] = ctx.Upload } + // Locale + data["locale"] = ctx.Locale + + // Theme + data["theme"] = ctx.Theme + return data }