From bfbc0a2958702690a6d1266d205952956c98bf4c Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Tue, 30 Jan 2024 13:49:21 -0800 Subject: [PATCH] create-langchain-integration[minor]: Update copied files (#4209) * create-langchain-integration[minor]: Update copied files * chore: lint files * chore: lint files --- .../helpers/default_file_contents.ts | 198 ------------------ .../helpers/templates.ts | 17 -- .../template/.release-it.json | 10 + .../template/package.json | 2 +- 4 files changed, 11 insertions(+), 216 deletions(-) delete mode 100644 libs/create-langchain-integration/helpers/default_file_contents.ts create mode 100644 libs/create-langchain-integration/template/.release-it.json diff --git a/libs/create-langchain-integration/helpers/default_file_contents.ts b/libs/create-langchain-integration/helpers/default_file_contents.ts deleted file mode 100644 index 8b3882c95cb1..000000000000 --- a/libs/create-langchain-integration/helpers/default_file_contents.ts +++ /dev/null @@ -1,198 +0,0 @@ -export const DEFAULT_ESLINTRC = `module.exports = { - extends: [ - "airbnb-base", - "eslint:recommended", - "prettier", - "plugin:@typescript-eslint/recommended", - ], - parserOptions: { - ecmaVersion: 12, - parser: "@typescript-eslint/parser", - project: "./tsconfig.json", - sourceType: "module", - }, - plugins: ["@typescript-eslint", "no-instanceof"], - ignorePatterns: [ - ".eslintrc.cjs", - "scripts", - "node_modules", - "dist", - "dist-cjs", - "*.js", - "*.cjs", - "*.d.ts", - ], - rules: { - "no-process-env": 2, - "no-instanceof/no-instanceof": 2, - "@typescript-eslint/explicit-module-boundary-types": 0, - "@typescript-eslint/no-empty-function": 0, - "@typescript-eslint/no-shadow": 0, - "@typescript-eslint/no-empty-interface": 0, - "@typescript-eslint/no-use-before-define": ["error", "nofunc"], - "@typescript-eslint/no-unused-vars": ["warn", { args: "none" }], - "@typescript-eslint/no-floating-promises": "error", - "@typescript-eslint/no-misused-promises": "error", - camelcase: 0, - "class-methods-use-this": 0, - "import/extensions": [2, "ignorePackages"], - "import/no-extraneous-dependencies": [ - "error", - { devDependencies: ["**/*.test.ts"] }, - ], - "import/no-unresolved": 0, - "import/prefer-default-export": 0, - "keyword-spacing": "error", - "max-classes-per-file": 0, - "max-len": 0, - "no-await-in-loop": 0, - "no-bitwise": 0, - "no-console": 0, - "no-restricted-syntax": 0, - "no-shadow": 0, - "no-continue": 0, - "no-void": 0, - "no-underscore-dangle": 0, - "no-use-before-define": 0, - "no-useless-constructor": 0, - "no-return-await": 0, - "consistent-return": 0, - "no-else-return": 0, - "func-names": 0, - "no-lonely-if": 0, - "prefer-rest-params": 0, - "new-cap": ["error", { properties: false, capIsNew: false }], - }, -}; -`; - -export const DEFAULT_README = `# @langchain/ - -This package contains the LangChain.js integrations for through their SDK. - -## Installation - -\`\`\`bash npm2yarn -npm install @langchain/ -\`\`\` - -## Chat Models - -This package contains the \`\` class, which is the recommended way to interface with the series of models. - -To use, install the requirements, and configure your environment. - -\`\`\`bash -export =your-api-key -\`\`\` - -Then initialize - -\`\`\`typescript -import { } from "@langchain/"; - -const model = new ExampleChatClass({ - apiKey: process.env.EXAMPLE_API_KEY, -}); -const response = await model.invoke(new HumanMessage("Hello world!")); -\`\`\` - -### Streaming - -\`\`\`typescript -import { } from "@langchain/"; - -const model = new ExampleChatClass({ - apiKey: process.env.EXAMPLE_API_KEY, -}); -const response = await model.stream(new HumanMessage("Hello world!")); -\`\`\` - -## Embeddings - -This package also adds support for embeddings model. - -\`\`\`typescript -import { } from "@langchain/"; - -const embeddings = new ExampleEmbeddingClass({ - apiKey: process.env.EXAMPLE_API_KEY, -}); -const res = await embeddings.embedQuery("Hello world"); -\`\`\` - -## Development - -To develop the package, you'll need to follow these instructions: - -### Install dependencies - -\`\`\`bash -yarn install -\`\`\` - -### Build the package - -\`\`\`bash -yarn build -\`\`\` - -Or from the repo root: - -\`\`\`bash -yarn build --filter=@langchain/ -\`\`\` - -### Run tests - -Test files should live within a \`tests/\` file in the \`src/\` folder. Unit tests should end in \`.test.ts\` and integration tests should -end in \`.int.test.ts\`: - -\`\`\`bash -$ yarn test -$ yarn test:int -\`\`\` - -### Lint & Format - -Run the linter & formatter to ensure your code is up to standard: - -\`\`\`bash -yarn lint && yarn format -\`\`\` - -### Adding new entrypoints - -If you add a new file to be exported, either import & re-export from \`src/index.ts\`, or add it to \`scripts/create-entrypoints.js\` and run \`yarn build\` to generate the new entrypoint. -`; - -export const DEFAULT_RELEASE_IT = { - github: { - release: true, - autoGenerate: true, - tokenRef: "GITHUB_TOKEN_RELEASE", - }, - npm: { - versionArgs: ["--workspaces-update=false"], - }, -}; - -export const DEFAULT_PRETTIERRC = { - $schema: "https://json.schemastore.org/prettierrc", - printWidth: 80, - tabWidth: 2, - useTabs: false, - semi: true, - singleQuote: false, - quoteProps: "as-needed", - jsxSingleQuote: false, - trailingComma: "es5", - bracketSpacing: true, - arrowParens: "always", - requirePragma: false, - insertPragma: false, - proseWrap: "preserve", - htmlWhitespaceSensitivity: "css", - vueIndentScriptAndStyle: false, - endOfLine: "lf", -}; diff --git a/libs/create-langchain-integration/helpers/templates.ts b/libs/create-langchain-integration/helpers/templates.ts index 0c7eff648ec4..2a3d0f8603f2 100644 --- a/libs/create-langchain-integration/helpers/templates.ts +++ b/libs/create-langchain-integration/helpers/templates.ts @@ -3,12 +3,6 @@ import fs from "fs/promises"; import os from "os"; import { copy } from "./copy"; -import { - DEFAULT_ESLINTRC, - DEFAULT_README, - DEFAULT_RELEASE_IT, - DEFAULT_PRETTIERRC, -} from "./default_file_contents"; /** * Install a internal template to a given `root` directory. @@ -46,16 +40,5 @@ export async function installTemplate({ appName, root }: any) { ["node_modules", "dist", ".yarn"].join("\n") + os.EOL ); - await fs.writeFile(path.join(root, ".eslintrc.cjs"), DEFAULT_ESLINTRC); - await fs.writeFile(path.join(root, "README.md"), DEFAULT_README); - await fs.writeFile( - path.join(root, ".release-it.json"), - `${JSON.stringify(DEFAULT_RELEASE_IT)}\n` - ); - await fs.writeFile( - path.join(root, ".prettierrc"), - `${JSON.stringify(DEFAULT_PRETTIERRC)}\n` - ); - console.log("\nDone!\n"); } diff --git a/libs/create-langchain-integration/template/.release-it.json b/libs/create-langchain-integration/template/.release-it.json new file mode 100644 index 000000000000..522ee6abf705 --- /dev/null +++ b/libs/create-langchain-integration/template/.release-it.json @@ -0,0 +1,10 @@ +{ + "github": { + "release": true, + "autoGenerate": true, + "tokenRef": "GITHUB_TOKEN_RELEASE" + }, + "npm": { + "versionArgs": ["--workspaces-update=false"] + } +} diff --git a/libs/create-langchain-integration/template/package.json b/libs/create-langchain-integration/template/package.json index 2ce5a3622544..f51f4d239078 100644 --- a/libs/create-langchain-integration/template/package.json +++ b/libs/create-langchain-integration/template/package.json @@ -43,7 +43,7 @@ "@jest/globals": "^29.5.0", "@swc/core": "^1.3.90", "@swc/jest": "^0.2.29", - "@langchain/scripts": "^0.0.2", + "@langchain/scripts": "~0.0", "@tsconfig/recommended": "^1.0.3", "@typescript-eslint/eslint-plugin": "^6.12.0", "@typescript-eslint/parser": "^6.12.0",