Skip to content

plosson/langchain-ai-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 

About

Langchain AI functions experiment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published