feat: enhance localization and configuration support
- Added timezone and language settings to the environment configuration. - Introduced built-in agent configurations with multilingual support for various agents. - Updated Docker Compose to utilize new environment variables for timezone and language. - Created new prompt templates for question generation, summary generation, and keywords extraction.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/application/service"
|
||||
@@ -102,6 +103,15 @@ func (h *ModelHandler) CreateModel(c *gin.Context) {
|
||||
logger.Infof(ctx, "Creating model, Tenant ID: %d, Model name: %s, Model type: %s",
|
||||
tenantID, secutils.SanitizeForLog(req.Name), secutils.SanitizeForLog(string(req.Type)))
|
||||
|
||||
// SSRF validation for model BaseURL
|
||||
if req.Parameters.BaseURL != "" {
|
||||
if err := secutils.ValidateURLForSSRF(req.Parameters.BaseURL); err != nil {
|
||||
logger.Warnf(ctx, "SSRF validation failed for model BaseURL: %v", err)
|
||||
c.Error(errors.NewBadRequestError(fmt.Sprintf("Base URL 未通过安全校验: %v", err)))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
model := &types.Model{
|
||||
TenantID: tenantID,
|
||||
Name: secutils.SanitizeForLog(req.Name),
|
||||
@@ -293,6 +303,14 @@ func (h *ModelHandler) UpdateModel(c *gin.Context) {
|
||||
model.Description = req.Description
|
||||
// Check if any Parameters field is set (can't use struct comparison due to map field)
|
||||
if req.Parameters.BaseURL != "" || req.Parameters.APIKey != "" || req.Parameters.Provider != "" {
|
||||
// SSRF validation for updated model BaseURL
|
||||
if req.Parameters.BaseURL != "" {
|
||||
if err := secutils.ValidateURLForSSRF(req.Parameters.BaseURL); err != nil {
|
||||
logger.Warnf(ctx, "SSRF validation failed for model BaseURL: %v", err)
|
||||
c.Error(errors.NewBadRequestError(fmt.Sprintf("Base URL 未通过安全校验: %v", err)))
|
||||
return
|
||||
}
|
||||
}
|
||||
model.Parameters = req.Parameters
|
||||
}
|
||||
model.Source = req.Source
|
||||
|
||||
Reference in New Issue
Block a user