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

partners[patch]: Comment out console logs in test files #6210

Merged
merged 7 commits into from
Jul 25, 2024
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
72 changes: 36 additions & 36 deletions langchain/src/agents/tests/agent.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ test("Pass runnable to agent executor", async () => {
input:
"Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?",
});
console.log(
{
res,
},
"Pass runnable to agent executor"
);
// console.log(
// {
// res,
// },
// "Pass runnable to agent executor"
// );
expect(res.output).not.toEqual("");
expect(res.output).not.toEqual("Agent stopped due to max iterations.");
});
Expand Down Expand Up @@ -115,12 +115,12 @@ test("Custom output parser", async () => {
input:
"Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?",
});
console.log(
{
res,
},
"Custom output parser"
);
// console.log(
// {
// res,
// },
// "Custom output parser"
// );
expect(res.output).toEqual("We did it!");
});

Expand Down Expand Up @@ -160,12 +160,12 @@ test("Add a fallback method", async () => {
const res = await executor.invoke({
input: "Is the sky blue? Response with a concise answer",
});
console.log(
{
res,
},
"Pass runnable to agent executor"
);
// console.log(
// {
// res,
// },
// "Pass runnable to agent executor"
// );
expect(res.output).not.toEqual("");
expect(res.output).not.toEqual("Agent stopped due to max iterations.");
});
Expand All @@ -177,10 +177,10 @@ test("Run agent with an abort signal", async () => {
const executor = await initializeAgentExecutorWithOptions(tools, model, {
agentType: "zero-shot-react-description",
});
console.log("Loaded agent.");
// console.log("Loaded agent.");

const input = `What is 3 to the fourth power?`;
console.log(`Executing with input "${input}"...`);
// console.log(`Executing with input "${input}"...`);

const controller = new AbortController();
await expect(() => {
Expand Down Expand Up @@ -208,7 +208,7 @@ test("Run agent with incorrect api key should throw error", async () => {
const executor = await initializeAgentExecutorWithOptions(tools, model, {
agentType: "zero-shot-react-description",
});
console.log("Loaded agent.");
// console.log("Loaded agent.");

const input = `Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?`;

Expand Down Expand Up @@ -246,18 +246,18 @@ test("Run tool web-browser", async () => {
agentType: "zero-shot-react-description",
returnIntermediateSteps: true,
});
console.log("Loaded agent.");
// console.log("Loaded agent.");

const input = `What is the word of the day on merriam webster`;
console.log(`Executing with input "${input}"...`);
// console.log(`Executing with input "${input}"...`);

const result = await executor.call({ input });
console.log(
{
result,
},
"Run tool web-browser"
);
// console.log(
// {
// result,
// },
// "Run tool web-browser"
// );
expect(result.intermediateSteps.length).toBeGreaterThanOrEqual(1);
expect(result.intermediateSteps[0].action.tool).toEqual("search");
expect(result.intermediateSteps[1].action.tool).toEqual("web-browser");
Expand All @@ -280,18 +280,18 @@ test("Agent can stream", async () => {
agentType: "zero-shot-react-description",
returnIntermediateSteps: false,
});
console.log("Loaded agent.");
// console.log("Loaded agent.");

const input = `What is the word of the day on merriam webster`;
console.log(`Executing with input "${input}"...`);
// console.log(`Executing with input "${input}"...`);

const result = await executor.stream({ input });
let streamIters = 0;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const finalResponse: any = [];
for await (const item of result) {
streamIters += 1;
console.log("Stream item:", item);
// console.log("Stream item:", item);
// each stream does NOT contain the previous steps,
// because returnIntermediateSteps is false so we
// push each new stream item to the array.
Expand Down Expand Up @@ -340,25 +340,25 @@ test("Agent can stream with chat messages", async () => {
returnIntermediateSteps: true,
memory,
});
console.log("Loaded agent.");
// console.log("Loaded agent.");

const input = `What is the word of the day on merriam webster, and what is the sum of all letter indices (relative to the english alphabet) in the word?`;
console.log(`Executing with input "${input}"...`);
// console.log(`Executing with input "${input}"...`);

const result = await executor.stream({ input, chat_history: [] });
let streamIters = 0;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let finalResponse: any;
for await (const item of result) {
streamIters += 1;
console.log("Stream item:", item);
// console.log("Stream item:", item);
// each stream contains the previous steps
// because returnIntermediateSteps is true),
// so we can overwrite on each stream.
finalResponse = item;
}

console.log("__finalResponse__", finalResponse);
// console.log("__finalResponse__", finalResponse);

expect("intermediateSteps" in finalResponse).toBeTruthy();
expect("output" in finalResponse).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test("createOpenAIFunctionsAgent works", async () => {
input,
});

console.log(result);
// console.log(result);

expect(result.input).toBe(input);
expect(typeof result.output).toBe("string");
Expand Down Expand Up @@ -69,21 +69,21 @@ test("createOpenAIFunctionsAgent can stream log", async () => {
if (!firstChunkTime) {
firstChunkTime = new Date().getTime();
}
console.log(chunk);
// console.log(chunk);
chunks.push(chunk);
}

if (!firstChunkTime) {
throw new Error("firstChunkTime was not set.");
}

console.log(chunks.length);
console.log();
console.log(
"Time to complete after first chunk:",
new Date().getTime() - firstChunkTime
);
// console.log(chunks.length);
// console.log();
// console.log(
// "Time to complete after first chunk:",
// new Date().getTime() - firstChunkTime
// );

console.log(chunks.length);
// console.log(chunks.length);
expect(chunks.length).toBeGreaterThan(1);
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test("createOpenAIToolsAgent works", async () => {
input,
});

console.log(result);
// console.log(result);

expect(result.input).toBe(input);
expect(typeof result.output).toBe("string");
Expand Down Expand Up @@ -63,8 +63,10 @@ test.skip("createOpenAIToolsAgent tracing works when it is nested in a lambda",
const noop = RunnableLambda.from(() => "hi").withConfig({
runName: "nested_testing",
});
// @eslint-disable-next-line/@typescript-eslint/ban-ts-comment
// @ts-expect-error unused var
const noopRes = await noop.invoke({ nested: "nested" });
console.log(noopRes);
// console.log(noopRes);
const res = await agentExecutor.invoke({
input,
});
Expand All @@ -76,7 +78,7 @@ test.skip("createOpenAIToolsAgent tracing works when it is nested in a lambda",
callbacks: [new LangChainTracer({ projectName: "langchainjs-tracing-2" })],
});

console.log(result);
// console.log(result);

expect(result.input).toBe(input);
expect(typeof result.output).toBe("string");
Expand Down
2 changes: 1 addition & 1 deletion langchain/src/agents/tests/create_react_agent.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test("createReactAgent works", async () => {
input,
});

console.log(result);
// console.log(result);

expect(result.input).toBe(input);
expect(typeof result.output).toBe("string");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test("createStructuredChatAgent works", async () => {
input,
});

console.log(result);
// console.log(result);

expect(result.input).toBe(input);
expect(typeof result.output).toBe("string");
Expand Down
10 changes: 5 additions & 5 deletions langchain/src/agents/tests/create_tool_calling_agent.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test("createToolCallingAgent works", async () => {
input,
});

console.log(result);
// console.log(result);

expect(result.input).toBe(input);
expect(typeof result.output).toBe("string");
Expand Down Expand Up @@ -91,9 +91,9 @@ test("createToolCallingAgent stream events works", async () => {

for await (const event of eventStream) {
const eventType = event.event;
console.log("Event type: ", eventType);
// console.log("Event type: ", eventType);
if (eventType === "on_chat_model_stream") {
console.log("Content: ", event.data);
// console.log("Content: ", event.data);
}
}
});
Expand Down Expand Up @@ -132,9 +132,9 @@ test("createToolCallingAgent stream events works for multiple turns", async () =

for await (const event of eventStream) {
const eventType = event.event;
console.log("Event type: ", eventType);
// console.log("Event type: ", eventType);
if (eventType === "on_chat_model_stream") {
console.log("Content: ", event.data);
// console.log("Content: ", event.data);
}
}
});
2 changes: 1 addition & 1 deletion langchain/src/agents/tests/create_xml_agent.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test("createXmlAgent works", async () => {
input,
});

console.log(result);
// console.log(result);

expect(result.input).toBe(input);
expect(typeof result.output).toBe("string");
Expand Down
4 changes: 2 additions & 2 deletions langchain/src/agents/tests/react.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test("ReActSingleInputOutputParser identifies final answer", async () => {
});

const parsedOutput = await outputParser.parse(finalAnswerText);
console.log(parsedOutput);
// console.log(parsedOutput);
expect(parsedOutput).toHaveProperty("returnValues");
expect(
"returnValues" in parsedOutput && parsedOutput.returnValues.output
Expand All @@ -28,7 +28,7 @@ test("ReActSingleInputOutputParser identifies agent actions", async () => {
});

const parsedOutput = await outputParser.parse(finalAnswerText);
console.log(parsedOutput);
// console.log(parsedOutput);
expect(parsedOutput).toHaveProperty("toolInput");
expect(parsedOutput).toHaveProperty("tool");
});
Expand Down
14 changes: 8 additions & 6 deletions langchain/src/agents/tests/runnable.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ test("Runnable variant", async () => {
tools,
});

console.log("Loaded agent executor");
// console.log("Loaded agent executor");

const query = "What is the weather in New York?";
console.log(`Calling agent executor with query: ${query}`);
// console.log(`Calling agent executor with query: ${query}`);
// @eslint-disable-next-line/@typescript-eslint/ban-ts-comment
// @ts-expect-error unused var
const result = await executor.invoke({
input: query,
});
console.log(result);
// console.log(result);
});

test("Runnable variant executor astream log", async () => {
Expand Down Expand Up @@ -112,16 +114,16 @@ test("Runnable variant executor astream log", async () => {
tools,
});

console.log("Loaded agent executor");
// console.log("Loaded agent executor");

const query = "What is the weather in New York?";
console.log(`Calling agent executor with query: ${query}`);
// console.log(`Calling agent executor with query: ${query}`);
const stream = await executor.streamLog({
input: query,
});
let hasSeenLLMLogPatch = false;
for await (const chunk of stream) {
console.log(JSON.stringify(chunk));
// console.log(JSON.stringify(chunk));
if (chunk.ops[0].path.includes("ChatOpenAI")) {
hasSeenLLMLogPatch = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const structuredOutputParser = (
const functionCall = output.additional_kwargs.function_call;
const name = functionCall?.name as string;
const inputs = functionCall?.arguments as string;
console.log(functionCall);
// console.log(functionCall);

const jsonInput = JSON.parse(inputs);

Expand Down Expand Up @@ -113,12 +113,14 @@ test("Pass custom structured output parsers", async () => {
tools: [retrieverTool],
});
/** Call invoke on the agent */
// @eslint-disable-next-line/@typescript-eslint/ban-ts-comment
// @ts-expect-error unused var
const res = await executor.invoke({
input: "what did the president say about kentaji brown jackson",
});
console.log({
res,
});
// console.log({
// res,
// });
/**
{
res: {
Expand Down
Loading
Loading