GitHub - TypeAI-dev/typeai: ✨ An AI Engineering Framework for TypeScript

Hey all

I’ve published a project I’ve been hacking on:

https://github.com/TypeAI-dev/typeai

Just specify your types and function signatures as you naturally would, and TypeAI will generate the appropriate implementation respecting your type declarations. No loading separate schema files, no prompt engineering, and no manually writing JSON Schema representations of your functions.

TypeAI makes connecting your functions and types to AI APIs like OpenAI’s chat completion endpoints lightweight by using runtime type reflection on TypeScript code to generate the JSON schema required by OpenAI’s function calling feature, and by handling function dispatch and result delivery to the LLM.

TypeAI currently provides two main areas of functionality:

  • Generation of “magic” AI-backed functions
    • AI Models
    • AI Functions
    • AI Classifiers
  • Generation and handing of LLM tool function glue
    • AI “Tool Functions”

I’d be really happy to hear feedback and impressions here or on Twitter at @jefflaporte

1 Like

Can you name other specific examples for use cases, where this can be useful, besides turning unstructured data into structured data?

1 Like

Hey Jan, thanks for asking! :slight_smile:

The AI-backed model and function generation isn’t limited to string in, structured type out. It’s any type in, any type out, with the generated function behaviour defined by (1) the function signature, and (2) the JSDoc @description content describing your desired behaviour.

TypeAI currently provides two main areas of functionality:

  1. Generation of “magic” AI-backed functions
  • AI Models
  • AI Functions
  • AI Classifiers
  1. Generation and handing of LLM tool function glue
  • AI “Tool Functions”

The Tool Functions aspect makes it much easier to expose functions to GPT-n via function calling, by taking care of JSON Schema generation and function dispatch handling.

There is explanation of the AI Tool Functions aspect here: TypeAI: AI Tool Function Helpers.

To add it bit more context, my own reason for wanting this functionality is to move up a layer. Once generating models and functions becomes trivial, it becomes cheap (in an engineering sense) to define AI capabilities rapidly, and tie them together in larger patterns (beyond chaining…). Personally, my goal for the higher level capabilities is to enable what I’m calling MacroTasks, which I’m not ready to show at this point but the name itself should be somewhat evocative. I commented a bit more on project context in a thread here @jefflaporte on Twitter: Thread.

1 Like

Excellent work! I hope to give this a try. Thankyou for your efforts.

1 Like

Hey Jeff, thanks for clarifying! :slight_smile: Now I have a much clearer picture. Very interesting work, thanks for sharing!

1 Like

Hi Jeff. I echo others in saying this lib looks useful with the potential to be very useful. I came across it when looking for a way to generate typescript typings for my OpenAI API function calls. I’m finding it tedious (and error prone) to consume the invoked functions in my application.

In terms of feedback (which may or may not be relevant w.r.t your goals for the library), I felt that your library solved this issue but rather a lot more comes for the ride - some of which I’m hesitant about:

  1. A shame to need to enable decorators due the dependency you’re pulling in. I’m not going back to decorators post MobX days :slightly_smiling_face:
  2. I still want control over the prompts I send to the function (e.g. the various roles) and honestly don’t find it painful to use the OpenAI API straight.

So I much appreciate that you’ve abstracted the typings of function calling. If you ever pull that into it’s own lib, I’ll be the first to try it.

1 Like