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

community[minor]: Fix CI #3601

Merged
merged 6 commits into from
Dec 9, 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
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ version: "3"
services:
test-exports-esbuild:
image: node:18
environment:
PUPPETEER_SKIP_DOWNLOAD: "true"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true"
working_dir: /app
volumes:
- ./yarn.lock:/root/yarn.lock
Expand All @@ -17,6 +20,9 @@ services:
command: bash /scripts/docker-ci-entrypoint.sh
test-exports-esm:
image: node:18
environment:
PUPPETEER_SKIP_DOWNLOAD: "true"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true"
working_dir: /app
volumes:
- ./yarn.lock:/root/yarn.lock
Expand All @@ -32,6 +38,9 @@ services:
command: bash /scripts/docker-ci-entrypoint.sh
test-exports-cjs:
image: node:18
environment:
PUPPETEER_SKIP_DOWNLOAD: "true"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true"
working_dir: /app
volumes:
- ./yarn.lock:/root/yarn.lock
Expand All @@ -47,6 +56,9 @@ services:
command: bash /scripts/docker-ci-entrypoint.sh
test-exports-cf:
image: node:18
environment:
PUPPETEER_SKIP_DOWNLOAD: "true"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true"
working_dir: /app
volumes:
- ./yarn.lock:/root/yarn.lock
Expand All @@ -62,6 +74,9 @@ services:
command: bash /scripts/docker-ci-entrypoint.sh
test-exports-vercel:
image: node:18
environment:
PUPPETEER_SKIP_DOWNLOAD: "true"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true"
working_dir: /app
volumes:
- ./yarn.lock:/root/yarn.lock
Expand All @@ -77,6 +92,9 @@ services:
command: bash /scripts/docker-ci-entrypoint.sh
test-exports-vite:
image: node:18
environment:
PUPPETEER_SKIP_DOWNLOAD: "true"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "true"
working_dir: /app
volumes:
- ./yarn.lock:/root/yarn.lock
Expand Down
21 changes: 12 additions & 9 deletions environment_tests/scripts/docker-ci-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,23 @@ shopt -s extglob
# avoid copying build artifacts from the host
cp -r ../package/!(node_modules|dist|dist-cjs|dist-esm|build|.next|.turbo) .

mkdir -p ./libs/langchain-core/
mkdir -p ./libs/langchain-openai/
mkdir -p ./libs/langchain-anthropic/
mkdir -p ./libs/langchain-community/
mkdir -p ./libs/langchain/

cp -r ../langchain-core ./libs/
cp -r ../langchain-openai ./libs/
cp -r ../langchain-anthropic ./libs/
cp -r ../langchain-community ./libs/
cp -r ../langchain ./libs/

# copy cache
mkdir -p ./.yarn
cp -r ../root/.yarn/!(berry|cache) ./.yarn
cp ../root/yarn.lock ../root/.yarnrc.yml .

# Replace the workspace dependency with the local copy, and install all others
# Avoid calling "yarn add ../langchain" as yarn berry does seem to hang for ~30s
# before installation actually occurs
sed -i 's/"@langchain\/core": "workspace:\*"/"@langchain\/core": "..\/langchain-core"/g' package.json
sed -i 's/"@langchain\/community": "workspace:\*"/"@langchain\/community": "..\/langchain-community"/g' package.json
sed -i 's/"@langchain\/anthropic": "workspace:\*"/"@langchain\/anthropic": "..\/langchain-anthropic"/g' package.json
sed -i 's/"@langchain\/openai": "workspace:\*"/"@langchain\/openai": "..\/langchain-openai"/g' package.json
sed -i 's/"langchain": "workspace:\*"/"langchain": "..\/langchain"/g' package.json

yarn install --no-immutable

# Check the build command completes successfully
Expand Down
3 changes: 3 additions & 0 deletions environment_tests/test-exports-cf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "test-exports-cf",
"version": "0.0.0",
"workspaces": [
"libs/*"
],
"devDependencies": {
"@cloudflare/workers-types": "^4.20230321.0",
"typescript": "^5.0.3",
Expand Down
3 changes: 3 additions & 0 deletions environment_tests/test-exports-cjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "test-exports-cjs",
"version": "0.0.0",
"workspaces": [
"libs/*"
],
"private": true,
"description": "CJS Tests for the things exported by the langchain package",
"main": "./index.mjs",
Expand Down
3 changes: 3 additions & 0 deletions environment_tests/test-exports-esbuild/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "test-exports-esbuild",
"version": "0.0.0",
"workspaces": [
"libs/*"
],
"private": true,
"description": "Tests for the things exported by the langchain package",
"main": "./index.mjs",
Expand Down
3 changes: 3 additions & 0 deletions environment_tests/test-exports-esm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "test-exports-esm",
"version": "0.0.0",
"workspaces": [
"libs/*"
],
"private": true,
"description": "Tests for the things exported by the langchain package",
"main": "./index.mjs",
Expand Down
3 changes: 3 additions & 0 deletions environment_tests/test-exports-vercel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "test-exports-vercel",
"version": "0.1.0",
"workspaces": [
"libs/*"
],
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
5 changes: 4 additions & 1 deletion environment_tests/test-exports-vercel/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"exclude": [
"node_modules",
"libs"
]
}
5 changes: 4 additions & 1 deletion environment_tests/test-exports-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"name": "test-exports-vite",
"private": true,
"version": "0.0.0",
"workspaces": [
"libs/*"
],
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
90 changes: 1 addition & 89 deletions langchain/src/cache/ioredis.ts
Original file line number Diff line number Diff line change
@@ -1,89 +1 @@
import { Redis } from "ioredis";
import { BaseCache, Generation } from "../schema/index.js";
import {
serializeGeneration,
deserializeStoredGeneration,
getCacheKey,
} from "./base.js";

/**
* Cache LLM results using Redis.
* @example
* ```typescript
* const model = new ChatOpenAI({
* cache: new RedisCache(new Redis(), { ttl: 60 }),
* });
*
* // Invoke the model with a prompt
* const response = await model.invoke("Do something random!");
* console.log(response);
*
* // Remember to disconnect the Redis client when done
* await redisClient.disconnect();
* ```
*/
export class RedisCache extends BaseCache {
protected redisClient: Redis;

protected ttl?: number;

constructor(
redisClient: Redis,
config?: {
ttl?: number;
}
) {
super();
this.redisClient = redisClient;
this.ttl = config?.ttl;
}

/**
* Retrieves data from the Redis server using a prompt and an LLM key. If
* the data is not found, it returns null.
* @param prompt The prompt used to find the data.
* @param llmKey The LLM key used to find the data.
* @returns The corresponding data as an array of Generation objects, or null if not found.
*/
public async lookup(prompt: string, llmKey: string) {
let idx = 0;
let key = getCacheKey(prompt, llmKey, String(idx));
let value = await this.redisClient.get(key);
const generations: Generation[] = [];

while (value) {
const storedGeneration = JSON.parse(value);
generations.push(deserializeStoredGeneration(storedGeneration));
idx += 1;
key = getCacheKey(prompt, llmKey, String(idx));
value = await this.redisClient.get(key);
}

return generations.length > 0 ? generations : null;
}

/**
* Updates the data in the Redis server using a prompt and an LLM key.
* @param prompt The prompt used to store the data.
* @param llmKey The LLM key used to store the data.
* @param value The data to be stored, represented as an array of Generation objects.
*/
public async update(prompt: string, llmKey: string, value: Generation[]) {
for (let i = 0; i < value.length; i += 1) {
const key = getCacheKey(prompt, llmKey, String(i));
if (this.ttl !== undefined) {
await this.redisClient.set(
key,
JSON.stringify(serializeGeneration(value[i])),
"EX",
this.ttl
);
} else {
await this.redisClient.set(
key,
JSON.stringify(serializeGeneration(value[i]))
);
}
}
}
}
export * from "@langchain/community/caches/ioredis";
2 changes: 0 additions & 2 deletions langchain/src/load/import_type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,6 @@ export interface OptionalImportMap {

export interface SecretMap {
ANTHROPIC_API_KEY?: string;
AWS_ACCESS_KEY_ID?: string;
AWS_SECRET_ACCESS_KEY?: string;
OPENAI_API_KEY?: string;
PROMPTLAYER_API_KEY?: string;
REMOTE_RETRIEVER_AUTH_BEARER?: string;
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain-community/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@cloudflare/ai": "^1.0.12",
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 a new development dependency, "@faker-js/faker": "^7.6.0", has been added to the project's package.json file. I've flagged this for your review to ensure it aligns with our project's dependencies. Keep up the great work! 🚀

"@cloudflare/workers-types": "^4.20230922.0",
"@elastic/elasticsearch": "^8.4.0",
"@faker-js/faker": "^7.6.0",
"@getmetal/metal-sdk": "^4.0.0",
"@getzep/zep-js": "^0.9.0",
"@gomomento/sdk": "^1.51.1",
Expand Down Expand Up @@ -173,7 +174,6 @@
"@clickhouse/client": "^0.2.5",
"@cloudflare/ai": "^1.0.12",
"@elastic/elasticsearch": "^8.4.0",
"@faker-js/faker": "^7.6.0",
"@getmetal/metal-sdk": "*",
"@getzep/zep-js": "^0.9.0",
"@gomomento/sdk": "^1.51.1",
Expand Down
5 changes: 5 additions & 0 deletions libs/langchain-community/scripts/create-entrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ const deprecatedNodeOnly = [];
// Therefore they are not tested in the generated test-exports-* packages.
const requiresOptionalDependency = [
"tools/aws_sfn",
"tools/aws_lambda",
"tools/gmail",
"agents/toolkits/aws_sfn",
"callbacks/handlers/llmonitor",
"embeddings/bedrock",
"embeddings/cloudflare_workersai",
Expand Down Expand Up @@ -283,6 +285,9 @@ const requiresOptionalDependency = [
"stores/message/redis",
"stores/message/upstash_redis",
"stores/message/xata",
// memory
"memory/motorhead_memory",
"memory/zep",
];

const updateJsonFile = (relativePath, updateFunction) => {
Expand Down
4 changes: 4 additions & 0 deletions libs/langchain-community/src/load/import_constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Auto-generated by `scripts/create-entrypoints.js`. Do not edit manually.

export const optionalImportEntrypoints = [
"langchain_community/tools/aws_lambda",
"langchain_community/tools/aws_sfn",
"langchain_community/tools/gmail",
"langchain_community/agents/toolkits/aws_sfn",
"langchain_community/embeddings/bedrock",
"langchain_community/embeddings/cloudflare_workersai",
"langchain_community/embeddings/cohere",
Expand Down Expand Up @@ -96,4 +98,6 @@ export const optionalImportEntrypoints = [
"langchain_community/stores/message/redis",
"langchain_community/stores/message/upstash_redis",
"langchain_community/stores/message/xata",
"langchain_community/memory/motorhead_memory",
"langchain_community/memory/zep",
];
4 changes: 0 additions & 4 deletions libs/langchain-community/src/load/import_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

export * as load__serializable from "../load/serializable.js";
export * as tools__aiplugin from "../tools/aiplugin.js";
export * as tools__aws_lambda from "../tools/aws_lambda.js";
export * as tools__bingserpapi from "../tools/bingserpapi.js";
export * as tools__brave_search from "../tools/brave_search.js";
export * as tools__connery from "../tools/connery.js";
Expand All @@ -18,7 +17,6 @@ export * as tools__serpapi from "../tools/serpapi.js";
export * as tools__serper from "../tools/serper.js";
export * as tools__wikipedia_query_run from "../tools/wikipedia_query_run.js";
export * as tools__wolframalpha from "../tools/wolframalpha.js";
export * as agents__toolkits__aws_sfn from "../agents/toolkits/aws_sfn.js";
export * as agents__toolkits__base from "../agents/toolkits/base.js";
export * as agents__toolkits__connery from "../agents/toolkits/connery/index.js";
export * as embeddings__minimax from "../embeddings/minimax.js";
Expand Down Expand Up @@ -50,5 +48,3 @@ export * as stores__doc__base from "../stores/doc/base.js";
export * as stores__doc__in_memory from "../stores/doc/in_memory.js";
export * as stores__message__in_memory from "../stores/message/in_memory.js";
export * as memory__chat_memory from "../memory/chat_memory.js";
export * as memory__motorhead_memory from "../memory/motorhead_memory.js";
export * as memory__zep from "../memory/zep.js";
12 changes: 12 additions & 0 deletions libs/langchain-community/src/load/import_type.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
// Auto-generated by `scripts/create-entrypoints.js`. Do not edit manually.

export interface OptionalImportMap {
"@langchain/community/tools/aws_lambda"?:
| typeof import("../tools/aws_lambda.js")
| Promise<typeof import("../tools/aws_lambda.js")>;
"@langchain/community/tools/aws_sfn"?:
| typeof import("../tools/aws_sfn.js")
| Promise<typeof import("../tools/aws_sfn.js")>;
"@langchain/community/tools/gmail"?:
| typeof import("../tools/gmail/index.js")
| Promise<typeof import("../tools/gmail/index.js")>;
"@langchain/community/agents/toolkits/aws_sfn"?:
| typeof import("../agents/toolkits/aws_sfn.js")
| Promise<typeof import("../agents/toolkits/aws_sfn.js")>;
"@langchain/community/embeddings/bedrock"?:
| typeof import("../embeddings/bedrock.js")
| Promise<typeof import("../embeddings/bedrock.js")>;
Expand Down Expand Up @@ -286,6 +292,12 @@ export interface OptionalImportMap {
"@langchain/community/stores/message/xata"?:
| typeof import("../stores/message/xata.js")
| Promise<typeof import("../stores/message/xata.js")>;
"@langchain/community/memory/motorhead_memory"?:
| typeof import("../memory/motorhead_memory.js")
| Promise<typeof import("../memory/motorhead_memory.js")>;
"@langchain/community/memory/zep"?:
| typeof import("../memory/zep.js")
| Promise<typeof import("../memory/zep.js")>;
}

export interface SecretMap {
Expand Down
1 change: 1 addition & 0 deletions libs/langchain-openai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@langchain/core": "~0.0.11-rc.1",
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 addition of "zod": "^3.22.3" in the package.json file seems to be a devDependency change. I've flagged this for your review. Keep up the great work!

"js-tiktoken": "^1.0.7",
"openai": "^4.19.0",
"zod": "^3.22.3",
"zod-to-json-schema": "3.20.3"
},
"devDependencies": {
Expand Down
Loading