Vectors: Fix passing model id to AI Studio

5a6d93fc0311f1a891ee2b453b30566f79225262

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +7 -6Showing whitespace changes
src/endpoints/vectors.js+2 -2
@@ -56,7 +56,7 @@ async function getVector(source, sourceSettings, text, isQuery, directories) {
56 case 'extras':56 case 'extras':
57 return getExtrasVector(text, sourceSettings.extrasUrl, sourceSettings.extrasKey);57 return getExtrasVector(text, sourceSettings.extrasUrl, sourceSettings.extrasKey);
58 case 'palm':58 case 'palm':
59 return getMakerSuiteVector(text, directories);59 return getMakerSuiteVector(text, directories, sourceSettings.model);
60 case 'cohere':60 case 'cohere':
61 return getCohereVector(text, isQuery, directories, sourceSettings.model);61 return getCohereVector(text, isQuery, directories, sourceSettings.model);
62 case 'llamacpp':62 case 'llamacpp':
@@ -105,7 +105,7 @@ async function getBatchVector(source, sourceSettings, texts, isQuery, directorie
105 results.push(...await getExtrasBatchVector(batch, sourceSettings.extrasUrl, sourceSettings.extrasKey));105 results.push(...await getExtrasBatchVector(batch, sourceSettings.extrasUrl, sourceSettings.extrasKey));
106 break;106 break;
107 case 'palm':107 case 'palm':
108 results.push(...await getMakerSuiteBatchVector(batch, directories));108 results.push(...await getMakerSuiteBatchVector(batch, directories, sourceSettings.model));
109 break;109 break;
110 case 'cohere':110 case 'cohere':
111 results.push(...await getCohereBatchVector(batch, isQuery, directories, sourceSettings.model));111 results.push(...await getCohereBatchVector(batch, isQuery, directories, sourceSettings.model));
src/vectors/makersuite-vectors.js+5 -4
@@ -7,10 +7,11 @@ const API_MAKERSUITE = 'https://generativelanguage.googleapis.com';
7 * Gets the vector for the given text from gecko model7 * Gets the vector for the given text from gecko model
8 * @param {string[]} texts - The array of texts to get the vector for8 * @param {string[]} texts - The array of texts to get the vector for
9 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user9 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
10 * @param {string} model - The model to use for embedding
10 * @returns {Promise<number[][]>} - The array of vectors for the texts11 * @returns {Promise<number[][]>} - The array of vectors for the texts
11 */12 */
12export async function getMakerSuiteBatchVector(texts, directories) {13export async function getMakerSuiteBatchVector(texts, directories, model) {
13 const promises = texts.map(text => getMakerSuiteVector(text, directories));14 const promises = texts.map(text => getMakerSuiteVector(text, directories, model));
14 return await Promise.all(promises);15 return await Promise.all(promises);
15}16}
1617
@@ -18,9 +19,10 @@ export async function getMakerSuiteBatchVector(texts, directories) {
18 * Gets the vector for the given text from Gemini API text-embedding-004 model19 * Gets the vector for the given text from Gemini API text-embedding-004 model
19 * @param {string} text - The text to get the vector for20 * @param {string} text - The text to get the vector for
20 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user21 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
22 * @param {string} model - The model to use for embedding (default is 'text-embedding-004')
21 * @returns {Promise<number[]>} - The vector for the text23 * @returns {Promise<number[]>} - The vector for the text
22 */24 */
23export async function getMakerSuiteVector(text, directories) {25export async function getMakerSuiteVector(text, directories, model) {
24 const key = readSecret(directories, SECRET_KEYS.MAKERSUITE);26 const key = readSecret(directories, SECRET_KEYS.MAKERSUITE);
2527
26 if (!key) {28 if (!key) {
@@ -29,7 +31,6 @@ export async function getMakerSuiteVector(text, directories) {
29 }31 }
3032
31 const apiUrl = trimTrailingSlash(API_MAKERSUITE);33 const apiUrl = trimTrailingSlash(API_MAKERSUITE);
32 const model = 'text-embedding-004';
33 const url = `${apiUrl}/v1beta/models/${model}:embedContent?key=${key}`;34 const url = `${apiUrl}/v1beta/models/${model}:embedContent?key=${key}`;
34 const body = {35 const body = {
35 content: {36 content: {