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

core[fix]: RunnableFunc config types #3513

Merged
merged 4 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions examples/src/chains/map_reduce_lcel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ const collapseChain = RunnableSequence.from([
// Define a function to collapse a list of documents until the total number of tokens is within the limit
const collapse = async (
documents: Document[],
config?: BaseCallbackConfig,
options?: {
config?: BaseCallbackConfig;
},
tokenMax = 4000
) => {
const editableConfig = config;
const editableConfig = options?.config;
let docs = documents;
let collapseCount = 1;
while ((await getNumTokens(docs)) > tokenMax) {
Expand Down
2 changes: 1 addition & 1 deletion examples/src/embeddings/gradient_ai.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GradientEmbeddings } from "langchain/embeddings/gradient_ai";

const model = new GradientEmbeddings();
const model = new GradientEmbeddings({});
const res = await model.embedQuery(
"What would be a good company name a company that makes colorful socks?"
);
Expand Down
10 changes: 6 additions & 4 deletions langchain-core/src/runnables/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import { RootListenersTracer } from "../tracers/root_listener.js";

export type RunnableFunc<RunInput, RunOutput> = (
input: RunInput,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options?: Record<string, any> & {
config?: RunnableConfig;
}
options?:
| { config?: RunnableConfig }
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| Record<string, any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| (Record<string, any> & { config: RunnableConfig })
) => RunOutput | Promise<RunOutput>;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down