Skip to content

Instantly share code, notes, and snippets.

@SlyOtis
Created August 1, 2025 20:47
Show Gist options
  • Save SlyOtis/408cc2613386d3c6f88b28eac0df85ba to your computer and use it in GitHub Desktop.
Save SlyOtis/408cc2613386d3c6f88b28eac0df85ba to your computer and use it in GitHub Desktop.
Tengo + Bookable Training Data for Llama 3.1 8B
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of splice in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nv := [\"a\", \"b\", \"c\"]\nitems := splice(v, 0, 0, \"d\", \"e\") // items == [], v == [\"d\", \"e\", \"a\", \"b\", \"c\"]<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of type conversions in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\ns1 := string(1984) // \"1984\"\ni2 := int(\"-999\") // -999\nf3 := float(-51) // -51.0\nb4 := bool(1) // true\nc5 := char(\"X\") // 'X'<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of process in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nproc := start_process(\"app\", [\"arg1\", \"arg2\"], \"dir\", [])\nproc.wait()<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nWrite a Tengo function that demonstrates function values<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nf1 := func(a, b, c) { return a + b + c }\nf1([1, 2, 3]...) // => 6\nf1(1, [2, 3]...) // => 6\nf1(1, 2, [3]...) // => 6\nf1([1, 2]...) // Runtime Error: wrong number of arguments: want=3, got=2\nf2 := func(a, ...b) {}\nf2(1) // valid; a = 1, b = []\nf2(1, 2) // valid; a = 1, b = [2]\nf2(1, 2, 3) // valid; a = 1, b = [2, 3]\nf2([1, 2, 3]...) // valid; a = 1, b = [2, 3]<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nWrite Tengo functions with closures and error handling<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nvalidateData := func(data) {\n errors := []\n \n if !data {\n errors = append(errors, \"Data is required\")\n }\n \n if data && !data.name {\n errors = append(errors, \"Name is required\")\n }\n \n if data && data.email && !contains(data.email, \"@\") {\n errors = append(errors, \"Valid email required\")\n }\n \n if len(errors) > 0 {\n return {valid: false, errors: errors}\n }\n \n return {valid: true, data: data}\n}\n\ncreateCalculator := func(operation) {\n return func(a, b) {\n switch operation {\n case \"add\":\n return a + b\n case \"subtract\":\n return a - b\n case \"multiply\":\n return a * b\n case \"divide\":\n return b != 0 ? a / b : 0\n default:\n return 0\n }\n }\n}\n\nadd := createCalculator(\"add\")\nresult := add(10, 5)<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nWrite a Tengo function that demonstrates function values<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nfunc my_func(arg1, arg2) { // illegal\nreturn arg1 + arg2\n}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of splice in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nv := [\"a\", \"b\", \"c\"]\nitems := splice(v, 2, 1, \"d\") // items == [\"c\"], v == [\"a\", \"b\", \"d\"]<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow time handling and date operations in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nimport(\"times\")\n\nnow := times.now()\ntomorrow := now.add(24 * times.hour)\nnextWeek := now.add(7 * 24 * times.hour)\n\nformatted := now.format(\"2006-01-02 15:04:05\")\ndateOnly := now.format(\"2006-01-02\")\ntimeOnly := now.format(\"15:04\")\n\nisWeekend := now.weekday() == 0 || now.weekday() == 6\nisBusinessHours := now.hour() >= 9 && now.hour() < 18\n\nduration := tomorrow.sub(now).hours()\nprintln(\"Hours until tomorrow:\", duration)\n\nstartOfDay := times.parse(\"2006-01-02\", now.format(\"2006-01-02\"))\nendOfDay := startOfDay.add(24*times.hour - times.second)<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of for-in statement in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nfor v in [1, 2, 3] { // array: element\n}\nfor i, v in [1, 2, 3] { // array: index and element\n}\nfor k, v in {k1: 1, k2: 2} { // map: key and value\n}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow variable declaration and basic operations in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nname := \"Alice\"\nage := 25\nscore := 95.5\nactive := true\n\nfullName := name + \" Johnson\"\nnextAge := age + 1\nisAdult := age >= 18\n\nprintln(\"Name:\", fullName)\nprintln(\"Age:\", nextAge)\nprintln(\"Adult:\", isAdult)<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of processstate in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\ncmd := exec.command(\"echo\", [\"foo\", \"bar\"])\noutput := cmd.output()<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of user object types in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nfunc (o *StringArray) CanIterate() bool {\nreturn true\n}\nfunc (o *StringArray) Iterate() tengo.Iterator {\nreturn &StringArrayIterator{\nstrArr: o,\n}\n}\ntype StringArrayIterator struct {\ntengo.ObjectImpl\nstrArr *StringArray\nidx int\n}\nfunc (i *StringArrayIterator) TypeName() string {\nreturn \"string-array-iterator\"\n}\nfunc (i *StringArrayIterator) Next() bool {\ni.idx++\nreturn i.idx <= len(i.strArr.Value)\n}\nfunc (i *StringArrayIterator) Key() tengo.Object {\nreturn &tengo.Int{Value: int64(i.idx - 1)}\n}\nfunc (i *StringArrayIterator) Value() tengo.Object {\nreturn &tengo.String{Value: i.strArr.Value[i.idx-1]}\n}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow how to use modules modules in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nmath := import(\"math\")\na := math.abs(-19.84) // == 19.84<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nCreate a Tengo action that checks room capacity and attendee requirements<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nattendeeCount := booking.Metadata[\"attendee_count\"] || 1\nroomCapacity := bookable.Metadata[\"capacity\"] || 0\nrequiredAmenities := booking.Metadata[\"required_amenities\"] || []\navailableAmenities := bookable.Metadata[\"amenities\"] || []\n\nif roomCapacity > 0 && attendeeCount > roomCapacity {\n alternativeRooms := getAvailableRooms({\n min_capacity: attendeeCount,\n start: booking.StartsAt,\n end: booking.EndsAt,\n location_id: bookable.LocationID\n })\n \n return {\n status: \"capacity_exceeded\",\n message: sprintf(\"Room capacity is %d, but %d attendees requested\", roomCapacity, attendeeCount),\n room_capacity: roomCapacity,\n requested_attendees: attendeeCount,\n alternatives: alternativeRooms\n }\n}\n\nmissingAmenities := []\nfor amenity in requiredAmenities {\n found := false\n for available in availableAmenities {\n if available == amenity {\n found = true\n break\n }\n }\n if !found {\n missingAmenities = append(missingAmenities, amenity)\n }\n}\n\nif len(missingAmenities) > 0 {\n roomsWithAmenities := getAvailableRooms({\n start: booking.StartsAt,\n end: booking.EndsAt,\n amenities: requiredAmenities,\n min_capacity: attendeeCount\n })\n \n return {\n status: \"amenities_missing\",\n message: \"Room does not have required amenities\",\n missing_amenities: missingAmenities,\n available_amenities: availableAmenities,\n alternatives: roomsWithAmenities\n }\n}\n\ncapacityUtilization := float(attendeeCount) / float(roomCapacity) * 100\n\nreturn {\n status: \"approved\",\n capacity_check: \"passed\",\n amenities_check: \"passed\",\n utilization_percentage: capacityUtilization\n}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of splice in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nv := [\"a\", \"b\", \"c\"]\nitems := splice(v, 1, 1, \"d\", \"e\") // items == [\"b\"], v == [\"a\", \"d\", \"e\", \"c\"]<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of immutable values in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\ns := \"abc\"\ns = \"foo\" // ok\na := immutable([1, 2, 3])\na = false // ok<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow how to use the tengo language modules in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n/* The Tengo Language */\nfmt := import(\"fmt\")\neach := func(seq, fn) {\nfor x in seq { fn(x) }\n}\nsum := func(init, seq) {\neach(seq, func(x) { init += x })\nreturn init\n}\nfmt.println(sum(0, [1, 2, 3])) // \"6\"\nfmt.println(sum(\"\", [1, 2, 3])) // \"123\"<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nWrite a Tengo function that demonstrates function values<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nmy_func := func(arg1, arg2) {\nreturn arg1 + arg2\n}\nadder := func(base) {\nreturn func(x) { return base + x } // capturing 'base'\n}\nadd5 := adder(5)\nnine := add5(4) // == 9<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow how to work with map values in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nm := { a: 1, b: false, c: \"foo\" }\nm[\"b\"] // == false\nm.c // == \"foo\"\nm.x // == undefined\n{a: [1,2,3], b: {c: \"foo\", d: \"bar\"}} // ok: map with an array element and a map element<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of splice in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nv := [\"a\", \"b\", \"c\"]\nitems := splice(v, 1, 2) // items == [\"b\", \"c\"], v == [\"a\"]<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of comments in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n/*\nmulti-line block comments\n*/\na := 5 // line comments<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of splice in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nv := [\"a\", \"b\", \"c\"]\nitems := splice(v, 3, 0, \"d\", \"e\") // items == [], v == [\"a\", \"b\", \"c\", \"d\", \"e\"]<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of quick start in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nres, err := tengo.Eval(ctx,\n`input ? \"success\" : \"fail\"`,\nmap[string]interface{}{\"input\": 1})\nif err != nil {\npanic(err)\n}\nfmt.Println(res) // \"success\"<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nWrite a Tengo function that demonstrates function values<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nf := func(a, b) {}\nf(1, 2, 3) // Runtime Error: wrong number of arguments: want=2, got=3<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nWrite a Tengo action that validates business hours for booking requests<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nimport(\"times\")\n\nstartTime := booking.StartsAt\nendTime := booking.EndsAt\n\nisValidBusinessDay := func(t) {\n weekday := t.weekday()\n return weekday >= 1 && weekday <= 5\n}\n\nisValidBusinessHour := func(t) {\n hour := t.hour()\n return hour >= 9 && hour < 18\n}\n\nif !isValidBusinessDay(startTime) || !isValidBusinessDay(endTime) {\n return {\n status: \"invalid_time\",\n message: \"Bookings are only allowed on weekdays (Monday-Friday)\",\n valid_days: [\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\"]\n }\n}\n\nif !isValidBusinessHour(startTime) || !isValidBusinessHour(endTime) {\n return {\n status: \"invalid_time\", \n message: \"Bookings are only allowed during business hours (9 AM - 6 PM)\",\n business_hours: \"9:00 AM - 6:00 PM\"\n }\n}\n\nduration := endTime.sub(startTime)\nif duration.minutes() < 15 {\n return {\n status: \"invalid_duration\",\n message: \"Minimum booking duration is 15 minutes\",\n minimum_duration: 15\n }\n}\n\nif duration.hours() > 8 {\n return {\n status: \"invalid_duration\",\n message: \"Maximum booking duration is 8 hours\",\n maximum_duration: 8\n }\n}\n\nreturn {\n status: \"approved\",\n duration: duration.minutes(),\n business_hours_valid: true\n}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nCreate a Tengo action that prevents double-booking by checking existing reservations<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nuserID := booking.CreatedBy\nrequestedStart := booking.StartsAt\nrequestedEnd := booking.EndsAt\nbookableID := booking.BookableID\n\nexistingBookings := getBookings({\n created_by: userID,\n bookable_id: bookableID,\n starts_before: requestedEnd,\n ends_after: requestedStart,\n exclude_id: booking.ID,\n cancelled_at: nil\n})\n\nconflicts := []\nfor b in existingBookings {\n if b.StartsAt < requestedEnd && b.EndsAt > requestedStart {\n conflicts = append(conflicts, {\n booking_id: b.ID,\n start: b.StartsAt,\n end: b.EndsAt,\n overlap_type: \"time_conflict\"\n })\n }\n}\n\nif len(conflicts) > 0 {\n return {\n status: \"conflict\",\n message: \"You already have a booking that conflicts with this time\",\n conflicts: conflicts,\n suggestion: \"Please choose a different time slot\"\n }\n}\n\nreturn {status: \"approved\"}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of splice in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nv := [1, 2, 3]\nitems := splice(v, 0, 1) // items == [1], v == [2, 3]<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of delete in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nv := {key: \"value\"}\ndelete(v, \"missing\") // v == {\"key\": \"value\"}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of undefined values in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\na := func() { b := 4 }() // a == undefined\nb := [1, 2, 3][10] // b == undefined\nc := {a: \"foo\"}[\"b\"] // c == undefined\nd := int(\"foo\") // d == undefined<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of ternary operators in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\na := true ? 1 : -1 // a == 1\nmin := func(a, b) {\nreturn a < b ? a : b\n}\nb := min(5, 10) // b == 5<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of processstate in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nproc := start_process(\"app\", [\"arg1\", \"arg2\"], \"dir\", [])\nstat := proc.wait()\npid := stat.pid()<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of splice in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nv := [1, 2, 3]\nitems := splice(v, 1) // items == [2, 3], v == [1]<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nDemonstrate arrays and maps with iteration in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nnumbers := [10, 20, 30, 40, 50]\ntotal := 0\n\nfor i, num in numbers {\n total += num\n printf(\"Index %d: %d\\n\", i, num)\n}\n\nperson := {\n name: \"Bob\",\n age: 30,\n city: \"New York\",\n skills: [\"go\", \"tengo\", \"javascript\"]\n}\n\nfor key, value in person {\n printf(\"%s: %v\\n\", key, value)\n}\n\nfiltered := []\nfor item in numbers {\n if item > 25 {\n filtered = append(filtered, item)\n }\n}\n\nprintln(\"Filtered:\", filtered)<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of variables and scopes in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\na := \"foo\" // define 'a' in global scope\nfunc() { // function scope A\nb := 52 // define 'b' in function scope A\nfunc() { // function scope B\nc := 19.84 // define 'c' in function scope B\na = \"bee\" // ok: assign new value to 'a' from global scope\nb = 20 // ok: assign new value to 'b' from function scope A\nb := true // ok: define new 'b' in function scope B\n}\na = \"bar\" // ok: assigne new value to 'a' from global scope\nb = 10 // ok: assigne new value to 'b'\na := -100 // ok: define new 'a' in function scope A\nc = -9.1 // illegal: 'c' is not defined\nb := [1, 2] // illegal: 'b' is already defined in the same scope\n}\nb = 25 // illegal: 'b' is not defined\na := {d: 2} // illegal: 'a' is already defined in the same scope<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of selector and indexer in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n[\"one\", \"two\", \"three\"][1] // == \"two\"\nm := {\na: 1,\nb: [2, 3, 4],\nc: func() { return 10 }\n}\nm.a // == 1\nm[\"b\"][1] // == 3\nm.c() // == 10\nm.x = 5 // add 'x' to map 'm'\nm[\"b\"][5] // == undefined\nm[\"b\"][5].d // == undefined\nm.b[5] = 0 // == undefined\nm.x.y.z // == undefined<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of user object types in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nfunc (o *StringArray) CanCall() bool {\nreturn true\n}\nfunc (o *StringArray) Call(args ...tengo.Object) (ret tengo.Object, err error) {\nif len(args) != 1 {\nreturn nil, tengo.ErrWrongNumArguments\n}\ns1, ok := tengo.ToString(args[0])\nif !ok {\nreturn nil, tengo.ErrInvalidArgumentType{\nName: \"first\",\nExpected: \"string\",\nFound: args[0].TypeName(),\n}\n}\nfor i, v := range o.Value {\nif v == s1 {\nreturn &tengo.Int{Value: int64(i)}, nil\n}\n}\nreturn tengo.UndefinedValue, nil\n}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nCreate a Tengo action that a specific group of users cannot book within 15 minutes of another group\n\nScenario: User from Group Engineering wants to book Meeting Room at 2:00pm, but user from Group Sales has booking ending at 1:50pm<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nbufferMinutes := 15\nuserGroupID := user.GroupID\nrequestedStart := booking.StartsAt\nrequestedEnd := booking.EndsAt\n\nbufferStart := requestedStart.add(-bufferMinutes, \"minutes\")\nbufferEnd := requestedEnd.add(bufferMinutes, \"minutes\")\n\nnearbyBookings := getBookings({\n bookable_id: booking.BookableID,\n starts_before: bufferEnd,\n ends_after: bufferStart,\n exclude_id: booking.ID\n})\n\nfor b in nearbyBookings {\n if b.User.GroupID != userGroupID {\n timeDiff := requestedStart.sub(b.EndsAt).minutes()\n if timeDiff < bufferMinutes && timeDiff >= 0 {\n return {\n status: \"proximity_conflict\",\n message: sprintf(\"Cannot book within %d minutes of %s group\", bufferMinutes, b.User.Group.Name),\n conflicting_booking: b.ID,\n time_difference: timeDiff,\n required_buffer: bufferMinutes\n }\n }\n }\n}\n\nreturn {status: \"approved\"}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of integer in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n%b base 2\n%c the character represented by the corresponding Unicode code point\n%d base 10\n%o base 8\n%O base 8 with 0o prefix\n%q a single-quoted character literal safely escaped with Go syntax.\n%x base 16, with lower-case letters for a-f\n%X base 16, with upper-case letters for A-F\n%U Unicode format: U+1234; same as \"U+%04X\"<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nCreate a Tengo action that when temperature is below -5 degrees, bookable is not available\n\nScenario: User wants to book Outdoor Pavilion on January 15th when temperature is forecasted to be -8°C<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nif !bookable.Metadata[\"is_outdoor\"] {\n return {status: \"not_applicable\"}\n}\n\nweatherData := http.get(\"/samna-connect/weather/temperature\", {\n location_id: bookable.LocationID,\n date: booking.StartsAt.format(\"2006-01-02\")\n})\n\nif weatherData.error {\n return {\n status: \"weather_check_failed\",\n error: weatherData.error\n }\n}\n\ntemperature := weatherData.temperature\nminTemp := bookable.Metadata[\"min_temperature\"] || -5\n\nif temperature < minTemp {\n return {\n status: \"unavailable\",\n message: sprintf(\"Temperature %d°C is below minimum %d°C\", temperature, minTemp),\n current_temperature: temperature,\n minimum_required: minTemp\n }\n}\n\nreturn {\n status: \"approved\",\n temperature_check: \"passed\",\n current_temperature: temperature\n}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of variables and scopes in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\na := 123 // assigned 'int'\na = \"123\" // re-assigned 'string'\na = [1, 2, 3] // re-assigned 'array'<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of user object types in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\ntype StringArray struct {\ntengo.ObjectImpl\nValue []string\n}\nfunc (o *StringArray) String() string {\nreturn strings.Join(o.Value, \", \")\n}\nfunc (o *StringArray) BinaryOp(op token.Token, rhs tengo.Object) (tengo.Object, error) {\nif rhs, ok := rhs.(*StringArray); ok {\nswitch op {\ncase token.Add:\nif len(rhs.Value) == 0 {\nreturn o, nil\n}\nreturn &StringArray{Value: append(o.Value, rhs.Value...)}, nil\n}\n}\nreturn nil, tengo.ErrInvalidOperator\n}\nfunc (o *StringArray) IsFalsy() bool {\nreturn len(o.Value) == 0\n}\nfunc (o *StringArray) Equals(x tengo.Object) bool {\nif x, ok := x.(*StringArray); ok {\nif len(o.Value) != len(x.Value) {\nreturn false\n}\nfor i, v := range o.Value {\nif v != x.Value[i] {\nreturn false\n}\n}\nreturn true\n}\nreturn false\n}\nfunc (o *StringArray) Copy() tengo.Object {\nreturn &StringArray{\nValue: append([]string{}, o.Value...),\n}\n}\nfunc (o *StringArray) TypeName() string {\nreturn \"string-array\"\n}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nDemonstrate HTTP requests and JSON handling in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nimport(\"http\")\nimport(\"json\")\n\nmakeRequest := func(url, method, data) {\n headers := {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"application/json\"\n }\n \n options := {headers: headers}\n \n if method == \"POST\" && data {\n options.body = json.encode(data)\n }\n \n response := http.request(method, url, options)\n \n if response.status_code >= 400 {\n return {\n success: false,\n error: \"HTTP \" + string(response.status_code),\n body: response.body\n }\n }\n \n decoded := json.decode(response.body)\n return {\n success: true,\n data: decoded,\n status: response.status_code\n }\n}\n\nresult := makeRequest(\"https://api.example.com/users\", \"GET\", nil)\nif result.success {\n println(\"Got data:\", result.data)\n} else {\n println(\"Error:\", result.error)\n}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of splice in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nv := [1, 2, 3]\nitems := splice(v, 0) // items == [1, 2, 3], v == []<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nWrite a Tengo function that demonstrates function values<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nvariadic := func (a, b, ...c) {\nreturn [a, b, c]\n}\nvariadic(1, 2, 3, 4) // [1, 2, [3, 4]]\nvariadicClosure := func(a) {\nreturn func(b, ...c) {\nreturn [a, b, c]\n}\n}\nvariadicClosure(1)(2, 3, 4) // [1, 2, [3, 4]]<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of format in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\na := [1, 2, 3]\ns := format(\"Foo: %v\", a) // s == \"Foo: [1, 2, 3]\"<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow how to use examples modules in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\njson := import(\"json\")\nencoded := json.encode({a: 1, b: [2, 3, 4]}) // JSON-encoded bytes string\nindentded := json.indent(encoded, \"\", \" \") // indented form\nhtml_safe := json.html_escape(encoded) // HTML escaped form\ndecoded := json.decode(encoded) // {a: 1, b: [2, 3, 4]}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of compiled.clone() in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nfor i := 0; i < concurrency; i++ {\ngo func(compiled *tengo.Compiled) {\n_ = compiled.Set(\"a\", rand.Intn(10))\n_ = compiled.Set(\"b\", rand.Intn(10))\n_ = compiled.Set(\"c\", rand.Intn(10))\nif err := compiled.Run(); err != nil {\npanic(err)\n}\nd = compiled.Get(\"d\").Int()\ne = compiled.Get(\"e\").Int()\n}(compiled.Clone()) // Pass the cloned copy of Compiled\n}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of float in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n%b decimalless scientific notation with exponent a power of two,\nin the manner of Go's strconv.FormatFloat with the 'b' format,\ne.g. -123456p-78\n%e scientific notation, e.g. -1.234456e+78\n%E scientific notation, e.g. -1.234456E+78\n%f decimal point but no exponent, e.g. 123.456\n%F synonym for %f\n%g %e for large exponents, %f otherwise. Precision is discussed below.\n%G %E for large exponents, %F otherwise\n%x hexadecimal notation (with decimal power of two exponent), e.g. -0x1.23abcp+20\n%X upper-case hexadecimal notation, e.g. -0X1.23ABCP+20<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of error values in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nerr1 := error(\"oops\") // error with string value\nerr2 := error(1+2+3) // error with int value\nif is_error(err1) { // 'is_error' builtin function\nerr_val := err1.value // get underlying value\n}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nCreate a Tengo action that two organizations cannot book on the same weekday\n\nScenario: Organization A wants to book Conference Room 1 on Tuesday at 2pm, but Organization B already has a booking on Tuesday at 10am<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\norgID := booking.Organization.ID\nweekday := booking.StartsAt.Weekday()\nbookableID := booking.BookableID\n\nconflictingBookings := getBookings({\n bookable_id: bookableID,\n weekday: weekday,\n organization_id: {\"ne\": orgID},\n cancelled_at: nil\n})\n\nif len(conflictingBookings) > 0 {\n alternatives := []\n for day := 1; day <= 7; day++ {\n if day != weekday {\n dayName := getDayName(day)\n alternatives = append(alternatives, dayName)\n }\n }\n \n return {\n status: \"conflict\",\n message: \"Another organization has a booking on this weekday\",\n conflicting_bookings: conflictingBookings,\n suggested_alternatives: alternatives\n }\n}\n\nreturn {status: \"approved\"}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow how to use modules modules in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nsum := import(\"./sum\") // load module from a local file\nfmt.print(sum(10)) // module function<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of values and value types in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n19 + 84 // int values\n\"aomame\" + `kawa` // string values\n-9.22 + 1e10 // float values\ntrue || false // bool values\n'九' > '9' // char values\n[1, false, \"foo\"] // array value\n{a: 12.34, b: \"bar\"} // map value\nfunc() { /*...*/ } // function value<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nWrite a Tengo action that handles recurring booking conflicts<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nimport(\"times\")\n\nisRecurring := booking.RRule != nil && booking.RRule != \"\"\nif !isRecurring {\n return {status: \"not_recurring\"}\n}\n\nparseRRule := func(rrule) {\n if contains(rrule, \"WEEKLY\") {\n return {\n frequency: \"weekly\",\n interval: 1,\n count: 52\n }\n }\n if contains(rrule, \"DAILY\") {\n return {\n frequency: \"daily\", \n interval: 1,\n count: 365\n }\n }\n return {frequency: \"unknown\"}\n}\n\nrecurringRule := parseRRule(booking.RRule)\nconflicts := []\n\nif recurringRule.frequency == \"weekly\" {\n endDate := booking.StartsAt.add(365 * 24 * times.hour)\n current := booking.StartsAt\n \n checkCount := 0\n for current.before(endDate) && checkCount < 20 {\n conflictingBookings := getBookings({\n bookable_id: booking.BookableID,\n starts_at: current,\n ends_at: current.add(booking.EndsAt.sub(booking.StartsAt)),\n exclude_id: booking.ID,\n cancelled_at: nil\n })\n \n if len(conflictingBookings) > 0 {\n conflicts = append(conflicts, {\n date: current,\n conflicting_bookings: conflictingBookings\n })\n }\n \n current = current.add(7 * 24 * times.hour)\n checkCount++\n }\n}\n\nif len(conflicts) > 0 {\n return {\n status: \"recurring_conflicts\",\n message: sprintf(\"Found %d conflicts in recurring series\", len(conflicts)),\n conflicts: conflicts,\n suggestion: \"Consider adjusting the time or frequency\"\n }\n}\n\nreturn {\n status: \"recurring_approved\",\n frequency: recurringRule.frequency,\n occurrences_checked: 20\n}<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of selector and indexer in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\na := [1, 2, 3, 4, 5][1:3] // == [2, 3]\nb := [1, 2, 3, 4, 5][3:] // == [4, 5]\nc := [1, 2, 3, 4, 5][:3] // == [1, 2, 3]\nd := \"hello world\"[2:10] // == \"llo worl\"\nc := [1, 2, 3, 4, 5][-1:10] // == [1, 2, 3, 4, 5]<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of immutable values in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\na := immutable({b: 4, c: [1, 2, 3]})\na.b = 5 // illegal\na.c[1] = 5 // ok: because 'a.c' is not immutable\na = immutable({b: 4, c: immutable([1, 2, 3])})\na.c[1] = 5 // illegal<|eot_id|>"}
{"text": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an expert Tengo programmer who specializes in creating booking system actions. Generate clean, efficient Tengo code that follows best practices. Focus on:\n\n- Proper Tengo syntax and idioms\n- Robust error handling and validation\n- HTTP API integration patterns \n- Business logic for booking conflicts and rules\n- Time and date handling\n- Clear, maintainable code structure\n\nAlways write production-ready code without comments.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nShow an example of immutable values in Tengo<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nb := immutable([1, 2, 3])\nb[1] = \"foo\" // illegal: 'b' references to an immutable array.<|eot_id|>"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment