forked from langchain-ai/langchainjs
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6312a7d
commit 5ccb681
Showing
58 changed files
with
8,023 additions
and
4,631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
yarn precommit | ||
npx turbo run precommit |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
nodeLinker: node-modules | ||
|
||
plugins: | ||
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs | ||
spec: "@yarnpkg/plugin-typescript" | ||
|
||
yarnPath: .yarn/releases/yarn-3.4.1.cjs |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
OPENAI_API_KEY=ADD_YOUR_API_KEY_HERE | ||
SERPAPI_API_KEY=ADD_YOUR_API_KEY_HERE |
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "langchain-examples", | ||
"version": "0.0.0", | ||
"private": true, | ||
"description": "Langchain examples", | ||
"main": "./dist/index.js", | ||
"files": [ | ||
"dist/" | ||
], | ||
"scripts": { | ||
"build": "tsc --declaration --outDir dist/", | ||
"start": "yarn build && node -r dotenv/config dist/index.js", | ||
"lint": "eslint src", | ||
"lint:fix": "yarn lint --fix" | ||
}, | ||
"author": "Langchain", | ||
"license": "MIT", | ||
"dependencies": { | ||
"langchain": "workspace:*", | ||
"openai": "^3.1.0", | ||
"serpapi": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"@tsconfig/recommended": "^1.0.2", | ||
"@typescript-eslint/eslint-plugin": "^5.51.0", | ||
"@typescript-eslint/parser": "^5.51.0", | ||
"dotenv": "^16.0.3", | ||
"eslint": "^8.33.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^8.6.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"prettier": "^2.8.3", | ||
"typescript": "^4.9.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { OpenAI } from "langchain"; | ||
import { loadAgent, AgentExecutor } from "langchain/agents"; | ||
import { SerpAPI } from "langchain/tools"; | ||
|
||
export const run = async () => { | ||
const model = new OpenAI(); | ||
const tools = [SerpAPI()]; | ||
|
||
const agent = await loadAgent( | ||
"lc://agents/zero-shot-react-description/agent.json", | ||
{ llm: model, tools } | ||
); | ||
console.log("Loaded agent from Langchain hub"); | ||
|
||
const executor = AgentExecutor.fromAgentAndTools({ | ||
agent, | ||
tools, | ||
returnIntermediateSteps: true, | ||
}); | ||
|
||
const input = "Who is Olivia Wilde's boyfriend?" + | ||
" What is his current age raised to the 0.23 power?"; | ||
console.log(`Executing with input "${input}"...`); | ||
|
||
const result = await executor.call({ input }); | ||
|
||
console.log(`Got output ${result.output}`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import path from "path"; | ||
|
||
const [exampleName, ...args] = process.argv.slice(2); | ||
let runExample; | ||
try { | ||
// eslint-disable-next-line import/no-dynamic-require,global-require | ||
({ run: runExample } = require(path.join(__dirname, exampleName))); | ||
} catch { | ||
throw new Error(`Could not load example ${exampleName}`); | ||
} | ||
|
||
runExample(args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
OPENAI_API_KEY=ADD_YOUR_API_KEY_HERE | ||
SERPAPI_API_KEY=ADD_YOUR_API_KEY_HERE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module.exports = { | ||
extends: [ | ||
"airbnb-base", | ||
"eslint:recommended", | ||
"prettier", | ||
"plugin:@typescript-eslint/recommended", | ||
], | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
parser: "@typescript-eslint/parser", | ||
sourceType: "module", | ||
}, | ||
plugins: ["@typescript-eslint"], | ||
ignorePatterns: ["dist", "node_modules"], | ||
rules: { | ||
"@typescript-eslint/explicit-module-boundary-types": 0, | ||
"@typescript-eslint/no-empty-function": 0, | ||
"@typescript-eslint/no-shadow": 0, | ||
"@typescript-eslint/no-use-before-define": ["error", "nofunc"], | ||
"@typescript-eslint/no-unused-vars": ["warn", { args: "none" }], | ||
"camelcase": 0, | ||
"class-methods-use-this": 0, | ||
"import/extensions": 0, | ||
"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": ["error", { code: 100, tabWidth: 2, ignoreComments: true }], | ||
"no-await-in-loop": 0, | ||
"no-bitwise": 0, | ||
"no-console": 0, | ||
"no-restricted-syntax": 0, | ||
"no-shadow": 0, | ||
"no-underscore-dangle": 0, | ||
"no-use-before-define": 0, | ||
"no-useless-constructor": 0, | ||
"semi": ["error", "always"], | ||
}, | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// babel.config.js | ||
module.exports = {presets: ['@babel/preset-env']}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ | ||
"name": "langchain", | ||
"version": "0.0.4", | ||
"description": "Typescript bindings for langchain", | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist/" | ||
], | ||
"exports": { | ||
".": { | ||
"types": "./dist/cjs/index.d.ts", | ||
"require": "./dist/cjs/index.js", | ||
"import": "./dist/esm/index.js" | ||
}, | ||
"./agents": { | ||
"types": "./dist/cjs/agents/index.d.ts", | ||
"require": "./dist/cjs/agents/index.js", | ||
"import": "./dist/esm/agents/index.js" | ||
}, | ||
"./tools": { | ||
"types": "./dist/cjs/agents/tools/index.d.ts", | ||
"require": "./dist/cjs/agents/tools/index.js", | ||
"import": "./dist/esm/agents/tools/index.js" | ||
}, | ||
"./prompt": { | ||
"types": "./dist/cjs/prompt/index.d.ts", | ||
"require": "./dist/cjs/prompt/index.js", | ||
"import": "./dist/esm/prompt/index.js" | ||
}, | ||
"./chains": { | ||
"types": "./dist/cjs/chains/index.d.ts", | ||
"require": "./dist/cjs/chains/index.js", | ||
"import": "./dist/esm/chains/index.js" | ||
}, | ||
"./llms": { | ||
"types": "./dist/cjs/llms/index.d.ts", | ||
"require": "./dist/cjs/llms/index.js", | ||
"import": "./dist/esm/llms/index.js" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "tsc --declaration --outDir dist/esm --module esnext && tsc --declaration --outDir dist/cjs", | ||
"lint": "eslint .", | ||
"lint:fix": "yarn lint --fix", | ||
"precommit": "tsc --noEmit && lint-staged", | ||
"clean": "rm -rf dist/", | ||
"prepack": "yarn build", | ||
"test": "jest", | ||
"prepare": "husky install" | ||
}, | ||
"author": "Langchain", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@babel/core": "^7.20.12", | ||
"@babel/preset-env": "^7.20.2", | ||
"@jest/globals": "^29.4.2", | ||
"@tsconfig/recommended": "^1.0.2", | ||
"@types/node-fetch": "2", | ||
"@typescript-eslint/eslint-plugin": "^5.51.0", | ||
"@typescript-eslint/parser": "^5.51.0", | ||
"babel-jest": "^29.4.2", | ||
"dotenv": "^16.0.3", | ||
"eslint": "^8.33.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^8.6.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"husky": "^8.0.3", | ||
"jest": "^29.4.2", | ||
"lint-staged": "^13.1.1", | ||
"openai": "^3.1.0", | ||
"prettier": "^2.8.3", | ||
"serpapi": "^1.1.0", | ||
"ts-jest": "^29.0.5", | ||
"typescript": "^4.9.5" | ||
}, | ||
"dependencies": { | ||
"exponential-backoff": "^3.1.0", | ||
"node-fetch": "2", | ||
"yaml": "^2.2.1" | ||
}, | ||
"optionalDependencies": { | ||
"openai": "^3.1.0", | ||
"serpapi": "^1.1.0" | ||
}, | ||
"lint-staged": { | ||
"**/*.{ts,tsx}": [ | ||
"prettier --write --ignore-unknown", | ||
"eslint --cache --fix" | ||
] | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"extends": "@tsconfig/recommended", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"lib": ["ESNext", "DOM"], | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"allowSyntheticDefaultImports": true, | ||
"baseUrl": "./", | ||
"declaration": true, | ||
"experimentalDecorators": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"useDefineForClassFields": true, | ||
"strictPropertyInitialization": false | ||
}, | ||
"exclude": ["node_modules/", "dist/", "tests/"], | ||
"include": ["./"] | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.