Giter VIP home page Giter VIP logo

langchain-ts-starter's Introduction

langchain-ts-starter

Boilerplate to get started quickly with the Langchain Typescript SDK.

This uses the same tsconfig and build setup as the examples repo, to ensure it's in sync with the official docs.

What's included

  • Typescript
  • .env file configuration
  • ESLint and Prettier for formatting
  • Turborepo to quickly run build scripts
  • tsup to bundle Typescript code
  • tsx to quickly run compiled code

How to use

  • Clone this repository
  • npm install
  • Write your code in src
  • npx turbo run build lint format to run build scripts quickly in parallel
  • npm start to run your program

langchain-ts-starter's People

Contributors

domeccleston avatar yukyu30 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

langchain-ts-starter's Issues

how to use could use some more info

the README for this repo doesn't really fully get someone up and running. i didn't have turbo installed so first i got an error for the turbo command not being found... ok i solved that, but now when I try running the turbo run build lint check command, i get this error:

Turbo error: error preparing engine: Could not find the following tasks in project: check

having a harder time finding the solution to that...

seems like some additional instructions could be helpful for this...

Module resolution error.

Hi, I'm trying to use the template but I get an error related to module resolution. My node version is node 18.16 and my OS is Windows 10.

Process followed:

  1. Cloned the repository.
  2. Executed npm install.
  3. Checked if the example works and it worked.
  4. Created a folder on src src/foo and created a file src/foo/bar.ts.
  5. Created some functions using langchain components and exported them.
  6. Tried to import those functions on src/index.ts.

The error Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './marko-assistant/assistant.js'?ts(2835)

I tried the suggested solution and it worked but I find it weird.

My tsconfig { "extends": "@tsconfig/recommended", "compilerOptions": { "outDir": "dist", "lib": ["ES2021", "ES2022.Object", "DOM"], "target": "es2017", "module": "nodenext", "sourceMap": true, "allowSyntheticDefaultImports": true, "baseUrl": "./src", "declaration": true, "experimentalDecorators": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "noUnusedLocals": true, "noUnusedParameters": true, "useDefineForClassFields": true, "strictPropertyInitialization": false }, "exclude": ["node_modules/", "dist/", "tests/"], "include": ["./src"] }
I would thank some guidance, i'm pretty new to this. Really thanks.

Top-level await is currently not supported with the "cjs" output format

I have a problem for that

`
✘ [ERROR] Top-level await is currently not supported with the "cjs" output format

src/index.ts:11:12:
11 │ const res = await model.call(
╵ ~~~~~

CJS Build failed
and i change the file tsconfig.json
"target": "es2022",
"module": "nodenext",
`

it doesn't , and google not helpful .
so can tell me how to fix that ?

Getting "Headers is not defined" when using this starter

Tried to use the starter but get the following error when running npm start:

$ npm start

[email protected] start
tsx -r dotenv/config src/index.ts

