mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00

* feat: update PaLM icons * feat: add additional google models * POC: formatting inputs for Vertex AI streaming * refactor: move endpoints services outside of /routes dir to /services/Endpoints * refactor: shorten schemas import * refactor: rename PALM to GOOGLE * feat: make Google editable endpoint * feat: reusable Ask and Edit controllers based off Anthropic * chore: organize imports/logic * fix(parseConvo): include examples in googleSchema * fix: google only allows odd number of messages to be sent * fix: pass proxy to AnthropicClient * refactor: change `google` altName to `Google` * refactor: update getModelMaxTokens and related functions to handle maxTokensMap with nested endpoint model key/values * refactor: google Icon and response sender changes (Codey and Google logo instead of PaLM in all cases) * feat: google support for maxTokensMap * feat: google updated endpoints with Ask/Edit controllers, buildOptions, and initializeClient * feat(GoogleClient): now builds prompt for text models and supports real streaming from Vertex AI through langchain * chore(GoogleClient): remove comments, left before for reference in git history * docs: update google instructions (WIP) * docs(apis_and_tokens.md): add images to google instructions * docs: remove typo apis_and_tokens.md * Update apis_and_tokens.md * feat(Google): use default settings map, fully support context for both text and chat models, fully support examples for chat models * chore: update more PaLM references to Google * chore: move playwright out of workflows to avoid failing tests
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
/**
|
|
* Formats an object to match the struct_val, list_val, string_val, float_val, and int_val format.
|
|
*
|
|
* @param {Object} obj - The object to be formatted.
|
|
* @returns {Object} The formatted object.
|
|
*
|
|
* Handles different types:
|
|
* - Arrays are wrapped in list_val and each element is processed.
|
|
* - Objects are recursively processed.
|
|
* - Strings are wrapped in string_val.
|
|
* - Numbers are wrapped in float_val or int_val depending on whether they are floating-point or integers.
|
|
*/
|
|
function formatGoogleInputs(obj) {
|
|
const formattedObj = {};
|
|
|
|
for (const key in obj) {
|
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
const value = obj[key];
|
|
|
|
// Handle arrays
|
|
if (Array.isArray(value)) {
|
|
formattedObj[key] = { list_val: value.map((item) => formatGoogleInputs(item)) };
|
|
}
|
|
// Handle objects
|
|
else if (typeof value === 'object' && value !== null) {
|
|
formattedObj[key] = formatGoogleInputs(value);
|
|
}
|
|
// Handle numbers
|
|
else if (typeof value === 'number') {
|
|
formattedObj[key] = Number.isInteger(value) ? { int_val: value } : { float_val: value };
|
|
}
|
|
// Handle other types (e.g., strings)
|
|
else {
|
|
formattedObj[key] = { string_val: [value] };
|
|
}
|
|
}
|
|
}
|
|
|
|
return { struct_val: formattedObj };
|
|
}
|
|
|
|
module.exports = formatGoogleInputs;
|