from niadra.replay import Replayer
# Runs each turn of the scenario 5 times inside your CI; tools answer from the record
run = Replayer(niadra, build_agent, build=BUILD).run(["sc_01J9..."], runs=5)
if run.regressed:
raise SystemExit(1)import { Replayer } from "@niadra/sdk";
// Runs each turn of the scenario 5 times inside your CI; tools answer from the record
const run = await new Replayer(niadra, buildAgent, { build: BUILD }).run(["sc_01J9..."], { runs: 5 });
if (run.verdict === "regression") process.exit(1);curl --request POST \
--url https://{space}.{region}.api.niadra.com/v1/replay/cases \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"build": {
"adapter": "<string>",
"pins": {
"assembler": "<string>",
"corpus_digest": "<string>",
"model": "<string>",
"niadra": {
"compiler": "<string>",
"pack_hash": "<string>"
},
"prompts": {},
"tool_schemas": {}
},
"sdk": "<string>"
},
"turn_id": "<string>",
"mode": "hermetic_turn",
"scenario_id": "<string>",
"vary": []
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
build: {
adapter: '<string>',
pins: {
assembler: '<string>',
corpus_digest: '<string>',
model: '<string>',
niadra: {compiler: '<string>', pack_hash: '<string>'},
prompts: {},
tool_schemas: {}
},
sdk: '<string>'
},
turn_id: '<string>',
mode: 'hermetic_turn',
scenario_id: '<string>',
vary: []
})
};
fetch('https://{space}.{region}.api.niadra.com/v1/replay/cases', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{space}.{region}.api.niadra.com/v1/replay/cases",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'build' => [
'adapter' => '<string>',
'pins' => [
'assembler' => '<string>',
'corpus_digest' => '<string>',
'model' => '<string>',
'niadra' => [
'compiler' => '<string>',
'pack_hash' => '<string>'
],
'prompts' => [
],
'tool_schemas' => [
]
],
'sdk' => '<string>'
],
'turn_id' => '<string>',
'mode' => 'hermetic_turn',
'scenario_id' => '<string>',
'vary' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{space}.{region}.api.niadra.com/v1/replay/cases"
payload := strings.NewReader("{\n \"build\": {\n \"adapter\": \"<string>\",\n \"pins\": {\n \"assembler\": \"<string>\",\n \"corpus_digest\": \"<string>\",\n \"model\": \"<string>\",\n \"niadra\": {\n \"compiler\": \"<string>\",\n \"pack_hash\": \"<string>\"\n },\n \"prompts\": {},\n \"tool_schemas\": {}\n },\n \"sdk\": \"<string>\"\n },\n \"turn_id\": \"<string>\",\n \"mode\": \"hermetic_turn\",\n \"scenario_id\": \"<string>\",\n \"vary\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{space}.{region}.api.niadra.com/v1/replay/cases")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"build\": {\n \"adapter\": \"<string>\",\n \"pins\": {\n \"assembler\": \"<string>\",\n \"corpus_digest\": \"<string>\",\n \"model\": \"<string>\",\n \"niadra\": {\n \"compiler\": \"<string>\",\n \"pack_hash\": \"<string>\"\n },\n \"prompts\": {},\n \"tool_schemas\": {}\n },\n \"sdk\": \"<string>\"\n },\n \"turn_id\": \"<string>\",\n \"mode\": \"hermetic_turn\",\n \"scenario_id\": \"<string>\",\n \"vary\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/replay/cases")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"build\": {\n \"adapter\": \"<string>\",\n \"pins\": {\n \"assembler\": \"<string>\",\n \"corpus_digest\": \"<string>\",\n \"model\": \"<string>\",\n \"niadra\": {\n \"compiler\": \"<string>\",\n \"pack_hash\": \"<string>\"\n },\n \"prompts\": {},\n \"tool_schemas\": {}\n },\n \"sdk\": \"<string>\"\n },\n \"turn_id\": \"<string>\",\n \"mode\": \"hermetic_turn\",\n \"scenario_id\": \"<string>\",\n \"vary\": []\n}"
response = http.request(request)
puts response.read_body{
"case_id": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"input": {
"kind": "message",
"text": "<string>"
},
"mode": "hermetic_turn",
"record": {
"agent": {
"name": "<string>",
"parent_turn_id": "<string>",
"role": "<string>"
},
"content_mode": "stored",
"started_at": "2023-11-07T05:31:56Z",
"turn_id": "<string>",
"blobs": {},
"build": {
"adapter": "<string>",
"pins": {
"assembler": "<string>",
"corpus_digest": "<string>",
"model": "<string>",
"niadra": {
"compiler": "<string>",
"pack_hash": "<string>"
},
"prompts": {},
"tool_schemas": {}
},
"sdk": "<string>"
},
"calls": [
{
"call_id": "<string>",
"kind": "tool",
"applied": {
"constraints": "<string>",
"results_checked": 1,
"unverifiable": 1,
"violations": 1,
"hard_sent": [
"<string>"
],
"relaxed": "declared"
},
"args": "<string>",
"args_hash": "<string>",
"attempt": 1,
"cache_hit": false,
"cost_units": {},
"effect_key": "<string>",
"latency_ms": 1,
"name": "<string>",
"observations": [
{
"fields": {},
"ref": "<string>",
"provenance": {
"source": "live",
"source_observed_at": "2023-11-07T05:31:56Z",
"scope": "global"
}
}
],
"parent_call_id": "<string>",
"result_model": "<string>",
"result_ui": "<string>",
"status": "ok",
"synthetic": false,
"tokens": {
"in": 1,
"out": 1,
"cached": 0
},
"truncated": false
}
],
"claims": [
{
"action": "none",
"category": "<string>",
"span": [
123,
123
],
"verdict": "matched",
"class": "money",
"evidence": {
"anchor": "<string>",
"call_id": "<string>",
"document": "<string>",
"field": "<string>",
"ref": "<string>",
"score": 0.5
},
"nature": "computed",
"role": "<string>",
"value": {
"amount": "<string>",
"date": "<string>",
"date_from": "<string>",
"date_to": "<string>",
"max": "<string>",
"min": "<string>",
"unit": "<string>"
}
}
],
"completeness": "complete",
"conversation_id": "<string>",
"coordination": [
{
"decision": "allow",
"decision_id": "<string>"
}
],
"cost": {
"usd": 1
},
"effects": [
{
"key": "<string>",
"state": "reserved"
}
],
"ended_at": "2023-11-07T05:31:56Z",
"fidelity": "gold",
"flags": [
"error"
],
"interactions": [
{
"delivered_at": "2023-11-07T05:31:56Z",
"exposure_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"items": [
{
"pos": 5000,
"ref": "<string>",
"shown": {},
"team": "a"
}
],
"kind": "presented",
"list_id": "<string>",
"for": "self",
"list_kind": "results",
"method": "bridge",
"offset": 0,
"page": 1,
"parent_list_id": "<string>",
"visible_k": 50
}
],
"kind": "message",
"latency_ms": 1,
"output": {
"document": "<string>",
"event_keys": [
"<string>"
],
"handoff_id": "<string>",
"ui": "<string>"
},
"reads": [
{
"surface": "pack",
"blob": "<string>",
"etag": "<string>",
"receipt_id": "<string>",
"version": "<string>"
}
],
"spec": "turn-record.v0",
"task_id": "<string>"
},
"required_pins": [
"prompts"
],
"turn_id": "<string>",
"assertions": [
{
"id": "<string>",
"kind": "tool_called",
"args": {},
"suggested": false,
"turn_id": "<string>"
}
],
"history": [
{
"at": "2023-11-07T05:31:56Z",
"role": "customer",
"text": "<string>"
}
],
"scenario_id": "<string>",
"vary": [
"prompts"
]
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Pedir um caso de replay
Um turno com o que o executor precisa para rodá-lo de novo dentro da sua empresa, depois que a build em execução confere os pinos.
from niadra.replay import Replayer
# Runs each turn of the scenario 5 times inside your CI; tools answer from the record
run = Replayer(niadra, build_agent, build=BUILD).run(["sc_01J9..."], runs=5)
if run.regressed:
raise SystemExit(1)import { Replayer } from "@niadra/sdk";
// Runs each turn of the scenario 5 times inside your CI; tools answer from the record
const run = await new Replayer(niadra, buildAgent, { build: BUILD }).run(["sc_01J9..."], { runs: 5 });
if (run.verdict === "regression") process.exit(1);curl --request POST \
--url https://{space}.{region}.api.niadra.com/v1/replay/cases \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"build": {
"adapter": "<string>",
"pins": {
"assembler": "<string>",
"corpus_digest": "<string>",
"model": "<string>",
"niadra": {
"compiler": "<string>",
"pack_hash": "<string>"
},
"prompts": {},
"tool_schemas": {}
},
"sdk": "<string>"
},
"turn_id": "<string>",
"mode": "hermetic_turn",
"scenario_id": "<string>",
"vary": []
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
build: {
adapter: '<string>',
pins: {
assembler: '<string>',
corpus_digest: '<string>',
model: '<string>',
niadra: {compiler: '<string>', pack_hash: '<string>'},
prompts: {},
tool_schemas: {}
},
sdk: '<string>'
},
turn_id: '<string>',
mode: 'hermetic_turn',
scenario_id: '<string>',
vary: []
})
};
fetch('https://{space}.{region}.api.niadra.com/v1/replay/cases', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{space}.{region}.api.niadra.com/v1/replay/cases",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'build' => [
'adapter' => '<string>',
'pins' => [
'assembler' => '<string>',
'corpus_digest' => '<string>',
'model' => '<string>',
'niadra' => [
'compiler' => '<string>',
'pack_hash' => '<string>'
],
'prompts' => [
],
'tool_schemas' => [
]
],
'sdk' => '<string>'
],
'turn_id' => '<string>',
'mode' => 'hermetic_turn',
'scenario_id' => '<string>',
'vary' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{space}.{region}.api.niadra.com/v1/replay/cases"
payload := strings.NewReader("{\n \"build\": {\n \"adapter\": \"<string>\",\n \"pins\": {\n \"assembler\": \"<string>\",\n \"corpus_digest\": \"<string>\",\n \"model\": \"<string>\",\n \"niadra\": {\n \"compiler\": \"<string>\",\n \"pack_hash\": \"<string>\"\n },\n \"prompts\": {},\n \"tool_schemas\": {}\n },\n \"sdk\": \"<string>\"\n },\n \"turn_id\": \"<string>\",\n \"mode\": \"hermetic_turn\",\n \"scenario_id\": \"<string>\",\n \"vary\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{space}.{region}.api.niadra.com/v1/replay/cases")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"build\": {\n \"adapter\": \"<string>\",\n \"pins\": {\n \"assembler\": \"<string>\",\n \"corpus_digest\": \"<string>\",\n \"model\": \"<string>\",\n \"niadra\": {\n \"compiler\": \"<string>\",\n \"pack_hash\": \"<string>\"\n },\n \"prompts\": {},\n \"tool_schemas\": {}\n },\n \"sdk\": \"<string>\"\n },\n \"turn_id\": \"<string>\",\n \"mode\": \"hermetic_turn\",\n \"scenario_id\": \"<string>\",\n \"vary\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/replay/cases")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"build\": {\n \"adapter\": \"<string>\",\n \"pins\": {\n \"assembler\": \"<string>\",\n \"corpus_digest\": \"<string>\",\n \"model\": \"<string>\",\n \"niadra\": {\n \"compiler\": \"<string>\",\n \"pack_hash\": \"<string>\"\n },\n \"prompts\": {},\n \"tool_schemas\": {}\n },\n \"sdk\": \"<string>\"\n },\n \"turn_id\": \"<string>\",\n \"mode\": \"hermetic_turn\",\n \"scenario_id\": \"<string>\",\n \"vary\": []\n}"
response = http.request(request)
puts response.read_body{
"case_id": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"input": {
"kind": "message",
"text": "<string>"
},
"mode": "hermetic_turn",
"record": {
"agent": {
"name": "<string>",
"parent_turn_id": "<string>",
"role": "<string>"
},
"content_mode": "stored",
"started_at": "2023-11-07T05:31:56Z",
"turn_id": "<string>",
"blobs": {},
"build": {
"adapter": "<string>",
"pins": {
"assembler": "<string>",
"corpus_digest": "<string>",
"model": "<string>",
"niadra": {
"compiler": "<string>",
"pack_hash": "<string>"
},
"prompts": {},
"tool_schemas": {}
},
"sdk": "<string>"
},
"calls": [
{
"call_id": "<string>",
"kind": "tool",
"applied": {
"constraints": "<string>",
"results_checked": 1,
"unverifiable": 1,
"violations": 1,
"hard_sent": [
"<string>"
],
"relaxed": "declared"
},
"args": "<string>",
"args_hash": "<string>",
"attempt": 1,
"cache_hit": false,
"cost_units": {},
"effect_key": "<string>",
"latency_ms": 1,
"name": "<string>",
"observations": [
{
"fields": {},
"ref": "<string>",
"provenance": {
"source": "live",
"source_observed_at": "2023-11-07T05:31:56Z",
"scope": "global"
}
}
],
"parent_call_id": "<string>",
"result_model": "<string>",
"result_ui": "<string>",
"status": "ok",
"synthetic": false,
"tokens": {
"in": 1,
"out": 1,
"cached": 0
},
"truncated": false
}
],
"claims": [
{
"action": "none",
"category": "<string>",
"span": [
123,
123
],
"verdict": "matched",
"class": "money",
"evidence": {
"anchor": "<string>",
"call_id": "<string>",
"document": "<string>",
"field": "<string>",
"ref": "<string>",
"score": 0.5
},
"nature": "computed",
"role": "<string>",
"value": {
"amount": "<string>",
"date": "<string>",
"date_from": "<string>",
"date_to": "<string>",
"max": "<string>",
"min": "<string>",
"unit": "<string>"
}
}
],
"completeness": "complete",
"conversation_id": "<string>",
"coordination": [
{
"decision": "allow",
"decision_id": "<string>"
}
],
"cost": {
"usd": 1
},
"effects": [
{
"key": "<string>",
"state": "reserved"
}
],
"ended_at": "2023-11-07T05:31:56Z",
"fidelity": "gold",
"flags": [
"error"
],
"interactions": [
{
"delivered_at": "2023-11-07T05:31:56Z",
"exposure_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"items": [
{
"pos": 5000,
"ref": "<string>",
"shown": {},
"team": "a"
}
],
"kind": "presented",
"list_id": "<string>",
"for": "self",
"list_kind": "results",
"method": "bridge",
"offset": 0,
"page": 1,
"parent_list_id": "<string>",
"visible_k": 50
}
],
"kind": "message",
"latency_ms": 1,
"output": {
"document": "<string>",
"event_keys": [
"<string>"
],
"handoff_id": "<string>",
"ui": "<string>"
},
"reads": [
{
"surface": "pack",
"blob": "<string>",
"etag": "<string>",
"receipt_id": "<string>",
"version": "<string>"
}
],
"spec": "turn-record.v0",
"task_id": "<string>"
},
"required_pins": [
"prompts"
],
"turn_id": "<string>",
"assertions": [
{
"id": "<string>",
"kind": "tool_called",
"args": {},
"suggested": false,
"turn_id": "<string>"
}
],
"history": [
{
"at": "2023-11-07T05:31:56Z",
"role": "customer",
"text": "<string>"
}
],
"scenario_id": "<string>",
"vary": [
"prompts"
]
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Autorizações
nia_sk_...
Corpo
Um caso para um turno, sozinho ou como parte de um cenário. build é a build que o executor vai rodar; todo pino que a gravação exige precisa bater com o gravado, menos os pinos em vary, que a execução muda de propósito.
Show child attributes
Show child attributes
^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$hermetic_turn, hermetic_conversation, era_memory 1 - 5125prompts, corpus_digest, model, assembler, tool_schemas Resposta
Resposta de sucesso.
O que o executor de replay precisa para rodar um turno de novo dentro da empresa: o registro, com os valores guardados no modo stored e os ponteiros e digests nos demais; os pinos; o histórico mascarado da conversa até o turno, terminando na própria entrada dele; e as asserções. O contexto da época é o blob da leitura pack do registro.
1 - 512Quando o turno sai do armazenamento; depois disso, replay_expired.
Show child attributes
Show child attributes
hermetic_turn, hermetic_conversation, era_memory Um turno, da entrada dele (uma mensagem, uma ação de interface, um evento, um temporizador disparado) até a última coisa que emitiu ao cliente ou a um documento.
Show child attributes
Show child attributes
prompts, corpus_digest, model, assembler, tool_schemas ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$Show child attributes
Show child attributes
Show child attributes
Show child attributes
1 - 512prompts, corpus_digest, model, assembler, tool_schemas 
