refactor: update session title generation and language context handling
- Modified the session title generation template to focus on extracting only the intent of the user's question. - Enhanced the session service to include language context when generating titles. - Updated middleware to inject language into the request context. - Added a new test suite for validating SSRF safety of URLs.
This commit is contained in:
@@ -47,7 +47,7 @@ func SessionTenantIDFromContext(ctx context.Context) (uint64, bool) {
|
||||
}
|
||||
|
||||
// LanguageFromContext extracts the language locale string from ctx (e.g. "zh-CN", "en-US").
|
||||
// Returns ("en-US", false) when the key is absent.
|
||||
// Returns ("zh-CN", false) when the key is absent.
|
||||
func LanguageFromContext(ctx context.Context) (string, bool) {
|
||||
v, ok := ctx.Value(LanguageContextKey).(string)
|
||||
return v, ok && v != ""
|
||||
@@ -58,7 +58,7 @@ func LanguageFromContext(ctx context.Context) (string, bool) {
|
||||
func LanguageNameFromContext(ctx context.Context) string {
|
||||
lang, ok := LanguageFromContext(ctx)
|
||||
if !ok {
|
||||
lang = "en-US"
|
||||
lang = "zh-CN"
|
||||
}
|
||||
return LanguageLocaleName(lang)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user