ReferenceError: Headers is not defined
at createRequest (file:///Users/brian_pulitous.ibm.com/git/langchain-ts-starter/node_modules/langchain/src/util/axios-fetch-adapter.js:273:19)
at fetchAdapter (file:///Users/brian_pulitous.ibm.com/git/langchain-ts-starter/node_modules/langchain/src/util/axios-fetch-adapter.js:196:19)
at dispatchRequest (/Users/brian_pulitous.ibm.com/git/langchain-ts-starter/node_modules/axios/lib/core/dispatchRequest.js:58:10)
at Axios.request (/Users/brian_pulitous.ibm.com/git/langchain-ts-starter/node_modules/axios/lib/core/Axios.js:108:15)
at Function.wrap [as request] (/Users/brian_pulitous.ibm.com/git/langchain-ts-starter/node_modules/axios/lib/helpers/bind.js:9:15)
at /Users/brian_pulitous.ibm.com/git/langchain-ts-starter/node_modules/openai/dist/common.js:149:22
at /Users/brian_pulitous.ibm.com/git/langchain-ts-starter/node_modules/openai/dist/api.js:1738:133

Any ideas what might be going run?

When I run 'npm start', it prints 'Headers is not defined'. I can run 'npx turbo run build lint format' successfully.

ReferenceError: Headers is not defined
at createRequest (/Users/zhangchaoqun/Developer/study/langchain/langchain-ts-starter/node_modules/langchain/src/util/axios-fetch-adapter.js:273:19)
at fetchAdapter (/Users/zhangchaoqun/Developer/study/langchain/langchain-ts-starter/node_modules/langchain/src/util/axios-fetch-adapter.js:196:19)
at dispatchRequest (/Users/zhangchaoqun/Developer/study/langchain/langchain-ts-starter/node_modules/axios/lib/core/dispatchRequest.js:58:10)
at Axios.request (/Users/zhangchaoqun/Developer/study/langchain/langchain-ts-starter/node_modules/axios/lib/core/Axios.js:108:15)
at Function.wrap (/Users/zhangchaoqun/Developer/study/langchain/langchain-ts-starter/node_modules/axios/lib/helpers/bind.js:9:15)
at (/Users/zhangchaoqun/Developer/study/langchain/langchain-ts-starter/node_modules/openai/dist/common.js:149:22)
at (/Users/zhangchaoqun/Developer/study/langchain/langchain-ts-starter/node_modules/openai/dist/api.js:1740:133)

ESM Build start : [ERROR] Top-level await is not available in the configured target environment ("es2017")

Hello everyone,

I've just cloned this repo and followed the instruction, but I get this error below when building the project. I've changed the target to es2020 but I got the same error :

➜ langchain-ts-starter git:(main) ✗ npx turbo run build lint format
• Running build, lint, format
• Remote caching disabled
lint: Skipping cache check for //#lint, outputs have not changed since previous run.
lint: cache hit, replaying output ba1d93610b79d22b
format: Skipping cache check for //#format, outputs have not changed since previous run.
format: cache hit, replaying output b62b0263feb4282c
build: cache miss, executing c0464e17a9d1b044
lint:
lint: > [email protected] lint
lint: > eslint src
lint:
format:
format: > [email protected] format
format: > prettier --write "**/*.ts"
format:
format: dist/index.d.ts 278ms
format: src/index.ts 34ms
build:
build: > [email protected] build
build: > tsup
build:
build: CLI Building entry: src/index.ts
build: CLI Using tsconfig: tsconfig.json
build: CLI tsup v6.7.0
build: CLI Using tsup config: /Users/bakanndy/may/langchain-ts-starter/tsup.config.js
build: CLI Target: es2017
build: CLI Cleaning output folder
build: CJS Build start
build: ESM Build start
build: ✘ [ERROR] Top-level await is not available in the configured target environment ("es2017")
build:
build: src/index.ts:11:12:
build: 11 │ const res = await model.call(
build: ╵ ~~~~~
build:
build: ✘ [ERROR] Top-level await is not available in the configured target environment ("es2017")
build:
build: src/index.ts:11:12:
build: 11 │ const res = await model.call(
build: ╵ ~~~~~
build:
build: CJS Build failed
build: Error: Build failed with 1 error:
build: src/index.ts:11:12: ERROR: Top-level await is not available in the configured target environment ("es2017")
build: at failureErrorWithLog (/Users/bakanndy/may/langchain-ts-starter/node_modules/esbuild/lib/main.js:1636:15)
build: at /Users/bakanndy/may/langchain-ts-starter/node_modules/esbuild/lib/main.js:1048:25
build: at runOnEndCallbacks (/Users/bakanndy/may/langchain-ts-starter/node_modules/esbuild/lib/main.js:1471:45)
build: at buildResponseToResult (/Users/bakanndy/may/langchain-ts-starter/node_modules/esbuild/lib/main.js:1046:7)
build: at /Users/bakanndy/may/langchain-ts-starter/node_modules/esbuild/lib/main.js:1075:16
build: at responseCallbacks. (/Users/bakanndy/may/langchain-ts-starter/node_modules/esbuild/lib/main.js:697:9)
build: at handleIncomingPacket (/Users/bakanndy/may/langchain-ts-starter/node_modules/esbuild/lib/main.js:752:9)
build: at Socket.readFromStdout (/Users/bakanndy/may/langchain-ts-starter/node_modules/esbuild/lib/main.js:673:7)
build: at Socket.emit (node:events:390:28)
build: at addChunk (node:internal/streams/readable:315:12)
build: ESM Build failed
build: DTS Build start
build: DTS ⚡️ Build success in 2160ms
build: DTS dist/index.d.ts 12.00 B
build: ERROR: command finished with error: command (/Users/bakanndy/may/langchain-ts-starter) npm run build exited (1)
command (/Users/bakanndy/may/langchain-ts-starter) npm run build exited (1)

Tasks: 2 successful, 3 total
Cached: 2 cached, 3 total
Time: 3.551s
Failed: //#build

ERROR run failed: command exited (1)
➜ langchain-ts-starter git:(main) ✗

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.