Hyperlambda Generator
Magic contains its own Hyperlambda Generator. This isn’t a single component, but goes through most parts of the platform that somehow allows you to create Hyperlambda code. It’s built as a custom LLM we have fine tuned on top of OpenAI’s GPT-4.1 model, with more than 20,000 training examples, so it’s actually very strong on creating backend code, even though it’s using a “small base model”.
You have to write “formal specifications using technical language”, in order for it to understand what to do. But if you’ve got some basic knowledge about software development, you should be able to rapidly understand how to use it. Below are some examples of prompts to give you an ide.
- “HTTP endpoint that selects rows from Artist table in chinook database, including Album rows for each individual artist. Use ArtistId as foreign key”
- “Executable Hyperlambda file that send an email using [name], [email], [subject], and [body] arguments. Endpoint can only be executed by root and admin accounts”
How to use it
If you go to Hyper IDE for example, and you create a new Hyperlambda file (extension “.hl”), then a popup dialog will ask you to provide a description and arguments. If you write what you want the code to do for you, and you click “Save & Generate”, the description will be sent through our LLM, transforming your English to working Hyperlambda.
DISCLAIMER - Magic and Hyperlambda isn’t really an “all purpose language”, it’s an orchestration language. If you’re using it for complex algorithms, you’re doing something wrong. So whatever description you supply, must be comething that is a good fit for Hyperlambda. Below is the result for the above prompt from the screenshot.
/*
* Endpoint: chinook.artist.read
* Purpose: Reads artists from chinook database, including albums for each artist.
* Access: Root users only.
*/
.arguments
auth.ticket.verify:root
data.connect:chinook
data.read
table:Artist
include:x:@data.read/*
data.read
table:Album
where
and
ArtistId.eq:x:@.dp/#/*/ArtistId
yield
albums:x:@data.read/*
yield
artists:x:@data.read/*
Notice, if the AI creates wrong code, you can click CTRL+Z
or OPTION+Z
on a Mac to undo the generator’s changes, at which point you can start over again by clicking OPTION+Q
or ALT+Q
, allowing you to edit the text to be more specific.
Modifying your code with AI
Below your main code view in Hyper IDE and the Hyperlambda Playground, you can see an input textbox that says “Where the Machine Creates the Code”. This bar allows you to provide change instructions to the LLM. Examples of prompts you might want to test can be found below.
- Add a name argument and use this when sending the email
- Make the title argument mandatory
- Log all incoming arguments
- Etc …