Skip to content

Commit 2195740

Browse files
authored
Support llava-hf/llava-1.5-7b-hf with .upper() string method (google#76)
* Support .upper() and .lower() string methods * Add syntax tests for upper and lower methods * Add llava-hf/llava-1.5-7b-hf to supported models
1 parent 9f2dc50 commit 2195740

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

include/minja/minja.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,16 @@ class MethodCallExpr : public Expression {
15411541
} else if (method->get_name() == "capitalize") {
15421542
vargs.expectArgs("capitalize method", {0, 0}, {0, 0});
15431543
return Value(capitalize(str));
1544+
} else if (method->get_name() == "upper") {
1545+
vargs.expectArgs("upper method", {0, 0}, {0, 0});
1546+
auto result = str;
1547+
std::transform(result.begin(), result.end(), result.begin(), ::toupper);
1548+
return Value(result);
1549+
} else if (method->get_name() == "lower") {
1550+
vargs.expectArgs("lower method", {0, 0}, {0, 0});
1551+
auto result = str;
1552+
std::transform(result.begin(), result.end(), result.begin(), ::tolower);
1553+
return Value(result);
15441554
} else if (method->get_name() == "endswith") {
15451555
vargs.expectArgs("endswith method", {1, 1}, {0, 0});
15461556
auto suffix = vargs.args[0].get<std::string>();

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ set(MODEL_IDS
168168
knifeayumu/Cydonia-v1.3-Magnum-v4-22B
169169
langgptai/qwen1.5-7b-chat-sa-v0.1
170170
LatitudeGames/Wayfarer-12B
171+
llava-hf/llava-1.5-7b-hf
171172
LGAI-EXAONE/EXAONE-3.5-2.4B-Instruct
172173
LGAI-EXAONE/EXAONE-3.5-7.8B-Instruct
173174
lightblue/DeepSeek-R1-Distill-Qwen-7B-Japanese

tests/test-syntax.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ TEST(SyntaxTest, SimpleCases) {
9191
EXPECT_EQ("abcXYZabcXYZabc",
9292
render("{{ 'abcXYZabcXYZabc'.replace('def', 'ok') }}", {}, {}));
9393

94+
EXPECT_EQ("HELLO WORLD", render("{{ 'hello world'.upper() }}", {}, {}));
95+
EXPECT_EQ("MIXED", render("{{ 'MiXeD'.upper() }}", {}, {}));
96+
EXPECT_EQ("", render("{{ ''.upper() }}", {}, {}));
97+
98+
EXPECT_EQ("hello world", render("{{ 'HELLO WORLD'.lower() }}", {}, {}));
99+
EXPECT_EQ("mixed", render("{{ 'MiXeD'.lower() }}", {}, {}));
100+
EXPECT_EQ("", render("{{ ''.lower() }}", {}, {}));
101+
94102
EXPECT_EQ(
95103
"ok",
96104
render("{# Hey\nHo #}{#- Multiline...\nComments! -#}{{ 'ok' }}{# yo #}", {}, {}));

0 commit comments

Comments
 (0)