Merge pull request #967 from trheyi/main

Enhance Context struct by adding Locale and Theme fields
This commit is contained in:
Max 2025-05-19 18:16:22 +08:00 committed by GitHub
commit d8e7560ff7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12,27 +12,33 @@ import (
// Context the context // Context the context
type Context struct { type Context struct {
context.Context context.Context
Sid string `json:"sid" yaml:"-"` // Session ID Sid string `json:"sid" yaml:"-"` // Session ID
ChatID string `json:"chat_id,omitempty"` // Chat ID, use to select chat ChatID string `json:"chat_id,omitempty"` // Chat ID, use to select chat
AssistantID string `json:"assistant_id,omitempty"` // Assistant ID, use to select assistant AssistantID string `json:"assistant_id,omitempty"` // Assistant ID, use to select assistant
Stack string `json:"stack,omitempty"` // will be removed in the future Stack string `json:"stack,omitempty"` // will be removed in the future
Path string `json:"pathname,omitempty"` // wiil be rename to path Path string `json:"pathname,omitempty"` // wiil be rename to path
FormData map[string]interface{} `json:"formdata,omitempty"` FormData map[string]interface{} `json:"formdata,omitempty"`
Field *Field `json:"field,omitempty"` Field *Field `json:"field,omitempty"`
Namespace string `json:"namespace,omitempty"` Namespace string `json:"namespace,omitempty"`
Config map[string]interface{} `json:"config,omitempty"` Config map[string]interface{} `json:"config,omitempty"`
Signal interface{} `json:"signal,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 Locale string `json:"locale,omitempty"` // Locale
HistoryVisible bool `json:"history_visible,omitempty"` // History visible, default is true, if false, the history will not be displayed in the UI Theme string `json:"theme,omitempty"` // Theme
Retry bool `json:"retry,omitempty"` // Retry mode
RetryTimes uint8 `json:"retry_times,omitempty"` // Retry times Silent bool `json:"silent,omitempty"` // Silent mode
Upload *FileUpload `json:"upload,omitempty"` ClientType string `json:"client_type,omitempty"` // The request client type. SDK, Desktop, Web, JSSDK, etc. the default is Web
Vision bool `json:"vision,omitempty"` // Vision support HistoryVisible bool `json:"history_visible,omitempty"` // History visible, default is true, if false, the history will not be displayed in the UI
Search bool `json:"search,omitempty"` // Search support Retry bool `json:"retry,omitempty"` // Retry mode
RAG bool `json:"rag,omitempty"` // RAG support RetryTimes uint8 `json:"retry_times,omitempty"` // Retry times
Args []interface{} `json:"args,omitempty"` // Arguments for call Upload *FileUpload `json:"upload,omitempty"` // Will be removed in the future
SharedSpace plan.Space `json:"-"` // Shared space
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 // Field the context field
@ -244,5 +250,11 @@ func (ctx *Context) Map() map[string]interface{} {
data["upload"] = ctx.Upload data["upload"] = ctx.Upload
} }
// Locale
data["locale"] = ctx.Locale
// Theme
data["theme"] = ctx.Theme
return data return data
} }