1.0.8 • Published 1 year ago

@plosson/langchain-ai-functions v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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 
1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago