curl https://api.anthropic.com/v1/messages \ --header "x-api-key: $ANTHROPIC_API_KEY" \ --header "anthropic-version: 2023-06-01" \ --header "content-type: application/json" \ --data \ '{ "model": "claude-3-7-sonnet-latest", "max_tokens": 20000, "tools": [ { "name": "translated_html", "description": "Report the translated HTML", "input_schema": { "type": "object", "properties": { "translated_html": { "description": "The translated HTML", "type": "string", "format": "html" } } } } ], "tool_choice": { "name": "translated_html", "type": "tool" }, "messages": [ { "role": "user", "content": "I want you to translate the following HTML to Spanish but don´t change anything in the tag contents. And do not modify HTML.\n\n\n\n\n\t\n\t\t\n\t\t\n\t\t\n\t\tLuan Tutorial\n\t\n\t\n\t\t
\n\n

Luan Tutorial

\n\n\n

Create a file hello.luan containing:

\n\n\n%>\nHello World\n<%\n\n\n

To run this, type luan hello.luan on the command line. This should print Hello World.

\n\n

The syntax here is based on JSP. Let´s change it a little:

\n\n\nlocal name = \"Bob\"\n%>\nHello <%= name %>\n<%\n\n\n

This should print Hello Bob. Now let´s try a more conventional approach:

\n\n\nlocal Io = require \"luan:Io.luan\"\nlocal print = Io.print\n\nprint(\"Hello World\")\n\n\n

In Luan, a function call with one string argument doesn´t require parenthesis, so print(\"Hello World\") is the same as print \"Hello World\" and require \"luan:Io.luan\" is the same as require(\"luan:Io.luan\"). Both require and print are functions.

\n\n

The require function takes a URI as an argument. Examples of URIs are luan:Io.luan and file:hello.luan. require is used to import a module, which is returned from the require function call. In the case above, we assign the module to the local variable Io. The function print is a member of this module. We could have done Io.print(\"Hello World\") but instead we chose to assign print to a local variable and use that to call the function.

\n\n

Luan starts with only one defined function: require. You will use require to import whatever you need. This is a little more work, but makes it clear in each file where each function comes from.

\n\n

Let´s a make fancier version:

\n\n\nlocal Io = require \"luan:Io.luan\"\nlocal print = Io.print\n\nlocal function hello(name)\n\tprint(\"Hello \"..name)\nend\n\nhello(\"Bob\")\n\n\n

The .. operator does concatenation. This will print Hello Bob.

\n\n

Now let´s make a web page. First we need a directory for our website. So create a directory src. In this directory, create a file hi.html.luan containing:\n\n\nlocal Io = require \"luan:Io.luan\"\nlocal Http = require \"luan:http/Http.luan\"\n\nreturn function()\n\tIo.stdout = Http.response.text_writer()\n%>\n<!doctype html>\n<html>\n\t<body>\n\t\tHello Claude\n\t</body>\n</html>\n<%\nend\n\n\n\t\t

\n\t\n\n
\n" } ], "temperature": 0 }'