From 7a9a6d21f94aa4ba34e22cf11859f90ce0da8208 Mon Sep 17 00:00:00 2001 From: ochafik Date: Sat, 8 Feb 2025 19:07:23 +0000 Subject: [PATCH 1/2] add string.capitalize --- include/minja/minja.hpp | 10 ++++++++++ tests/test-syntax.cpp | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/include/minja/minja.hpp b/include/minja/minja.hpp index c726592..c58dd66 100644 --- a/include/minja/minja.hpp +++ b/include/minja/minja.hpp @@ -1385,6 +1385,13 @@ static std::string strip(const std::string & s) { return s.substr(start, end - start + 1); } +static std::string capitalize(const std::string & s) { + if (s.empty()) return s; + auto result = s; + result[0] = std::toupper(result[0]); + return result; +} + static std::string html_escape(const std::string & s) { std::string result; result.reserve(s.size()); @@ -1462,6 +1469,9 @@ class MethodCallExpr : public Expression { if (method->get_name() == "strip") { vargs.expectArgs("strip method", {0, 0}, {0, 0}); return Value(strip(str)); + } else if (method->get_name() == "capitalize") { + vargs.expectArgs("capitalize method", {0, 0}, {0, 0}); + return Value(capitalize(str)); } else if (method->get_name() == "endswith") { vargs.expectArgs("endswith method", {1, 1}, {0, 0}); auto suffix = vargs.args[0].get(); diff --git a/tests/test-syntax.cpp b/tests/test-syntax.cpp index 85bf222..b4f4673 100644 --- a/tests/test-syntax.cpp +++ b/tests/test-syntax.cpp @@ -74,6 +74,10 @@ TEST(SyntaxTest, SimpleCases) { return testing::Throws(Property(&std::runtime_error::what, testing::HasSubstr(expected_substr))); }; + EXPECT_EQ( + "Ok", + render("{{ 'ok'.capitalize() }}", {}, {})); + EXPECT_EQ( "ok", render("{# Hey\nHo #}{#- Multiline...\nComments! -#}{{ 'ok' }}{# yo #}", {}, {})); From e63242853684fc388cd48cc5c5996edc9f8c4029 Mon Sep 17 00:00:00 2001 From: ochafik Date: Sat, 8 Feb 2025 19:08:02 +0000 Subject: [PATCH 2/2] test BEE-spoke-data/tFINE-900m-instruct-orpo --- tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 89e3dc8..550515d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -78,6 +78,7 @@ set(MODEL_IDS databricks/dbrx-instruct # Gated google/gemma-2-2b-it # Gated google/gemma-7b-it # Gated + BEE-spoke-data/tFINE-900m-instruct-orpo MiniMaxAI/MiniMax-Text-01 indischepartij/MiniCPM-3B-OpenHermes-2.5-v2 mattshumer/Reflection-Llama-3.1-70B