uncloseai.com/src/config.js
Russell Ballestrini eee33986cf feat(ui): add comprehensive language localization system
- Add complete UI translations for all 19 supported languages
- Add language preference dropdown in modal settings
- Store language preference in localStorage
- Inject language preference into Hermes system prompts
- Add smart translation dropdown with AI-powered language detection
- Keep both original translation modal and new smart dropdown
- Remove non-functional upload button from modal
- Add biome.json config to ignore third-party CSS files
2025-07-03 11:09:10 -04:00

79 lines
2.9 KiB
JavaScript

// Configuration and endpoints for uncloseai.js
export const TTS_API_URL = "https://speech.ai.unturf.com/v1/audio/speech";
export const MEGAPARCE_API_URL = "https://megaparce.ai.unturf.com/v1/file";
export const API_KEY = "dummy-api-key";
export const MODEL = "adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic"; // default model (always available)
// System message configuration - implementors can customize this
export const SYSTEM_MESSAGE_BASE =
"You are Hermes, a large language model from Nous Research, embedded as an AI assistant on this webpage. Your primary task is to help users understand and interact with the content of this specific page, while also being capable of assisting with any other topics, coding, creative tasks, or questions they may have. You should be conversational, helpful, and knowledgeable about the webpage content as well as general topics. Always strive to provide accurate, useful responses.";
// Optional additional system message content - can be set by implementor
export let SYSTEM_MESSAGE_APPEND = "";
// Function to set additional system message content
export function setSystemMessageAppend(appendText) {
SYSTEM_MESSAGE_APPEND = appendText;
}
// Function to get the complete system message with language preference
export function getSystemMessage() {
// Get user's language preference from localStorage
let userLang = "en";
try {
userLang = localStorage.getItem("uncloseai_language") || "en";
} catch (error) {
console.warn("Failed to read language preference:", error);
}
// Add language instruction to the system message
let languageInstruction = "";
if (userLang !== "en") {
// Map language codes to full names for clarity
const langNames = {
es: "Spanish",
zh: "Chinese (Simplified)",
hi: "Hindi",
fr: "French",
ar: "Arabic",
bn: "Bengali",
ru: "Russian",
pt: "Portuguese",
ur: "Urdu",
id: "Indonesian",
de: "German",
ja: "Japanese",
sw: "Swahili",
mr: "Marathi",
te: "Telugu",
tr: "Turkish",
"zh-tw": "Chinese (Traditional)",
ko: "Korean",
};
const langName = langNames[userLang] || userLang;
languageInstruction = `\n\nIMPORTANT: The user has set their language preference to ${langName}. Please respond in ${langName} unless the user explicitly asks for another language. Maintain natural, fluent communication in ${langName}.`;
}
const baseMessage = SYSTEM_MESSAGE_APPEND
? `${SYSTEM_MESSAGE_BASE}\n\n${SYSTEM_MESSAGE_APPEND}`
: SYSTEM_MESSAGE_BASE;
return baseMessage + languageInstruction;
}
// Dynamic Endpoints Configuration for Chat API
export const VLLM_ENDPOINTS = [
{ id: "hermes.ai.unturf.com", url: "https://hermes.ai.unturf.com/v1" },
{ id: "hermes2.ai.unturf.com", url: "https://hermes2.ai.unturf.com/v1" },
];
// Global state
export let lastTTSInput = "";
export let lastTTSResult = null;
export function setLastTTS(input, result) {
lastTTSInput = input;
lastTTSResult = result;
}