@beparallel/langchain-ts
v1.0.0
Published
Extracts Langchain prompts and generates TypeScript types.
Readme
@beparallel/langchain-ts
A TypeScript tool for extracting Langchain prompts and generating corresponding TypeScript types.
Features
- Extracts prompts from Langchain Hub
- Generates TypeScript interfaces for prompt inputs and outputs
- Automatically handles JSON schema conversion
- Command-line interface for easy integration
- Optional filtering by prompt name and tag override
Installation
- Install the package
pnpm i @beparallel/langchain-ts- Set the environment variables in your
.envfile
LANGCHAIN_API_KEY=your_api_key
LANGCHAIN_TAG=your_tag- Set up the script in your
package.jsonfile
"scripts": {
...
"prompt:generate": "dotenv -f .env.* run -- npx langchain-types --file=X"
}Where:
Xis the path to the file where you want to save the types.- Optional:
--name=Yto filter prompts by name (partial match). - Optional:
--tag=Zto override theLANGCHAIN_TAGenvironment variable.
- Run the script
pnpm prompt:generateContributing
Installation
pnpm iUsage
- Add the environment variables in your
.envfile
LANGCHAIN_API_KEY=your_api_key
LANGCHAIN_TAG=your_tag- Export them
export LANGCHAIN_API_KEY=your_api_key
export LANGCHAIN_TAG=your_tag- Run the script
pnpm prompt:generateRelease
- Update the version in the
package.jsonfile. - Run the following command to update the types.
pnpm prepublish- Run npm publish command
npm publish --access public- Commit and push the changes.
- Create a new release on GitHub.
License
This project is licensed under the MIT License. See the LICENSE file for details.
