joke
object would be:
Joke
interface:
joke
object would now contain a topics
array:
Wait, what?!
You probably noticed by now that RΞASON is different from others frameworks because it actually utilizes your Typescript type information to change the actual output of your program. This is a key distinction: RΞASON uses Typescript (& JSDoc comments) not only at compile-time but also at runtime.How does it work under-the-hood?
How does it work under-the-hood?
When you run As you can see, the
npm run dev
what you are actually running is npx reason dev
, which runs the RΞASON transpiler.The RΞASON transpiler — as the name suggests — transpile your code to a different representation.For instance, the previous examples gets transpiled to:Joke
interface gets converted to an object that is passed as a parameter to reason()
.The inspiration came from React: they created a new syntax (JSX) for writing “HTML” in .js
files that gets transpiled to normal JavaScript. The same is true with RΞASON — except we didn’t create a new syntax, we changed how interfaces
are used.Ensuring the LLM conforms to the interface
RΞASON uses function calling to ensure a LLM returns an object that conforms to an interface.For OpenAI’s models that support JSON mode we use that instead of function calling.
A quick shoutout to Instructor, a Python library that is where we got the idea to use
interfaces
to get structured output from a LLM. Its an awesome library and if you are using Python, check them out.Design
RΞASON is a backend Typescript framework for building LLM apps. We also have frontend libraries to make it easy to make a great experience for the final user. We call RΞASON “minimalistic” because it is laser-focused on three areas only:- String parsing: RΞASON returns JSON objects so you never have to parse a raw completion again. RΞASON also has an incredible syntax for you to declare your own agents and never have to worry about calling your functions and passing parameters.
- Streaming: RΞASON handles both streaming-in and out of your app. Never worry about HTTP streams from OpenAI or to your frontend again.
- Observability: RΞASON is OpenTelemetry compatible — allowing you to use any observability tool you wish.
The philosophy behind RΞASON
We believe LLMs are a new primitive that programmers can use — not a new way to program; its still up to the programmer to do the right thing & create the right abstractions. At the core of RΞASON, we believe its the developers job to learn the new concepts that comes from this new primitive, such as prompting & retrieval. That’s why RΞASON does not interfere on those areas — we actively stay away from them. RΞASON is a functional transparent box that interops with normal TS code; not aconst agent = new ReasonChatAgent()
that is terrible to extend and customize.
To be clear, prompting & retrieval are key areas to the sucess of your LLM app, and, precisely because of that you should be the one in charge of it — not the framework. It is the job of the framework to focus on areas that do not differenciate your business, such as string parsing and handling HTTP streams.