Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ Under `azion dev`, `env` is the `process.env` of your machine: the whole shell e
The fetch handler is the `fetch` method of the default export. Azion Runtime calls it with three arguments each time the function runs:

```javascript
async fetch(request, env, ctx)
export default {
async fetch(request, env, ctx) {
return new Response('Hello World!');
},
};
```

### Parameters
Expand All @@ -47,7 +51,11 @@ The `env` parameter holds no variables in a deployed function. To read a variabl
The firewall handler is the `firewall` method of the default export. A function instance on a firewall calls it in place of `fetch`:

```javascript
async firewall(request, env, ctx)
export default {
async firewall(request, env, ctx) {
ctx.continue();
},
};
```

Azion CLI 4.24.0 runs Azion Bundler 1.2.0, which wraps the ES Modules `firewall` handler in `addEventListener('firewall', …)`. In a function built by Azion CLI 4.24.0 or later, `ctx` carries these methods, each bound to the firewall event:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ The response is similar to this one:
"results": [
{
"id": 1,
...
"lockout": {
"locked_at": "20240101T10:20:01",
"unlock_at": "20240102T10:20:01",
"unlock_at": "20240102T10:20:01"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ The response is similar to this one:
"max_idle_time": 1,
"max_session_time": 5
}
}
```

`max_idle_time` sets how long an idle session lasts, and `max_session_time` how long any session lasts, both in *minutes*.
Expand Down Expand Up @@ -85,6 +86,7 @@ The response is similar to this one:
"max_idle_time": 1,
"max_session_time": 5
}
}
```

The policy uses the new values for the sessions on the account.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ When the argument file has no `http_connection_args` and no `s3_connection_args`

When the function cannot connect to the HTTP endpoint or to the S3 provider, it ignores the user request. The function still creates an error log, which you can access through [Data Stream](/en/documentation/platform/data-stream/). For example, an invalid access key shows this message:

```json
```text
[Send event to endpoint] S3 connection error;
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,20 @@ The endpoint then returns the model response.

## The endpoint answers Missing model field or Invalid JSON

The endpoint of the AI Inference Starter Kit answers `400` with one of these bodies:
The endpoint of the AI Inference Starter Kit answers `400` with one of two bodies. For a body without the `model` field:

```json
{"error":"Missing 'model' field in request body"}
{"error":"Invalid JSON in request body"}
{
"error": "Missing 'model' field in request body"
}
```

For a body that does not parse as JSON:

```json
{
"error": "Invalid JSON in request body"
}
```

The Function the template installs reads the model id from the `model` field of the body. A body without `model`, or a body that does not parse as JSON, stops before the model call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ With the defaults, the endpoint receives NDJSON: one log line per line, with no

With **Payload Log Line Separator** `\n` and **Payload Format** `$dataset`, the request body is NDJSON:

```json
```jsonl
{"request_method": "GET", "host": "www.onedomain.com", "status": "200"}
{"request_method": "POST", "host": "www.anotherdomain.net", "status": "200"}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ Com `azion dev`, `env` é o `process.env` da sua máquina: todo o ambiente do sh
O handler fetch é o método `fetch` do export default. O Azion Runtime o chama com três argumentos a cada execução da function:

```javascript
async fetch(request, env, ctx)
export default {
async fetch(request, env, ctx) {
return new Response('Hello World!');
},
};
```

### Parâmetros
Expand All @@ -47,7 +51,11 @@ O parâmetro `env` não contém variáveis em uma function com deploy feito. Par
O handler firewall é o método `firewall` do export default. Uma instância de function em um firewall o chama no lugar de `fetch`:

```javascript
async firewall(request, env, ctx)
export default {
async firewall(request, env, ctx) {
ctx.continue();
},
};
```

Azion CLI 4.24.0 executa Azion Bundler 1.2.0, que envolve o handler `firewall` ES Modules em `addEventListener('firewall', …)`. Em uma function com build feito pela Azion CLI 4.24.0 ou posterior, `ctx` carrega estes métodos, cada um vinculado ao evento de firewall:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ A resposta é semelhante a esta:
"results": [
{
"id": 1,
...
"lockout": {
"locked_at": "20240101T10:20:01",
"unlock_at": "20240102T10:20:01",
"unlock_at": "20240102T10:20:01"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ A resposta é semelhante a esta:
"max_idle_time": 1,
"max_session_time": 5
}
}
```

`max_idle_time` define quanto tempo uma sessão ociosa dura, e `max_session_time`, quanto tempo qualquer sessão dura, ambos em *minutos*.
Expand Down Expand Up @@ -85,6 +86,7 @@ A resposta é semelhante a esta:
"max_idle_time": 1,
"max_session_time": 5
}
}
```

A política passa a usar os novos valores para as sessões da conta.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ Quando o arquivo de argumentos não tem `http_connection_args` nem `s3_connectio

Quando a function não consegue se conectar ao endpoint HTTP ou ao provedor S3, ela ignora a requisição do usuário. A function ainda cria um log de erro, que você acessa pelo [Data Stream](/pt-br/documentacao/plataforma/data-stream/). Por exemplo, uma access key inválida mostra esta mensagem:

```json
```text
[Send event to endpoint] S3 connection error;
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,20 @@ O endpoint então retorna a resposta do modelo.

## O endpoint responde Missing model field ou Invalid JSON

O endpoint do AI Inference Starter Kit responde `400` com um destes corpos:
O endpoint do AI Inference Starter Kit responde `400` com um de dois corpos. Para um corpo sem o campo `model`:

```json
{"error":"Missing 'model' field in request body"}
{"error":"Invalid JSON in request body"}
{
"error": "Missing 'model' field in request body"
}
```

Para um corpo que não é um JSON válido:

```json
{
"error": "Invalid JSON in request body"
}
```

A Function que o template instala lê o id do modelo do campo `model` do corpo. Um corpo sem `model`, ou um corpo que não é um JSON válido, para antes da chamada de modelo.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Com os valores padrão, o endpoint recebe NDJSON: uma linha de log por linha, se

Com **Payload Log Line Separator** `\n` e **Payload Format** `$dataset`, o corpo da requisição é NDJSON:

```json
```jsonl
{"request_method": "GET", "host": "www.onedomain.com", "status": "200"}
{"request_method": "POST", "host": "www.anotherdomain.net", "status": "200"}
```
Expand Down
Loading