@botpress/zai 2.0.13 → 2.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/operations/extract.js +5 -9
- package/e2e/data/cache.jsonl +17 -0
- package/e2e/utils.ts +3 -2
- package/package.json +2 -2
- package/src/operations/extract.ts +6 -11
|
@@ -46,16 +46,12 @@ Zai.prototype.extract = async function(input, _schema, _options) {
|
|
|
46
46
|
this.ModelDetails.input.maxTokens - PROMPT_INPUT_BUFFER - schemaLength
|
|
47
47
|
);
|
|
48
48
|
const keys = Object.keys(schema.shape);
|
|
49
|
-
|
|
49
|
+
const inputAsString = stringify(input);
|
|
50
50
|
if (tokenizer.count(inputAsString) > options.chunkLength) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return all.flat();
|
|
56
|
-
} else {
|
|
57
|
-
inputAsString = tokenizer.truncate(stringify(input), options.chunkLength);
|
|
58
|
-
}
|
|
51
|
+
const tokens = tokenizer.split(inputAsString);
|
|
52
|
+
const chunks = chunk(tokens, options.chunkLength).map((x) => x.join(""));
|
|
53
|
+
const all = await Promise.all(chunks.map((chunk2) => this.extract(chunk2, originalSchema)));
|
|
54
|
+
return this.extract(all, originalSchema, options);
|
|
59
55
|
}
|
|
60
56
|
const instructions = [];
|
|
61
57
|
if (options.instructions) {
|
package/e2e/data/cache.jsonl
CHANGED
|
@@ -111,3 +111,20 @@
|
|
|
111
111
|
{"test":"zai.learn.check > learns a contradiction from examples-2","key":"fb829dbe","input":"[{\"input\":{\"messages\":[{\"content\":\"Expert Example #1\\n<|start_input|>\\nhello! how are you?\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"Analysis: \\\"hello!\\\" is a common greeting in English.\\nFinal Answer: ■TRUE■\\n■END■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Considering the below input and above examples, is the following condition true or false?\\nExpert Example #2\\n<|start_input|>\\nWhat's up\\n<|end_input|>\\nIn your \\\"Analysis\\\", please refer to the Expert Examples # to justify your decision.\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■END■\"],\"systemPrompt\":\"Check if the following condition is true or false for the given input. Before answering, make sure to read the input and the condition carefully.\\nJustify your answer, then answer with either ■TRUE■ or ■FALSE■ at the very end, then add ■END■ to finish the response.\\nIMPORTANT: Make sure to answer with either ■TRUE■ or ■FALSE■ at the end of your response, but NOT both.\\n---\\nExpert Examples (#1 to #1):\\n- You have been provided with examples from previous experts. Make sure to read them carefully before making your decision.\\n- Make sure to refer to the examples provided by the experts to justify your decision (when applicable).\\n- When in doubt, ground your decision on the examples provided by the experts instead of your own intuition.\\n- When no example is similar to the input, make sure to provide a clear justification for your decision while inferring the decision-making process from the examples provided by the experts.\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-BfueyMm1AB33ju6mdrjiI7J97NJW7","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"Analysis: In the given input, \"What's up\" is a common informal greeting in English, similar in purpose to \"hello!\" from Expert Example #1. Both are used as greetings or as a way of initiating conversation. Based on the reasoning from Expert Example #1, this input also aligns with the category of common conversational language.\n\nFinal Answer: ■TRUE■ \n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":309,"inputCost":0.0007725000000000001,"outputTokens":77,"outputCost":0.0007700000000000001},"botpress":{"cost":0.0015425}},"meta":{"cached":false}}}
|
|
112
112
|
{"test":"zai.learn.extract > learns a extraction format from examples-1","key":"76172648","input":"[{\"input\":{\"messages\":[{\"content\":\"Expert Example #1\\n\\n<|start_schema|>\\n{ name: string; movie: string }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nextract the name of the movie and name of the main character\\n<|end_instructions|>\\n\\n<|start_input|>\\nDid you know that the gladiator movie has a lot of fighting scenes?\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"■json_start■\\n{\\n \\\"name\\\": \\\"MAXIMUS DECIMUS MERIDIUS\\\",\\n \\\"movie\\\": \\\"GLADIATOR\\\"\\n}\\n■json_end■■NO_MORE_ELEMENT■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Expert Example #2\\n\\n<|start_schema|>\\n{ name: string; movie: string }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nextract the name of the movie and name of the main character\\n<|end_instructions|>\\n\\n<|start_input|>\\nI really liked Casino Royale\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■json_end■\"],\"systemPrompt\":\"Extract the following information from the input:\\n{ name: string; movie: string }\\n====\\n\\n• extract the name of the movie and name of the main character\\n• You may have exactly one element in the input.\\n• The element must be a JSON object with exactly the format: ■json_start■{ \\\"name\\\": ..., \\\"movie\\\": ... }■json_end■\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-Bfuez8mOBr1KkP8oC58cbgbYlHE6M","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"■json_start■\n{\n \"name\": \"JAMES BOND\",\n \"movie\": \"CASINO ROYALE\"\n}\n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":284,"inputCost":0.00071,"outputTokens":32,"outputCost":0.00032},"botpress":{"cost":0.00103}},"meta":{"cached":false}}}
|
|
113
113
|
{"test":"zai.learn.label > learns a labelling rule from examples-1","key":"125badfe","input":"[{\"input\":{\"messages\":[{\"content\":\"Expert Example #1\\n\\n<|start_input|>\\nSylvain Pellerin has no criminal record.\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"Expert Example #1\\n============\\n■canadian:【Since we are doing business only in Canada, we assume all users are Canadians.】:ABSOLUTELY_YES■\\n■is_french:【Important: Sylvain is a common French name.】:ABSOLUTELY_YES■\\n■END■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Input to tag:\\n<|start_input|>\\nSylvain Perron has no criminal record.\\n<|end_input|>\\n\\nAnswer with this following format:\\n```\\n■is_human:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person a human?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■good_person:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person a good person?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■bad_person:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person a bad person?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■canadian:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person canadian?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■is_french:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person french?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n■END■\\n```\\n\\nFormat cheatsheet:\\n```\\n■label:【explanation】:x■\\n```\\n\\nWhere `x` is one of the following: ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES\\n\\nRemember: In your `explanation`, please refer to the Expert Examples # (and quote them) that are relevant to ground your decision-making process.\\nThe Expert Examples are there to help you make your decision. They have been provided by experts in the field and their answers (and reasoning) are considered the ground truth and should be used as a reference to make your decision when applicable.\\nFor example, you can say: \\\"According to Expert Example #1, ...\\\"\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■END■\"],\"systemPrompt\":\"You need to tag the input with the following labels based on the question asked:\\nABSOLUTELY_NOT: You are absolutely sure that the answer is \\\"NO\\\" to the question.\\nPROBABLY_NOT: You are leaning towards \\\"NO\\\" to the question.\\nAMBIGUOUS: You are unsure about the answer to the question.\\nPROBABLY_YES: You are leaning towards \\\"YES\\\" to the question.\\nABSOLUTELY_YES: You are absolutely sure that the answer is \\\"YES\\\" to the question.\\n\\nYou need to return a mapping of the labels, an explanation and the answer for each label following the format below:\\n```\\n■is_human:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person a human?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■good_person:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person a good person?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■bad_person:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person a bad person?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■canadian:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person canadian?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■is_french:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person french?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n■END■\\n```\\n\\nundefined\\n\\n===\\nYou should consider the Expert Examples below to help you make your decision.\\nIn your \\\"Analysis\\\", please refer to the Expert Examples # to justify your decision.\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-BfuezdTLpBtnv2EiyrP83gKJdUtxJ","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"```\n■is_human:【The name \"Sylvain Perron\" refers to an individual and there is no indication that it is not a human.】:ABSOLUTELY_YES■\n\n■good_person:【The input states that Sylvain Perron has no criminal record, which implies no criminal activities. This leans towards considering Sylvain Perron a good person, though it is not definitive proof.】:PROBABLY_YES■\n\n■bad_person:【The input explicitly mentions that Sylvain Perron has no criminal record, which strongly suggests no history of bad or criminal actions.】:ABSOLUTELY_NOT■\n\n■canadian:【According to Expert Example #1, all users are assumed to be Canadian unless stated otherwise. Thus, we assume Sylvain Perron is Canadian.】:ABSOLUTELY_YES■\n\n■is_french:【As per Expert Example #1, Sylvain is a common French name. Combining this with \"Perron,\" which is also a French last name, this strongly suggests a French origin for the person.】:ABSOLUTELY_YES■\n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":1085,"inputCost":0.0027125,"outputTokens":233,"outputCost":0.00233},"botpress":{"cost":0.0050425}},"meta":{"cached":false}}}
|
|
114
|
+
{"test":"zai.extract > extract an object from a long text (multi-chunks)-1","key":"a6498cbe","input":"[{\"input\":{\"messages\":[{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ name: string, age: number }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nExtract the person\\n<|end_instructions|>\\n\\n<|start_input|>\\nThe story goes as follow.\\nOnce upon a time, there was a person named Alice who was 30 years old.\\nThe end.\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"■json_start■\\n{\\n \\\"name\\\": \\\"Alice\\\",\\n \\\"age\\\": 30\\n}\\n■json_end■■NO_MORE_ELEMENT■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ features: string[] }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nExtract all features from the text\\n<|end_instructions|>\\n\\n<|start_input|>\\nFeature 1: Tables\\n\\nTOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■json_end■\"],\"systemPrompt\":\"Extract the following information from the input:\\n{ features: string[] }\\n====\\n\\n• Extract all features from the text\\n• You may have exactly one element in the input.\\n• The element must be a JSON object with exactly the format: ■json_start■{ \\\"features\\\": ... }■json_end■\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-BoeqeFLis4DRMC6fNOdnjj4cFFYcB","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"■json_start■\n{\n \"features\": [\"Tables\"]\n}\n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":510,"inputCost":0.001275,"outputTokens":18,"outputCost":0.00018},"botpress":{"cost":0.0014550000000000001}},"meta":{"cached":false}}}
|
|
115
|
+
{"test":"zai.learn.check > learns a contradiction from examples-2","key":"4e329aaf","input":"[{\"input\":{\"messages\":[{\"content\":\"Expert Example #1\\n<|start_input|>\\nwhat is up\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"Analysis: \\\"What's up\\\" in our business scenario is NOT considered an official greeting.\\nFinal Answer: ■FALSE■\\n■END■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Expert Example #2\\n<|start_input|>\\nhello! how are you?\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"Analysis: \\\"hello!\\\" is a common greeting in English.\\nFinal Answer: ■TRUE■\\n■END■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Expert Example #3\\n<|start_input|>\\nwassup\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"Analysis: \\\"wassup\\\" is a slang term and not considered a formal greeting. It is therefore NOT considered a greeting.\\nFinal Answer: ■FALSE■\\n■END■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Considering the below input and above examples, is the following condition true or false?\\nExpert Example #4\\n<|start_input|>\\nWhat's up\\n<|end_input|>\\nIn your \\\"Analysis\\\", please refer to the Expert Examples # to justify your decision.\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■END■\"],\"systemPrompt\":\"Check if the following condition is true or false for the given input. Before answering, make sure to read the input and the condition carefully.\\nJustify your answer, then answer with either ■TRUE■ or ■FALSE■ at the very end, then add ■END■ to finish the response.\\nIMPORTANT: Make sure to answer with either ■TRUE■ or ■FALSE■ at the end of your response, but NOT both.\\n---\\nExpert Examples (#1 to #3):\\n- You have been provided with examples from previous experts. Make sure to read them carefully before making your decision.\\n- Make sure to refer to the examples provided by the experts to justify your decision (when applicable).\\n- When in doubt, ground your decision on the examples provided by the experts instead of your own intuition.\\n- When no example is similar to the input, make sure to provide a clear justification for your decision while inferring the decision-making process from the examples provided by the experts.\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-BoeqfvqOlqnlj3NW5hWOR1ctHtd2t","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"Analysis: In Expert Example #1, the phrase \"what is up\" was determined to NOT be an official greeting in this context, as it was clarified to not meet the standard criteria of formal greetings. The phrase \"What's up\" is simply a contraction of \"What is up\" and carries the exact same meaning. Based on Expert Example #1, \"What's up\" should also NOT be considered a formal greeting and the same logic applies.\n\nFinal Answer: ■FALSE■ \n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":428,"inputCost":0.00107,"outputTokens":99,"outputCost":0.00099},"botpress":{"cost":0.00206}},"meta":{"cached":false}}}
|
|
116
|
+
{"test":"zai.extract > extract an object from a long text (multi-chunks)-2","key":"4dbf859c","input":"[{\"input\":{\"messages\":[{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ name: string, age: number }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nExtract the person\\n<|end_instructions|>\\n\\n<|start_input|>\\nThe story goes as follow.\\nOnce upon a time, there was a person named Alice who was 30 years old.\\nThe end.\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"■json_start■\\n{\\n \\\"name\\\": \\\"Alice\\\",\\n \\\"age\\\": 30\\n}\\n■json_end■■NO_MORE_ELEMENT■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ features: string[] }\\n<|end_schema|>\\n\\n<|start_instructions|>\\n\\n<|end_instructions|>\\n\\n<|start_input|>\\nTOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■json_end■\"],\"systemPrompt\":\"Extract the following information from the input:\\n{ features: string[] }\\n====\\n\\n• You may have exactly one element in the input.\\n• The element must be a JSON object with exactly the format: ■json_start■{ \\\"features\\\": ... }■json_end■\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-BoexzfMG4AUBJdcNCBdbruK5P2XUv","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"■json_start■\n{\n \"features\": []\n}\n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":495,"inputCost":0.0012375,"outputTokens":16,"outputCost":0.00016},"botpress":{"cost":0.0013975}},"meta":{"cached":false}}}
|
|
117
|
+
{"test":"zai.extract > extract an object from a long text (multi-chunks)-6","key":"4dbf859c","input":"[{\"input\":{\"messages\":[{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ name: string, age: number }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nExtract the person\\n<|end_instructions|>\\n\\n<|start_input|>\\nThe story goes as follow.\\nOnce upon a time, there was a person named Alice who was 30 years old.\\nThe end.\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"■json_start■\\n{\\n \\\"name\\\": \\\"Alice\\\",\\n \\\"age\\\": 30\\n}\\n■json_end■■NO_MORE_ELEMENT■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ features: string[] }\\n<|end_schema|>\\n\\n<|start_instructions|>\\n\\n<|end_instructions|>\\n\\n<|start_input|>\\nTOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■json_end■\"],\"systemPrompt\":\"Extract the following information from the input:\\n{ features: string[] }\\n====\\n\\n• You may have exactly one element in the input.\\n• The element must be a JSON object with exactly the format: ■json_start■{ \\\"features\\\": ... }■json_end■\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-BoexzeFdVqs5wrnVapJ2vNkziKsQM","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"■json_start■\n{\n \"features\": []\n}\n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":495,"inputCost":0.0012375,"outputTokens":16,"outputCost":0.00016},"botpress":{"cost":0.0013975}},"meta":{"cached":false}}}
|
|
118
|
+
{"test":"zai.extract > extract an object from a long text (multi-chunks)-4","key":"4dbf859c","input":"[{\"input\":{\"messages\":[{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ name: string, age: number }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nExtract the person\\n<|end_instructions|>\\n\\n<|start_input|>\\nThe story goes as follow.\\nOnce upon a time, there was a person named Alice who was 30 years old.\\nThe end.\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"■json_start■\\n{\\n \\\"name\\\": \\\"Alice\\\",\\n \\\"age\\\": 30\\n}\\n■json_end■■NO_MORE_ELEMENT■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ features: string[] }\\n<|end_schema|>\\n\\n<|start_instructions|>\\n\\n<|end_instructions|>\\n\\n<|start_input|>\\nTOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■json_end■\"],\"systemPrompt\":\"Extract the following information from the input:\\n{ features: string[] }\\n====\\n\\n• You may have exactly one element in the input.\\n• The element must be a JSON object with exactly the format: ■json_start■{ \\\"features\\\": ... }■json_end■\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-BoexzESpFoQ3wUAFBpauyCXDtMBut","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"■json_start■\n{\n \"features\": []\n}\n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":495,"inputCost":0.0012375,"outputTokens":16,"outputCost":0.00016},"botpress":{"cost":0.0013975}},"meta":{"cached":false}}}
|
|
119
|
+
{"test":"zai.extract > extract an object from a long text (multi-chunks)-5","key":"1152200","input":"[{\"input\":{\"messages\":[{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ name: string, age: number }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nExtract the person\\n<|end_instructions|>\\n\\n<|start_input|>\\nThe story goes as follow.\\nOnce upon a time, there was a person named Alice who was 30 years old.\\nThe end.\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"■json_start■\\n{\\n \\\"name\\\": \\\"Alice\\\",\\n \\\"age\\\": 30\\n}\\n■json_end■■NO_MORE_ELEMENT■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ features: string[] }\\n<|end_schema|>\\n\\n<|start_instructions|>\\n\\n<|end_instructions|>\\n\\n<|start_input|>\\nTOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN \\nFeature 3: Analytics\\n\\nTOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■json_end■\"],\"systemPrompt\":\"Extract the following information from the input:\\n{ features: string[] }\\n====\\n\\n• You may have exactly one element in the input.\\n• The element must be a JSON object with exactly the format: ■json_start■{ \\\"features\\\": ... }■json_end■\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-Boexzc0rUvNlrxfLgMMZol41xcmm7","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"■json_start■\n{\n \"features\": [\"Analytics\"]\n}\n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":495,"inputCost":0.0012375,"outputTokens":18,"outputCost":0.00018},"botpress":{"cost":0.0014175000000000001}},"meta":{"cached":false}}}
|
|
120
|
+
{"test":"zai.extract > extract an object from a long text (multi-chunks)-7","key":"80fd0a19","input":"[{\"input\":{\"messages\":[{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ name: string, age: number }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nExtract the person\\n<|end_instructions|>\\n\\n<|start_input|>\\nThe story goes as follow.\\nOnce upon a time, there was a person named Alice who was 30 years old.\\nThe end.\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"■json_start■\\n{\\n \\\"name\\\": \\\"Alice\\\",\\n \\\"age\\\": 30\\n}\\n■json_end■■NO_MORE_ELEMENT■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ features: string[] }\\n<|end_schema|>\\n\\n<|start_instructions|>\\n\\n<|end_instructions|>\\n\\n<|start_input|>\\nTOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN \\nFeature 4: Integrations\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■json_end■\"],\"systemPrompt\":\"Extract the following information from the input:\\n{ features: string[] }\\n====\\n\\n• You may have exactly one element in the input.\\n• The element must be a JSON object with exactly the format: ■json_start■{ \\\"features\\\": ... }■json_end■\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-BoexzZ8gppN0rOErqrvijsAVApFHF","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"■json_start■\n{\n \"features\": [\"Integrations\"]\n}\n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":278,"inputCost":0.0006950000000000001,"outputTokens":19,"outputCost":0.00019},"botpress":{"cost":0.0008850000000000002}},"meta":{"cached":false}}}
|
|
121
|
+
{"test":"zai.extract > extract an object from a long text (multi-chunks)-1","key":"91831a4e","input":"[{\"input\":{\"messages\":[{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ name: string, age: number }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nExtract the person\\n<|end_instructions|>\\n\\n<|start_input|>\\nThe story goes as follow.\\nOnce upon a time, there was a person named Alice who was 30 years old.\\nThe end.\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"■json_start■\\n{\\n \\\"name\\\": \\\"Alice\\\",\\n \\\"age\\\": 30\\n}\\n■json_end■■NO_MORE_ELEMENT■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ features: string[] }\\n<|end_schema|>\\n\\n<|start_instructions|>\\n\\n<|end_instructions|>\\n\\n<|start_input|>\\nFeature 1: Tables\\n\\nTOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■json_end■\"],\"systemPrompt\":\"Extract the following information from the input:\\n{ features: string[] }\\n====\\n\\n• You may have exactly one element in the input.\\n• The element must be a JSON object with exactly the format: ■json_start■{ \\\"features\\\": ... }■json_end■\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-BoexzeiYWHlatCgbf3cDYzuykuVhS","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"■json_start■\n{\n \"features\": [\"Tables\"]\n}\n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":495,"inputCost":0.0012375,"outputTokens":18,"outputCost":0.00018},"botpress":{"cost":0.0014175000000000001}},"meta":{"cached":false}}}
|
|
122
|
+
{"test":"zai.extract > extract an object from a long text (multi-chunks)-3","key":"2e2accda","input":"[{\"input\":{\"messages\":[{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ name: string, age: number }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nExtract the person\\n<|end_instructions|>\\n\\n<|start_input|>\\nThe story goes as follow.\\nOnce upon a time, there was a person named Alice who was 30 years old.\\nThe end.\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"■json_start■\\n{\\n \\\"name\\\": \\\"Alice\\\",\\n \\\"age\\\": 30\\n}\\n■json_end■■NO_MORE_ELEMENT■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ features: string[] }\\n<|end_schema|>\\n\\n<|start_instructions|>\\n\\n<|end_instructions|>\\n\\n<|start_input|>\\nTOKEN TOKEN TOKEN TOKEN TOKEN TOKEN \\nFeature 2: HITL (Human in the Loop)\\n\\nTOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN TOKEN\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■json_end■\"],\"systemPrompt\":\"Extract the following information from the input:\\n{ features: string[] }\\n====\\n\\n• You may have exactly one element in the input.\\n• The element must be a JSON object with exactly the format: ■json_start■{ \\\"features\\\": ... }■json_end■\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-Boexz0y0iBcs716HrVCuXhlaS4UkV","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"■json_start■\n{\n \"features\": [\"HITL (Human in the Loop)\"]\n}\n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":495,"inputCost":0.0012375,"outputTokens":26,"outputCost":0.00026000000000000003},"botpress":{"cost":0.0014975000000000001}},"meta":{"cached":false}}}
|
|
123
|
+
{"test":"zai.extract > extract an object from a long text (multi-chunks)-8","key":"ba3ad024","input":"[{\"input\":{\"messages\":[{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ name: string, age: number }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nExtract the person\\n<|end_instructions|>\\n\\n<|start_input|>\\nThe story goes as follow.\\nOnce upon a time, there was a person named Alice who was 30 years old.\\nThe end.\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"■json_start■\\n{\\n \\\"name\\\": \\\"Alice\\\",\\n \\\"age\\\": 30\\n}\\n■json_end■■NO_MORE_ELEMENT■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ features: string[] }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nExtract all features from the text\\n<|end_instructions|>\\n\\n<|start_input|>\\n[\\n {\\n \\\"features\\\": [\\n \\\"Tables\\\"\\n ]\\n },\\n {\\n \\\"features\\\": []\\n },\\n {\\n \\\"features\\\": [\\n \\\"HITL (Human in the Loop)\\\"\\n ]\\n },\\n {\\n \\\"features\\\": []\\n },\\n {\\n \\\"features\\\": [\\n \\\"Analytics\\\"\\n ]\\n },\\n {\\n \\\"features\\\": []\\n },\\n {\\n \\\"features\\\": [\\n \\\"Integrations\\\"\\n ]\\n }\\n]\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■json_end■\"],\"systemPrompt\":\"Extract the following information from the input:\\n{ features: string[] }\\n====\\n\\n• Extract all features from the text\\n• You may have exactly one element in the input.\\n• The element must be a JSON object with exactly the format: ■json_start■{ \\\"features\\\": ... }■json_end■\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-BoezM1L9LPCwShFFXh9RIxpRnKeZU","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"■json_start■\n{\n \"features\": [\n \"Tables\",\n \"HITL (Human in the Loop)\",\n \"Analytics\",\n \"Integrations\"\n ]\n}\n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":356,"inputCost":0.0008900000000000001,"outputTokens":42,"outputCost":0.00042},"botpress":{"cost":0.00131}},"meta":{"cached":false}}}
|
|
124
|
+
{"test":"zai.extract > extract an array of objects from a super long text-24","key":"dc0440e5","input":"[{\"input\":{\"messages\":[{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\nArray<{ name: string, age: number }>\\n<|end_schema|>\\n\\n<|start_instructions|>\\nExtract all people\\n<|end_instructions|>\\n\\n<|start_input|>\\nThe story goes as follow.\\nOnce upon a time, there was a person named Alice who was 30 years old.\\nThen, there was a person named Bob who was 25 years old.\\nThe end.\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"■json_start■\\n{\\n \\\"name\\\": \\\"Alice\\\",\\n \\\"age\\\": 30\\n}\\n■json_end■\\n■json_start■\\n{\\n \\\"name\\\": \\\"Bob\\\",\\n \\\"age\\\": 25\\n}\\n■json_end■■NO_MORE_ELEMENT■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Here's an example to help you understand the format:\\n\\n<|start_schema|>\\n{ \\n/** The name of the feature */\\nfeature: string\\n; \\n/** The parent feature */\\nparent?: string | undefined | null\\n; \\n/** The description of the feature */\\ndescription: string\\n }\\n<|end_schema|>\\n\\n<|start_instructions|>\\nExtract all things that looks like a Botpress feature in the provided input. You must extract a minimum of one element.\\n<|end_instructions|>\\n\\n<|start_input|>\\n[\\n [],\\n [],\\n [],\\n [],\\n [],\\n [],\\n [],\\n [],\\n [],\\n [],\\n [\\n {\\n \\\"feature\\\": \\\"DOCX KB Source\\\",\\n \\\"parent\\\": null,\\n \\\"description\\\": \\\"Allows uploading DOCX files to make them searchable and accessible in Botpress for employees.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"File Limits in KB\\\",\\n \\\"parent\\\": \\\"DOCX KB Source\\\",\\n \\\"description\\\": \\\"Enables uploading up to 100 documents with a size limit of 50MB per document for efficient utilization.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"Web Pages KB Source\\\",\\n \\\"parent\\\": null,\\n \\\"description\\\": \\\"Allows users to upload websites to the Knowledge Base, incorporating articles, blogs, forums, and other online content.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"Add from URLs\\\",\\n \\\"parent\\\": \\\"Web Pages KB Source\\\",\\n \\\"description\\\": \\\"Users can add web pages by entering URLs (maximum 350 characters per URL), with content automatically retrieved for the Knowledge Base.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"Add from Site Map\\\",\\n \\\"parent\\\": \\\"Web Pages KB Source\\\",\\n \\\"description\\\": \\\"Users can add multiple web pages by providing a site map URL that lists URLs to be added to the Knowledge Base.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"Web Search KB Source\\\",\\n \\\"parent\\\": null,\\n \\\"description\\\": \\\"Customize the Knowledge Base by specifying websites to include or exclude in the search, or by applying time filters.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"Filter Search Results by Time Period\\\",\\n \\\"parent\\\": \\\"Web Search KB Source\\\",\\n \\\"description\\\": \\\"Allows filtering search results by time, such as the last 24 hours, 7 days, or 30 days, for obtaining the most relevant information.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"Text Document KB Source\\\",\\n \\\"parent\\\": null,\\n \\\"description\\\": \\\"Supports creating and organizing plain text information, like FAQs, guides, and manuals, for quick access to topical information.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"Tables KB Source\\\",\\n \\\"parent\\\": null,\\n \\\"description\\\": \\\"Enables users to connect tables to the Knowledge Base, allowing data to be searched and accessed easily.\\\"\\n }\\n ],\\n [],\\n [],\\n [],\\n [],\\n [],\\n [],\\n [],\\n [],\\n [],\\n [\\n {\\n \\\"feature\\\": \\\"Best\\\",\\n \\\"parent\\\": null,\\n \\\"description\\\": \\\"This model should be used for complex tasks, prioritizing performance over speed or cost.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"Autonomous Language Model\\\",\\n \\\"parent\\\": null,\\n \\\"description\\\": \\\"This is the model that powers LLMz and generates responses, including all of your Autonomous Nodes.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"LLMz Version\\\",\\n \\\"parent\\\": null,\\n \\\"description\\\": \\\"The version of LLMz that your bot uses. We recommend staying updated to the latest version, but you may find that a bot built on previous versions of LLMz function best on those versions.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"Variables\\\",\\n \\\"parent\\\": null,\\n \\\"description\\\": \\\"In these sections, you can identify variables that exist above the scope of workflow variables, like user and bot variables. You can learn more about variables [here](https://botpress.com/docs/variables).\\\"\\n },\\n {\\n \\\"feature\\\": \\\"Policy Agent\\\",\\n \\\"parent\\\": \\\"Key Features\\\",\\n \\\"description\\\": \\\"The Policy Agent is a rules-based mechanism that controls the outputs of LLMs by enforcing constraints and guardrails. By configuring policies, users can dictate acceptable response behaviors, prevent harmful outputs, and ensure that AI actions align with brand values.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"RAG Safety\\\",\\n \\\"parent\\\": \\\"Key Features\\\",\\n \\\"description\\\": \\\"Retrieval-Augmented Generation (RAG) Safety provides transparency over the data selection process used by LLMs. It reveals which data chunks were identified as relevant to a query and which were ultimately submitted to the LLM. Users have the ability to review, approve, or modify these selections, ensuring that only the most appropriate data informs the AI's output.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"LLM Inspector\\\",\\n \\\"parent\\\": \\\"Key Features\\\",\\n \\\"description\\\": \\\"The LLM Inspector is a tool that breaks down the decision-making process of the LLM, showing why it selected certain actions or responses. By dissecting the LLM’s internal logic, users can gain insights into the decision pathways and make informed adjustments to align AI behavior with brand standards.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"HITL\\\",\\n \\\"parent\\\": \\\"Key Features\\\",\\n \\\"description\\\": \\\"HITL, or Human-in-the-Loop, allows you to participate in an AI agent's conversation directly from the Botpress dashboard. This feature offers a critical layer of oversight and control when using LLMs in customer- or user-facing interactions. It was designed to ensure that sensitive or high-risk conversations can be escalated to human agents, helping maintain brand integrity, mitigate potential issues, and protect user privacy.\\\"\\n },\\n {\\n \\\"feature\\\": \\\"Knowledge Agent\\\",\\n \\\"parent\\\": \\\"Agents\\\",\\n \\\"description\\\": \\\"The Query Knowledge Bases card allows you to programmatically query Knowledge Bases from within your bot. This card is useful when you want to retrieve information from your Knowledge Bases and display it to the user during the conversation.\\\"\\n }\\n ],\\n [],\\n []\\n]\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■NO_MORE_ELEMENT■\"],\"systemPrompt\":\"Extract the following information from the input:\\n{ \\n/** The name of the feature */\\nfeature: string\\n; \\n/** The parent feature */\\nparent?: string | undefined | null\\n; \\n/** The description of the feature */\\ndescription: string\\n }\\n====\\n\\n• Extract all things that looks like a Botpress feature in the provided input. You must extract a minimum of one element.\\n• You may have multiple elements, or zero elements in the input.\\n• You must extract each element separately.\\n• Each element must be a JSON object with exactly the format: ■json_start■{ \\\"feature\\\": ..., \\\"parent\\\": ..., \\\"description\\\": ... }■json_end■\\n• When you are done extracting all elements, type \\\"■NO_MORE_ELEMENT■\\\" to finish.\\n• For example, if you have zero elements, the output should look like this: ■NO_MORE_ELEMENT■\\n• For example, if you have two elements, the output should look like this: ■json_start■{ ... }■json_end■■json_start■{ ... }■json_end■■NO_MORE_ELEMENT■\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-Bof0VUE4GGbeHXcWu9ji1xiMDi0wn","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"■json_start■\n{\n \"feature\": \"DOCX KB Source\",\n \"parent\": null,\n \"description\": \"Allows uploading DOCX files to make them searchable and accessible in Botpress for employees.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"File Limits in KB\",\n \"parent\": \"DOCX KB Source\",\n \"description\": \"Enables uploading up to 100 documents with a size limit of 50MB per document for efficient utilization.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"Web Pages KB Source\",\n \"parent\": null,\n \"description\": \"Allows users to upload websites to the Knowledge Base, incorporating articles, blogs, forums, and other online content.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"Add from URLs\",\n \"parent\": \"Web Pages KB Source\",\n \"description\": \"Users can add web pages by entering URLs (maximum 350 characters per URL), with content automatically retrieved for the Knowledge Base.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"Add from Site Map\",\n \"parent\": \"Web Pages KB Source\",\n \"description\": \"Users can add multiple web pages by providing a site map URL that lists URLs to be added to the Knowledge Base.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"Web Search KB Source\",\n \"parent\": null,\n \"description\": \"Customize the Knowledge Base by specifying websites to include or exclude in the search, or by applying time filters.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"Filter Search Results by Time Period\",\n \"parent\": \"Web Search KB Source\",\n \"description\": \"Allows filtering search results by time, such as the last 24 hours, 7 days, or 30 days, for obtaining the most relevant information.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"Text Document KB Source\",\n \"parent\": null,\n \"description\": \"Supports creating and organizing plain text information, like FAQs, guides, and manuals, for quick access to topical information.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"Tables KB Source\",\n \"parent\": null,\n \"description\": \"Enables users to connect tables to the Knowledge Base, allowing data to be searched and accessed easily.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"Best\",\n \"parent\": null,\n \"description\": \"This model should be used for complex tasks, prioritizing performance over speed or cost.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"Autonomous Language Model\",\n \"parent\": null,\n \"description\": \"This is the model that powers LLMz and generates responses, including all of your Autonomous Nodes.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"LLMz Version\",\n \"parent\": null,\n \"description\": \"The version of LLMz that your bot uses. We recommend staying updated to the latest version, but you may find that a bot built on previous versions of LLMz function best on those versions.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"Variables\",\n \"parent\": null,\n \"description\": \"In these sections, you can identify variables that exist above the scope of workflow variables, like user and bot variables. You can learn more about variables [here](https://botpress.com/docs/variables).\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"Policy Agent\",\n \"parent\": \"Key Features\",\n \"description\": \"The Policy Agent is a rules-based mechanism that controls the outputs of LLMs by enforcing constraints and guardrails. By configuring policies, users can dictate acceptable response behaviors, prevent harmful outputs, and ensure that AI actions align with brand values.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"RAG Safety\",\n \"parent\": \"Key Features\",\n \"description\": \"Retrieval-Augmented Generation (RAG) Safety provides transparency over the data selection process used by LLMs. It reveals which data chunks were identified as relevant to a query and which were ultimately submitted to the LLM. Users have the ability to review, approve, or modify these selections, ensuring that only the most appropriate data informs the AI's output.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"LLM Inspector\",\n \"parent\": \"Key Features\",\n \"description\": \"The LLM Inspector is a tool that breaks down the decision-making process of the LLM, showing why it selected certain actions or responses. By dissecting the LLM’s internal logic, users can gain insights into the decision pathways and make informed adjustments to align AI behavior with brand standards.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"HITL\",\n \"parent\": \"Key Features\",\n \"description\": \"HITL, or Human-in-the-Loop, allows you to participate in an AI agent's conversation directly from the Botpress dashboard. This feature offers a critical layer of oversight and control when using LLMs in customer- or user-facing interactions. It was designed to ensure that sensitive or high-risk conversations can be escalated to human agents, helping maintain brand integrity, mitigate potential issues, and protect user privacy.\"\n}\n■json_end■\n■json_start■\n{\n \"feature\": \"Knowledge Agent\",\n \"parent\": \"Agents\",\n \"description\": \"The Query Knowledge Bases card allows you to programmatically query Knowledge Bases from within your bot. This card is useful when you want to retrieve information from your Knowledge Bases and display it to the user during the conversation.\"\n}\n■json_end■","index":0,"stopReason":"stop"}],"usage":{"inputTokens":1653,"inputCost":0.004132500000000001,"outputTokens":1236,"outputCost":0.012360000000000001},"botpress":{"cost":0.0164925}},"meta":{"cached":false}}}
|
|
125
|
+
{"test":"zai.learn.filter > learns a filtering rule from examples-1","key":"f7f2a172","input":"[{\"input\":{\"messages\":[{\"content\":\"Condition to check:\\ncompetes with us? (botpress)\\n\\nItems (from ■0 to ■-1)\\n==============================\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"■END■\\n====\\nHere's the reasoning behind each example:\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Condition to check:\\ncompetes with us? (botpress)\\n\\nItems (from ■0 to ■4)\\n==============================\\n■0 = Nike\\n■1 = Ada.cx\\n■2 = Adidas\\n■3 = Moveworks\\n■4 = Lululemon\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■END■\"],\"systemPrompt\":\"You are given a list of items. Your task is to filter out the items that meet the condition below.\\nYou need to return the full list of items with the format:\\n■x:true■y:false■z:true (where x, y, z are the indices of the items in the list)\\nYou need to start with \\\"■0\\\" and go up to the last index \\\"■4\\\".\\nIf an item meets the condition, you should return \\\":true\\\", otherwise \\\":false\\\".\\n\\nIMPORTANT: Make sure to read the condition and the examples carefully before making your decision.\\nThe condition is: \\\"competes with us? (botpress)\\\"\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-Bof1Oru7JDAtm8ybcT0APbDsdp9iH","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"■0:false■1:true■2:false■3:true■4:false","index":0,"stopReason":"stop"}],"usage":{"inputTokens":239,"inputCost":0.0005975,"outputTokens":15,"outputCost":0.00015000000000000001},"botpress":{"cost":0.0007475000000000001}},"meta":{"cached":false}}}
|
|
126
|
+
{"test":"zai.learn.check > learns a contradiction from examples-2","key":"24fc15ca","input":"[{\"input\":{\"messages\":[{\"content\":\"Expert Example #1\\n<|start_input|>\\nwassup\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"Analysis: \\\"wassup\\\" is a slang term and not considered a formal greeting. It is therefore NOT considered a greeting.\\nFinal Answer: ■FALSE■\\n■END■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Expert Example #2\\n<|start_input|>\\nwhat is up\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"Analysis: \\\"What's up\\\" in our business scenario is NOT considered an official greeting.\\nFinal Answer: ■FALSE■\\n■END■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Considering the below input and above examples, is the following condition true or false?\\nExpert Example #3\\n<|start_input|>\\nWhat's up\\n<|end_input|>\\nIn your \\\"Analysis\\\", please refer to the Expert Examples # to justify your decision.\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■END■\"],\"systemPrompt\":\"Check if the following condition is true or false for the given input. Before answering, make sure to read the input and the condition carefully.\\nJustify your answer, then answer with either ■TRUE■ or ■FALSE■ at the very end, then add ■END■ to finish the response.\\nIMPORTANT: Make sure to answer with either ■TRUE■ or ■FALSE■ at the end of your response, but NOT both.\\n---\\nExpert Examples (#1 to #2):\\n- You have been provided with examples from previous experts. Make sure to read them carefully before making your decision.\\n- Make sure to refer to the examples provided by the experts to justify your decision (when applicable).\\n- When in doubt, ground your decision on the examples provided by the experts instead of your own intuition.\\n- When no example is similar to the input, make sure to provide a clear justification for your decision while inferring the decision-making process from the examples provided by the experts.\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-Bof1arlHtm5yIQ8mBKE3MtIej2vxf","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"Analysis: In Expert Example #2, the input \"what is up\" was determined to NOT be an official greeting and was labeled as ■FALSE■. The input in this case, \"What's up\", is merely a contraction of \"what is up\" and serves the same informal conversational purpose. Therefore, using the reasoning from Expert Example #2, \"What's up\" is also NOT considered an official greeting.\n\nFinal Answer: ■FALSE■ \n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":375,"inputCost":0.0009375000000000001,"outputTokens":92,"outputCost":0.00092},"botpress":{"cost":0.0018575000000000002}},"meta":{"cached":false}}}
|
|
127
|
+
{"test":"zai.learn.check > learns a contradiction from examples-2","key":"dcd6d070","input":"[{\"input\":{\"messages\":[{\"content\":\"Expert Example #1\\n<|start_input|>\\nwhat is up\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"Analysis: \\\"What's up\\\" in our business scenario is NOT considered an official greeting.\\nFinal Answer: ■FALSE■\\n■END■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Considering the below input and above examples, is the following condition true or false?\\nExpert Example #2\\n<|start_input|>\\nWhat's up\\n<|end_input|>\\nIn your \\\"Analysis\\\", please refer to the Expert Examples # to justify your decision.\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■END■\"],\"systemPrompt\":\"Check if the following condition is true or false for the given input. Before answering, make sure to read the input and the condition carefully.\\nJustify your answer, then answer with either ■TRUE■ or ■FALSE■ at the very end, then add ■END■ to finish the response.\\nIMPORTANT: Make sure to answer with either ■TRUE■ or ■FALSE■ at the end of your response, but NOT both.\\n---\\nExpert Examples (#1 to #1):\\n- You have been provided with examples from previous experts. Make sure to read them carefully before making your decision.\\n- Make sure to refer to the examples provided by the experts to justify your decision (when applicable).\\n- When in doubt, ground your decision on the examples provided by the experts instead of your own intuition.\\n- When no example is similar to the input, make sure to provide a clear justification for your decision while inferring the decision-making process from the examples provided by the experts.\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-Bof1pnnmDOZEdXUsIBR2RoCQjRoA2","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"Analysis: In Expert Example #1, the phrase \"what is up\" is evaluated as not being an official greeting in our business scenario. The phrasing \"What's up\" in Expert Example #2 is synonymous with \"what is up,\" as it conveys the same informal tone and context. Drawing from the judgment in Expert Example #1, \"What's up\" would also not qualify as an official greeting.\n\nFinal Answer: ■FALSE■ \n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":312,"inputCost":0.0007800000000000001,"outputTokens":91,"outputCost":0.0009100000000000001},"botpress":{"cost":0.00169}},"meta":{"cached":false}}}
|
|
128
|
+
{"test":"zai.learn.check > learns a contradiction from examples-1","key":"9fd30464","input":"[{\"input\":{\"messages\":[{\"content\":\"Expert Example #1\\n<|start_input|>\\nwassup\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"Analysis: \\\"wassup\\\" is a slang term and not considered a formal greeting. It is therefore NOT considered a greeting.\\nFinal Answer: ■FALSE■\\n■END■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Expert Example #2\\n<|start_input|>\\nhello! how are you?\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"Analysis: \\\"hello!\\\" is a common greeting in English.\\nFinal Answer: ■TRUE■\\n■END■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Considering the below input and above examples, is the following condition true or false?\\nExpert Example #3\\n<|start_input|>\\nWhat's up\\n<|end_input|>\\nIn your \\\"Analysis\\\", please refer to the Expert Examples # to justify your decision.\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■END■\"],\"systemPrompt\":\"Check if the following condition is true or false for the given input. Before answering, make sure to read the input and the condition carefully.\\nJustify your answer, then answer with either ■TRUE■ or ■FALSE■ at the very end, then add ■END■ to finish the response.\\nIMPORTANT: Make sure to answer with either ■TRUE■ or ■FALSE■ at the end of your response, but NOT both.\\n---\\nExpert Examples (#1 to #2):\\n- You have been provided with examples from previous experts. Make sure to read them carefully before making your decision.\\n- Make sure to refer to the examples provided by the experts to justify your decision (when applicable).\\n- When in doubt, ground your decision on the examples provided by the experts instead of your own intuition.\\n- When no example is similar to the input, make sure to provide a clear justification for your decision while inferring the decision-making process from the examples provided by the experts.\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-Bof26kM8fOQ2NA49cN7gdBrkHfAQu","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"Analysis: The phrase \"What's up\" is a casual or informal way of greeting someone, similar in use to the slang \"wassup\" from Expert Example #1. In Example #1, \"wassup\" was determined to not be a formal greeting and the final answer was ■FALSE■. By the same reasoning, \"What's up\" would also not qualify as a greeting based on its informal and slang nature. \n\nFinal Answer: ■FALSE■ \n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":372,"inputCost":0.00093,"outputTokens":95,"outputCost":0.0009500000000000001},"botpress":{"cost":0.0018800000000000002}},"meta":{"cached":false}}}
|
|
129
|
+
{"test":"zai.learn.rewrite > learns rewrite rules from examples-2","key":"968f491","input":"[{\"input\":{\"messages\":[{\"content\":\"Prompt: write it like we want it\\n\\n■START■\\nMicrosoft is a big company\\n■END■\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"■START■# MICROSOFT IS A BIG COMPANY■END■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Prompt: write it like we want it\\n\\n■START■\\nBotpress is awesome\\n■END■\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■END■\"],\"systemPrompt\":\"Rewrite the text between the ■START■ and ■END■ tags to match the user prompt.\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-Bof28txUE40vS1gWRBEAFWRrTsWYn","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"■START■Botpress is absolutely awesome!","index":0,"stopReason":"stop"}],"usage":{"inputTokens":95,"inputCost":0.00023750000000000003,"outputTokens":12,"outputCost":0.00012000000000000002},"botpress":{"cost":0.00035750000000000007}},"meta":{"cached":false}}}
|
|
130
|
+
{"test":"zai.learn.label > learns a labelling rule from examples-1","key":"39fae725","input":"[{\"input\":{\"messages\":[{\"content\":\"Expert Example #1\\n\\n<|start_input|>\\nJoannie Côté has a dog.\\n<|end_input|>\",\"role\":\"user\",\"type\":\"text\"},{\"content\":\"Expert Example #1\\n============\\n■canadian:【Since we are doing business only in Canada, we assume all users are Canadians.】:ABSOLUTELY_YES■\\n■is_french:【Important: Joannie is a common French name and Côté is a common French last name.】:ABSOLUTELY_YES■\\n■END■\",\"role\":\"assistant\",\"type\":\"text\"},{\"content\":\"Input to tag:\\n<|start_input|>\\nSylvain Perron has no criminal record.\\n<|end_input|>\\n\\nAnswer with this following format:\\n```\\n■is_human:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person a human?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■good_person:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person a good person?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■bad_person:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person a bad person?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■canadian:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person canadian?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■is_french:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person french?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n■END■\\n```\\n\\nFormat cheatsheet:\\n```\\n■label:【explanation】:x■\\n```\\n\\nWhere `x` is one of the following: ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES\\n\\nRemember: In your `explanation`, please refer to the Expert Examples # (and quote them) that are relevant to ground your decision-making process.\\nThe Expert Examples are there to help you make your decision. They have been provided by experts in the field and their answers (and reasoning) are considered the ground truth and should be used as a reference to make your decision when applicable.\\nFor example, you can say: \\\"According to Expert Example #1, ...\\\"\",\"role\":\"user\",\"type\":\"text\"}],\"model\":{\"id\":\"gpt-4o-2024-11-20\"},\"stopSequences\":[\"■END■\"],\"systemPrompt\":\"You need to tag the input with the following labels based on the question asked:\\nABSOLUTELY_NOT: You are absolutely sure that the answer is \\\"NO\\\" to the question.\\nPROBABLY_NOT: You are leaning towards \\\"NO\\\" to the question.\\nAMBIGUOUS: You are unsure about the answer to the question.\\nPROBABLY_YES: You are leaning towards \\\"YES\\\" to the question.\\nABSOLUTELY_YES: You are absolutely sure that the answer is \\\"YES\\\" to the question.\\n\\nYou need to return a mapping of the labels, an explanation and the answer for each label following the format below:\\n```\\n■is_human:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person a human?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■good_person:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person a good person?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■bad_person:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person a bad person?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■canadian:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person canadian?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n\\n■is_french:【explanation (where \\\"explanation\\\" is answering the question \\\"is the person french?\\\")】:x■ (where x is ABSOLUTELY_NOT | PROBABLY_NOT | AMBIGUOUS | PROBABLY_YES | ABSOLUTELY_YES)\\n■END■\\n```\\n\\nundefined\\n\\n===\\nYou should consider the Expert Examples below to help you make your decision.\\nIn your \\\"Analysis\\\", please refer to the Expert Examples # to justify your decision.\"},\"type\":\"openai:generateContent\"}]","value":{"output":{"id":"chatcmpl-Bof28Til5Fs5UiUT6f7qMi1k82ePB","provider":"OpenAI","model":"gpt-4o-2024-11-20","choices":[{"role":"assistant","type":"text","content":"```\n■is_human:【The name \"Sylvain Perron\" is indicative of a human individual. This aligns with a personal name format.】:ABSOLUTELY_YES■\n\n■good_person:【The input states that Sylvain Perron has no criminal record, which indicates absence of any known negative behavior but does not necessarily imply overall \"goodness\" as there is no further supporting evidence about their moral character.】:AMBIGUOUS■\n\n■bad_person:【The input states Sylvain Perron has no criminal record, which argues against them being a \"bad person\" based on legal standing, but does not definitively rule out this possibility.】:PROBABLY_NOT■\n\n■canadian:【According to Expert Example #1, since we assume all individuals mentioned in our database are Canadian, it is reasonable to classify Sylvain Perron as Canadian.】:ABSOLUTELY_YES■\n\n■is_french:【Per Expert Example #1, names such as \"Sylvain\" and \"Perron\" are commonly associated with French origins. It is reasonable to assume Sylvain Perron has French heritage or is French-speaking.】:ABSOLUTELY_YES■\n","index":0,"stopReason":"stop"}],"usage":{"inputTokens":1092,"inputCost":0.0027300000000000002,"outputTokens":250,"outputCost":0.0025},"botpress":{"cost":0.00523}},"meta":{"cached":false}}}
|
package/e2e/utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Client } from '@botpress/client'
|
|
2
|
+
import { Cognitive } from '@botpress/cognitive'
|
|
2
3
|
import { type TextTokenizer, getWasmTokenizer } from '@bpinternal/thicktoken'
|
|
3
4
|
import fs from 'node:fs'
|
|
4
5
|
import path from 'node:path'
|
|
@@ -21,8 +22,8 @@ export const getCachedClient = () => {
|
|
|
21
22
|
return getCachedCognitiveClient()
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export const getZai = () => {
|
|
25
|
-
const client = getCachedClient()
|
|
25
|
+
export const getZai = (cognitive?: Cognitive) => {
|
|
26
|
+
const client = cognitive || getCachedClient()
|
|
26
27
|
return new Zai({ client })
|
|
27
28
|
}
|
|
28
29
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/zai",
|
|
3
3
|
"description": "Zui AI (zai) – An LLM utility library written on top of Zui and the Botpress API",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.15",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@botpress/cognitive": "0.1.
|
|
26
|
+
"@botpress/cognitive": "0.1.28",
|
|
27
27
|
"json5": "^2.2.3",
|
|
28
28
|
"jsonrepair": "^3.10.0",
|
|
29
29
|
"lodash-es": "^4.17.21"
|
|
@@ -92,20 +92,15 @@ Zai.prototype.extract = async function <S extends OfType<AnyObjectOrArray>>(
|
|
|
92
92
|
|
|
93
93
|
const keys = Object.keys((schema as ZodObject).shape)
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
const inputAsString = stringify(input)
|
|
96
96
|
|
|
97
97
|
if (tokenizer.count(inputAsString) > options.chunkLength) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const chunks = chunk(tokens, options.chunkLength).map((x) => x.join(''))
|
|
102
|
-
const all = await Promise.all(chunks.map((chunk) => this.extract(chunk, originalSchema)))
|
|
98
|
+
const tokens = tokenizer.split(inputAsString)
|
|
99
|
+
const chunks = chunk(tokens, options.chunkLength).map((x) => x.join(''))
|
|
100
|
+
const all = await Promise.all(chunks.map((chunk) => this.extract(chunk, originalSchema)))
|
|
103
101
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
// Truncate the input to fit the model's input size
|
|
107
|
-
inputAsString = tokenizer.truncate(stringify(input), options.chunkLength)
|
|
108
|
-
}
|
|
102
|
+
// We run this function recursively until all chunks are merged into a single output
|
|
103
|
+
return this.extract(all, originalSchema, options)
|
|
109
104
|
}
|
|
110
105
|
|
|
111
106
|
const instructions: string[] = []
|