@plosson/langchain-ai-functions
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

Langchain Typescript AI decorators

This is a quick experiment to write AI functions using decorators in Typescript.

The main idea is to be able write this directly in your code base

    @AiFn({
    template: 'I really want to travel to {city} in {country}. What should I do there? Respond in one short sentence',
    inputVariables: ['city', 'country']
})
async
whatToVisit(city
:
string, country
:
string
):
AiFnOutput < string > {}

The implementation will be included through Typescript's decorator feature.

You can then call the code simply doing :

const result = await t.whatToVisit('Rome', 'Italy')
console.log(result);

It should output

Visit the Colosseum, Vatican City, and eat authentic Italian cuisine.

Project Setup

npm install

Copy .env.example to .env and add your OPENAI_API_KEY

Using the decorators in your project

npm install "@plosson/langchain-ai-functions"
import {AiFn, AiFnOutput} from "@plosson/langchain-ai-functions";

Examples

There is an example in the tests folder that can be executed using

npm run example 

Readme

Keywords

none

Package Sidebar

Install

npm i @plosson/langchain-ai-functions

Weekly Downloads

3

Version

1.0.8

License

ISC

Unpacked Size

11.1 kB

Total Files

8

Last publish

Collaborators

  • plosson