Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix llms and chat tests failing, rework llms accordingly to new Watsonx #31

Merged
merged 55 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
317a6af
Fix llms and chat tests failing, rework llms accordingly to new Watso…
FilipZmijewski Nov 13, 2024
933c90f
Fixed missing tool_choice in call options of chat (#30)
FilipZmijewski Nov 12, 2024
d4e5bc4
Remove unused import
FilipZmijewski Nov 13, 2024
ebbeaa6
Fix
FilipZmijewski Nov 13, 2024
b7b980b
fix[community]: Fixed missing tool_choice in call options of chat IBM…
FilipZmijewski Nov 12, 2024
4a712a8
fix(anthropic, bedrock): Remove message merging logic (#7196)
bracesproul Nov 13, 2024
65a6f51
feat(community): Release 0.3.14 (#7197)
bracesproul Nov 13, 2024
9b312bd
feat(anthropic): Release 0.3.8 (#7198)
bracesproul Nov 13, 2024
30bdafd
fix(google-genai): Force tool usage in WSO (#7213)
bracesproul Nov 16, 2024
1e9908f
fix(google-genai): Release 0.1.4 (#7215)
bracesproul Nov 16, 2024
7bf0eaf
feat(community): Adds an HTML loader for URLS (#7184)
philnash Nov 17, 2024
d939328
feat(community): allow metadata generics to flow through LibSQLVector…
cdierkens Nov 17, 2024
157e1d6
feat(community): replace `vectordb` package with new `@lancedb/lanced…
wjones127 Nov 17, 2024
2aac482
feat(cosmosdbnosql): Add Chat History Integration (#7057)
aditishree1 Nov 17, 2024
9b2de04
chore(azure-cosmosdb): Release 0.2.2 (#7219)
jacoblee93 Nov 17, 2024
d6a0663
feat(community): add filters to LibSQLVectorStore (#7209)
cdierkens Nov 17, 2024
ebb06ef
chore(community): Release 0.3.15 (#7221)
jacoblee93 Nov 17, 2024
d65690a
fix(langchain): Fix structured parser with triple backticks, adds tes…
johnguirgis Nov 17, 2024
67193c1
chore(langchain): add throw err for JsonOutputFunctionsParser.parse (…
Makoq Nov 17, 2024
5fcc0c4
fix(langchain): Fix serialization for initChatModel (#7222)
jacoblee93 Nov 17, 2024
6d7398e
chore(langchain): Release 0.3.6 (#7223)
jacoblee93 Nov 17, 2024
c37d90e
feat(pinecone): Add support for Pinecone `/embed` endpoint (#7203)
aulorbe Nov 17, 2024
70206f0
chore(pinecone): Release 0.1.3 (#7224)
jacoblee93 Nov 17, 2024
6ab8bcc
fix(openai): Support o1 streaming (#7229)
bracesproul Nov 18, 2024
27d0adc
chore(openai): Release 0.3.14 (#7230)
jacoblee93 Nov 18, 2024
105461f
docs: Add missing streaming concept (#7228)
eyurtsev Nov 20, 2024
d5e616d
fix(ci): Update release script to be more lenient (#7234)
bracesproul Nov 22, 2024
2c071da
feat(mistral): Mistral 1.3.1 migration (#7218)
CarterMorris Nov 22, 2024
3f9dfd0
chore(mistral): Release 0.2.0 (#7239)
jacoblee93 Nov 22, 2024
0c18758
feat(azurecosmosdb): Vector Store Add DiskANN index for CosmosDB (#7225)
crisjc-e Nov 22, 2024
661c9e2
chore(azure-cosmosdb): Release 0.2.3 (#7241)
jacoblee93 Nov 22, 2024
6b42b80
fix(community): bedrock parsing array content/tool blocks (#7244)
bracesproul Nov 22, 2024
f555135
fix(ci): Fix release workspace (#7245)
bracesproul Nov 22, 2024
552d054
feat(community): Incorporate BM25 score in the results (#7236)
felipediel Nov 25, 2024
b40f981
feat(community): Stagehand tools integration (#7177)
filip-michalsky Nov 25, 2024
c62a644
Update Pinecone indexing example to show use of deletionProtection (#…
aulorbe Nov 25, 2024
d28b74a
feat(community): Add rerank solution to existing IBM community implem…
FilipZmijewski Nov 25, 2024
080e0c7
fix(core): Fix issue in .d.ts typing for protected type (#7259)
jacoblee93 Nov 25, 2024
256f2a8
fix(community): PrismaVectorStore handle empty array in filter (#7254)
shan-mx Nov 25, 2024
87f7283
fix(core): Move type (#7246)
jacoblee93 Nov 25, 2024
ccf278f
chore(core): Release 0.3.19 (#7260)
jacoblee93 Nov 25, 2024
a8c3927
chore(community): Release 0.3.16 (#7261)
jacoblee93 Nov 25, 2024
4ddb593
fix(google-common): Anthropic util using getType instead of _getType …
bracesproul Nov 26, 2024
85d56f3
release(google-common): 0.1.3 (#7265)
bracesproul Nov 26, 2024
0f0ccd5
fix(google-gauth/webauth): Bump Google common dep (#7266)
bracesproul Nov 26, 2024
27b34b2
release(google-webauth): 0.1.3 (#7267)
bracesproul Nov 26, 2024
8a59fdc
fix(google-vertexai/web): Bump Google auth deps (#7269)
bracesproul Nov 26, 2024
f90dac0
release(google-vertexai): 0.1.3 (#7270)
bracesproul Nov 26, 2024
7b05e28
release(google-gauth): 0.1.3 (#7271)
bracesproul Nov 26, 2024
018a4f6
release(google-vertexai-web): 0.1.3 (#7272)
bracesproul Nov 26, 2024
c7ed778
Main ibm community update to main (#34)
FilipZmijewski Nov 26, 2024
e2078ba
Change compressDocuments() method, add tests regarding changes"
FilipZmijewski Nov 27, 2024
5e6b43b
Remove unused import
FilipZmijewski Nov 27, 2024
24e0b0b
Merge branch 'main' into fix/ibm_implementation
FilipZmijewski Nov 27, 2024
87363cb
Update ibm.ts
FilipZmijewski Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(langchain): Fix serialization for initChatModel (langchain-ai#7222)
  • Loading branch information
jacoblee93 authored and FilipZmijewski committed Nov 27, 2024
commit 5fcc0c4c10b00bc987bdfd575c607a77e346c6fa
44 changes: 40 additions & 4 deletions langchain/src/chat_models/tests/universal.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ChatPromptTemplate, PromptTemplate } from "@langchain/core/prompts";
import { RunLogPatch, StreamEvent } from "@langchain/core/tracers/log_stream";
import { AIMessageChunk } from "@langchain/core/messages";
import { concat } from "@langchain/core/utils/stream";
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
import { AgentExecutor, createReactAgent } from "../../agents/index.js";
import { pull } from "../../hub.js";
import { initChatModel } from "../universal.js";
Expand All @@ -32,7 +33,7 @@ const googleApiKey = process.env.GOOGLE_API_KEY;
process.env.GOOGLE_API_KEY = "";

test("Initialize non-configurable models", async () => {
const gpt4 = await initChatModel("gpt-4", {
const gpt4 = await initChatModel("gpt-4o-mini", {
modelProvider: "openai",
temperature: 0.25, // Funky temperature to verify it's being set properly.
apiKey: openAIApiKey,
Expand Down Expand Up @@ -67,7 +68,7 @@ test("Create a partially configurable model with no default model", async () =>

const gpt4Result = await configurableModel.invoke("what's your name", {
configurable: {
model: "gpt-4",
model: "gpt-4o-mini",
apiKey: openAIApiKey,
},
});
Expand All @@ -85,7 +86,7 @@ test("Create a partially configurable model with no default model", async () =>
});

test("Create a fully configurable model with a default model and a config prefix", async () => {
const configurableModelWithDefault = await initChatModel("gpt-4", {
const configurableModelWithDefault = await initChatModel("gpt-4o-mini", {
modelProvider: "openai",
configurableFields: "any",
configPrefix: "foo",
Expand Down Expand Up @@ -155,7 +156,7 @@ test("Bind tools to a configurable model", async () => {
}
);

const configurableModel = await initChatModel("gpt-4", {
const configurableModel = await initChatModel("gpt-4o-mini", {
configurableFields: ["model", "modelProvider", "apiKey"],
temperature: 0,
});
Expand Down Expand Up @@ -602,3 +603,38 @@ describe("Can call base runnable methods", () => {
expect(result.tool_calls?.[0].name).toBe("GetWeather");
});
});

describe("Serialization", () => {
it("does not contain additional fields", async () => {
const gpt4 = await initChatModel("gpt-4o-mini", {
modelProvider: "openai",
temperature: 0.25, // Funky temperature to verify it's being set properly.
apiKey: openAIApiKey,
});
let serializedRepresentation;
const res = await gpt4.invoke("foo", {
callbacks: [
{
handleChatModelStart(llm) {
serializedRepresentation = llm;
},
},
],
configurable: { extra: "bar" },
});
await awaitAllCallbacks();
expect(res).toBeDefined();
const { ChatOpenAI } = await import("@langchain/openai");
expect(serializedRepresentation).toEqual(
JSON.parse(
JSON.stringify(
new ChatOpenAI({
model: "gpt-4o-mini",
temperature: 0.25,
apiKey: openAIApiKey,
})
)
)
);
});
});
40 changes: 23 additions & 17 deletions langchain/src/chat_models/universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,50 +73,51 @@ async function _initChatModelHelper(
`Unable to infer model provider for { model: ${model} }, please specify modelProvider directly.`
);
}
const { modelProvider: _unused, ...passedParams } = params;

try {
switch (modelProviderCopy) {
case "openai": {
const { ChatOpenAI } = await import("@langchain/openai");
return new ChatOpenAI({ model, ...params });
return new ChatOpenAI({ model, ...passedParams });
}
case "anthropic": {
const { ChatAnthropic } = await import("@langchain/anthropic");
return new ChatAnthropic({ model, ...params });
return new ChatAnthropic({ model, ...passedParams });
}
case "azure_openai": {
const { AzureChatOpenAI } = await import("@langchain/openai");
return new AzureChatOpenAI({ model, ...params });
return new AzureChatOpenAI({ model, ...passedParams });
}
case "cohere": {
const { ChatCohere } = await import("@langchain/cohere");
return new ChatCohere({ model, ...params });
return new ChatCohere({ model, ...passedParams });
}
case "google-vertexai": {
const { ChatVertexAI } = await import("@langchain/google-vertexai");
return new ChatVertexAI({ model, ...params });
return new ChatVertexAI({ model, ...passedParams });
}
case "google-genai": {
const { ChatGoogleGenerativeAI } = await import(
"@langchain/google-genai"
);
return new ChatGoogleGenerativeAI({ model, ...params });
return new ChatGoogleGenerativeAI({ model, ...passedParams });
}
case "ollama": {
const { ChatOllama } = await import("@langchain/ollama");
return new ChatOllama({ model, ...params });
return new ChatOllama({ model, ...passedParams });
}
case "mistralai": {
const { ChatMistralAI } = await import("@langchain/mistralai");
return new ChatMistralAI({ model, ...params });
return new ChatMistralAI({ model, ...passedParams });
}
case "groq": {
const { ChatGroq } = await import("@langchain/groq");
return new ChatGroq({ model, ...params });
return new ChatGroq({ model, ...passedParams });
}
case "bedrock": {
const { ChatBedrockConverse } = await import("@langchain/aws");
return new ChatBedrockConverse({ model, ...params });
return new ChatBedrockConverse({ model, ...passedParams });
}
case "fireworks": {
const { ChatFireworks } = await import(
Expand All @@ -127,7 +128,7 @@ async function _initChatModelHelper(
// @ts-ignore - Can not install as a proper dependency due to circular dependency
"@langchain/community/chat_models/fireworks"
);
return new ChatFireworks({ model, ...params });
return new ChatFireworks({ model, ...passedParams });
}
case "together": {
const { ChatTogetherAI } = await import(
Expand All @@ -138,7 +139,7 @@ async function _initChatModelHelper(
// @ts-ignore - Can not install as a proper dependency due to circular dependency
"@langchain/community/chat_models/togetherai"
);
return new ChatTogetherAI({ model, ...params });
return new ChatTogetherAI({ model, ...passedParams });
}
default: {
const supported = _SUPPORTED_PROVIDERS.join(", ");
Expand Down Expand Up @@ -247,7 +248,10 @@ class _ConfigurableModel<
if (fields.configurableFields === "any") {
this._configurableFields = "any";
} else {
this._configurableFields = fields.configurableFields ?? "any";
this._configurableFields = fields.configurableFields ?? [
"model",
"modelProvider",
];
}

if (fields.configPrefix) {
Expand Down Expand Up @@ -786,12 +790,14 @@ export async function initChatModel<
configPrefix: "",
...(fields ?? {}),
};
let configurableFieldsCopy = configurableFields;
let configurableFieldsCopy = Array.isArray(configurableFields)
? [...configurableFields]
: configurableFields;

if (!model && !configurableFieldsCopy) {
if (!model && configurableFieldsCopy === undefined) {
configurableFieldsCopy = ["model", "modelProvider"];
}
if (configPrefix && !configurableFieldsCopy) {
if (configPrefix && configurableFieldsCopy === undefined) {
console.warn(
`{ configPrefix: ${configPrefix} } has been set but no fields are configurable. Set ` +
`{ configurableFields: [...] } to specify the model params that are ` +
Expand All @@ -802,7 +808,7 @@ export async function initChatModel<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const paramsCopy: Record<string, any> = { ...params };

if (!configurableFieldsCopy) {
if (configurableFieldsCopy === undefined) {
return new _ConfigurableModel<RunInput, CallOptions>({
defaultConfig: {
...paramsCopy,
Expand Down