Skip to content

Commit

Permalink
fix(google-common, google-vertexai): Invalid URL for embeddings model (
Browse files Browse the repository at this point in the history
…#7406)

Co-authored-by: jacoblee93 <[email protected]>
  • Loading branch information
afirstenberg and jacoblee93 authored Dec 19, 2024
1 parent 06f4de8 commit a7bc916
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
5 changes: 5 additions & 0 deletions libs/langchain-google-common/src/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class EmbeddingsConnection<
return "predict";
}

get modelPublisher(): string {
// All the embedding models are currently published by "google"
return "google";
}

async formatData(
input: GoogleEmbeddingsInstance[],
parameters: GoogleAIModelRequestParams
Expand Down
47 changes: 29 additions & 18 deletions libs/langchain-google-vertexai/src/tests/embeddings.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,32 @@ test("Test VertexAIEmbeddings.embedQuery", async () => {
expect(typeof res[0]).toBe("number");
});

test("Test VertexAIEmbeddings.embedDocuments", async () => {
const embeddings = new VertexAIEmbeddings({
model: "text-embedding-004",
});
const res = await embeddings.embedDocuments([
"Hello world",
"Bye bye",
"we need",
"at least",
"six documents",
"to test pagination",
]);
// console.log(res);
expect(res).toHaveLength(6);
res.forEach((r) => {
expect(typeof r[0]).toBe("number");
});
});
const testModelsLocations = [
["text-embedding-005", "us-central1"],
["text-multilingual-embedding-002", "us-central1"],
["text-embedding-005", "europe-west9"],
["text-multilingual-embedding-002", "europe-west9"],
];

test.each(testModelsLocations)(
"VertexAIEmbeddings.embedDocuments %s %s",
async (model, location) => {
const embeddings = new VertexAIEmbeddings({
model,
location,
});
const res = await embeddings.embedDocuments([
"Hello world",
"Bye bye",
"we need",
"at least",
"six documents",
"to test pagination",
]);
// console.log(res);
expect(res).toHaveLength(6);
res.forEach((r) => {
expect(typeof r[0]).toBe("number");
});
}
);

0 comments on commit a7bc916

Please sign in to comment.