feat: add language synonym mapping and canonicalization
Add LANGUAGE_SYNONYMS dictionary to map language aliases to canonical IDs, _canonical_language_id() to normalize language identifiers, and _language_guidance() to provide language-specific instructions for LLM code generation. This improves language detection and ensures consistent prompt context across different language format variations.
This commit is contained in:
@@ -60,7 +60,17 @@ async function getClientIP() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchSuggestion(prefix, suffix, signal, apiUrl = API_URL) {
|
||||
export async function fetchSuggestion(prefix, suffix, languageId, signal, apiUrl = API_URL) {
|
||||
let normalizedLanguageId = 'markdown'
|
||||
if (typeof languageId === 'string' && languageId.trim()) {
|
||||
normalizedLanguageId = languageId.trim()
|
||||
} else if (languageId && typeof languageId === 'object' && 'aborted' in languageId) {
|
||||
signal = languageId
|
||||
}
|
||||
if (typeof signal === 'string') {
|
||||
apiUrl = signal
|
||||
signal = undefined
|
||||
}
|
||||
const requestId = generateRequestId()
|
||||
const cancelUrl = getCancelUrl(apiUrl)
|
||||
|
||||
@@ -94,7 +104,7 @@ export async function fetchSuggestion(prefix, suffix, signal, apiUrl = API_URL)
|
||||
const body = {
|
||||
prefix,
|
||||
suffix,
|
||||
languageId: 'markdown',
|
||||
languageId: normalizedLanguageId,
|
||||
model_thinking: settings.modelThinking,
|
||||
privacy_mode: settings.privacyMode,
|
||||
user_preferences: {
|
||||
|
||||
Reference in New Issue
Block a user