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

google-genai[patch],openai[patch]: Test nits #6008

Merged
merged 4 commits into from
Jul 9, 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
6 changes: 5 additions & 1 deletion .github/workflows/standard-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
DISABLE_CONSOLE_LOGS: "true"

# The `@langchain/openai` package contains standard tests for ChatOpenAI and AzureChatOpenAI
# We want to run these separately, so we need to pass the exact path for each test, which means
Expand All @@ -50,6 +51,7 @@ jobs:
run: yarn workspace @langchain/openai test:single src/tests/chat_models_structured_output.int.test.ts src/tests/chat_models-extended.int.test.ts src/tests/chat_models-vision.int.test.ts src/tests/chat_models.int.test.ts src/tests/chat_models.standard.int.test.ts
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
DISABLE_CONSOLE_LOGS: "true"

standard-tests-azure-openai:
runs-on: ubuntu-latest
Expand All @@ -71,6 +73,7 @@ jobs:
AZURE_OPENAI_API_DEPLOYMENT_NAME: "chat"
AZURE_OPENAI_API_VERSION: ${{ secrets.AZURE_OPENAI_API_VERSION }}
AZURE_OPENAI_BASE_PATH: ${{ secrets.AZURE_OPENAI_BASE_PATH }}
DISABLE_CONSOLE_LOGS: "true"

standard-tests-bedrock:
runs-on: ubuntu-latest
Expand All @@ -90,4 +93,5 @@ jobs:
env:
BEDROCK_AWS_REGION: "us-east-1"
BEDROCK_AWS_SECRET_ACCESS_KEY: ${{ secrets.BEDROCK_AWS_SECRET_ACCESS_KEY }}
BEDROCK_AWS_ACCESS_KEY_ID: ${{ secrets.BEDROCK_AWS_ACCESS_KEY_ID }}
BEDROCK_AWS_ACCESS_KEY_ID: ${{ secrets.BEDROCK_AWS_ACCESS_KEY_ID }}
DISABLE_CONSOLE_LOGS: "true"
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ test("Test Google AI in streaming mode", async () => {
],
});
console.log({ tokens, nrNewTokens });
expect(nrNewTokens > 1).toBe(true);
expect(nrNewTokens).toBeGreaterThan(1);
expect(res.content).toBe(tokens);
} finally {
// Reset the environment variable
Expand Down
6 changes: 6 additions & 0 deletions libs/langchain-openai/scripts/jest-setup-after-env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { awaitAllCallbacks } from "@langchain/core/callbacks/promises";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there! I noticed that the recent change in jest-setup-after-env.js adds code to access an environment variable using process.env. This comment is just to flag this change for your review. Keep up the great work!

import { afterAll, jest } from "@jest/globals";

afterAll(awaitAllCallbacks);

// Allow console.log to be disabled in tests
if (process.env.DISABLE_CONSOLE_LOGS === "true") {
console.log = jest.fn();
}
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ test("Test Azure ChatOpenAI stream method, timeout error thrown from SDK", async
maxTokens: 50,
modelName: "gpt-3.5-turbo",
timeout: 1,
maxRetries: 0,
});
const stream = await model.stream(
"How is your day going? Be extremely verbose."
Expand Down
Loading