feat: add thinking support (#100)

* feat: add thinking support

* feat: improve thinking block render in web and filter thinking content in channels

* fix: migrate
This commit is contained in:
Acbox Liu
2026-02-23 14:41:27 +08:00
committed by GitHub
parent 18535f97f2
commit 17cd077f34
31 changed files with 530 additions and 118 deletions
+20 -5
View File
@@ -140,12 +140,18 @@ func (r *Resolver) SetInboxService(service *inbox.Service) {
// --- gateway payload ---
type gatewayReasoningConfig struct {
Enabled bool `json:"enabled"`
Effort string `json:"effort"`
}
type gatewayModelConfig struct {
ModelID string `json:"modelId"`
ClientType string `json:"clientType"`
Input []string `json:"input"`
APIKey string `json:"apiKey"`
BaseURL string `json:"baseUrl"`
ModelID string `json:"modelId"`
ClientType string `json:"clientType"`
Input []string `json:"input"`
APIKey string `json:"apiKey"`
BaseURL string `json:"baseUrl"`
Reasoning *gatewayReasoningConfig `json:"reasoning,omitempty"`
}
type gatewayIdentity struct {
@@ -393,6 +399,14 @@ func (r *Resolver) resolve(ctx context.Context, req conversation.ChatRequest) (r
req.Query,
)
var reasoning *gatewayReasoningConfig
if chatModel.SupportsReasoning && botSettings.ReasoningEnabled {
reasoning = &gatewayReasoningConfig{
Enabled: true,
Effort: botSettings.ReasoningEffort,
}
}
payload := gatewayRequest{
Model: gatewayModelConfig{
ModelID: chatModel.ModelID,
@@ -400,6 +414,7 @@ func (r *Resolver) resolve(ctx context.Context, req conversation.ChatRequest) (r
Input: chatModel.InputModalities,
APIKey: provider.ApiKey,
BaseURL: provider.BaseUrl,
Reasoning: reasoning,
},
ActiveContextTime: maxCtx,
Channels: nonNilStrings(req.Channels),