Photos downloads from Apps instead of shipping in Breeze, practice and guide voice clips move to Ogg Opus, dependencies update (Ziran, Kryon, Apps, Arcade, practices), and the 2.1.63 version and store notes are prepared. The Practice tab note is translated in every locale.
83 lines
3.5 KiB
Ziran
83 lines
3.5 KiB
Ziran
#import, file "../src/apps/lumi_response.zi";
|
|
#import "vec"
|
|
#import "text"
|
|
#import "json_scan"
|
|
|
|
#scope_export
|
|
Answer :: () -> s32 {
|
|
response := "{\"message\":{\"role\":\"assistant\",\"content\":\"Hello\"}}"
|
|
if LumiResponseMessageAt(response) < 0 ||
|
|
LumiResponseMessageAt("{\"message\":{\"role\":\"assistant\",\"content\":\"Hello\"}}\n") < 0 ||
|
|
LumiResponseMessageAt("{\"message\":{\"role\":\"assistant\",\"content\":\"Hello\"}} \r\n\t") < 0 {
|
|
return 1
|
|
}
|
|
if LumiResponseMessageAt("{\"message\":{\"role\":\"assistant\",\"content\":\"Hello\"}}garbage") >= 0 ||
|
|
LumiResponseMessageAt("{\"message\":") >= 0 ||
|
|
LumiResponseMessageAt("{}\n") >= 0 {
|
|
return 2
|
|
}
|
|
id := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
|
receipt := "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\""
|
|
if !LumiFeedbackReceiptMatches(receipt, id) ||
|
|
!LumiFeedbackReceiptMatches(" \n\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" \r\n\t", id) {
|
|
return 3
|
|
}
|
|
invalid: [8]string = .["true", "{}", "\"short\"", "null", "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"garbage",
|
|
"\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"", "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", ""]
|
|
for value: invalid {
|
|
if LumiFeedbackReceiptMatches(value, id) {
|
|
return 4
|
|
}
|
|
}
|
|
if LumiFeedbackReceiptMatches(receipt, "short") {
|
|
return 5
|
|
}
|
|
out: Vec(u8)
|
|
BuilderPrint(*out, "[")
|
|
for index: cast(s32)0..21 {
|
|
BuilderPrint(*out, "%{\"role\":\"%\",\"content\":\"message %\"}",
|
|
ifx index == 0 then "" else ",", ifx index == 3 then "user" else "assistant", index)
|
|
}
|
|
BuilderPrint(*out, "]")
|
|
history := BuilderFinish(out)
|
|
first := LumiRequestHistoryStart(history)
|
|
if first != ElementAt(history, 0, 2) {
|
|
return 6
|
|
}
|
|
// An over-budget exchange starting at the current user cannot be
|
|
// repaired by discarding a tool call or its result.
|
|
too_long: Vec(u8)
|
|
BuilderPrint(*too_long, "[{\"role\":\"user\",\"content\":\"current\"}")
|
|
for index: cast(s32)0..19 {
|
|
BuilderPrint(*too_long, ",{\"role\":\"tool\",\"tool_call_id\":\"id\",\"content\":\"result\"}")
|
|
}
|
|
BuilderPrint(*too_long, "]")
|
|
exchange := BuilderFinish(too_long)
|
|
if LumiRequestHistoryStart(exchange) >= 0 ||
|
|
LumiRequestHistoryStart("[]") >= 0 ||
|
|
LumiRequestHistoryStart("[{\"role\":\"user\"}]junk") >= 0 ||
|
|
LumiRequestHistoryStart("[{\"role\":\"assistant\"}]") >= 0 ||
|
|
LumiRequestHistoryStart("[{\"role\":\"user\",\"content\":\"hello\"}]") != 1 {
|
|
return 7
|
|
}
|
|
completed: Vec(u8)
|
|
BuilderPrint(*completed, "[")
|
|
for index: cast(s32)0..21 {
|
|
if index == 1 {
|
|
BuilderPrint(*completed, ",{\"role\":\"assistant\",\"tool_calls\":[{\"id\":\"a\"},{\"id\":\"b\"}]}")
|
|
} else if index == 2 || index == 3 {
|
|
BuilderPrint(*completed, ",{\"role\":\"tool\",\"tool_call_id\":\"%\",\"content\":\"result\"}",
|
|
ifx index == 2 then "a" else "b")
|
|
} else {
|
|
BuilderPrint(*completed, "%{\"role\":\"%\",\"content\":\"message %\"}",
|
|
ifx index == 0 then "" else ",", ifx index == 0 || index == 21 then "user" else "assistant", index)
|
|
}
|
|
}
|
|
BuilderPrint(*completed, "]")
|
|
queued := BuilderFinish(completed)
|
|
if LumiRequestHistoryStart(queued) != ElementAt(queued, 0, 4) {
|
|
return 8
|
|
}
|
|
return 42
|
|
}
|