Skip to content

Commit 596ff7f

Browse files
author
ochafik
committed
fix flake8 lints
1 parent 62a1416 commit 596ff7f

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

common/chat.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ static common_chat_params common_chat_params_init_hermes_2_pro(const common_chat
13701370
}));
13711371
tool_call_alts.push_back(builder.add_rule(
13721372
name + "-function-tag",
1373-
"\"<function\" ( \"=" + name + "\" | \" name=\\\"" + name + "\\\"\" ) \">\" space " +
1373+
"\"<function\" ( \"=" + name + "\" | \" name=\\\"" + name + "\\\"\" ) \">\" space " +
13741374
builder.add_schema(name + "-args", parameters) + " "
13751375
"\"</function>\" space"));
13761376

@@ -1455,7 +1455,7 @@ static common_chat_msg common_chat_parse_hermes_2_pro(const std::string& input)
14551455
);
14561456

14571457
try {
1458-
1458+
14591459
common_chat_msg msg;
14601460
msg.role = "assistant";
14611461

@@ -1467,7 +1467,7 @@ static common_chat_msg common_chat_parse_hermes_2_pro(const std::string& input)
14671467
if (std::regex_search(it, end, match, open_regex)) {
14681468
// Add content before the match
14691469
msg.content += std::string(it, match[0].first);
1470-
1470+
14711471
auto block_start = match[1].str();
14721472
std::string block_end = block_start.empty() ? "" : "```";
14731473

@@ -1479,10 +1479,10 @@ static common_chat_msg common_chat_parse_hermes_2_pro(const std::string& input)
14791479
auto json_it = match[3].first;
14801480
auto tool_call = parse_json(json_it, end);
14811481
if (tool_call && tool_call->contains("name") && tool_call->contains("arguments")) {
1482-
1482+
14831483
msg.tool_calls.emplace_back(process_tool_call(*tool_call));
14841484
it = json_it; // Move iterator past parsed JSON
1485-
1485+
14861486
// Handle close tags
14871487
consume_spaces(it, end);
14881488
if (!close_tag.empty() && !parse_literal(it, end, close_tag)) {
@@ -1514,7 +1514,7 @@ static common_chat_msg common_chat_parse_hermes_2_pro(const std::string& input)
15141514
{"arguments", *arguments},
15151515
}));
15161516
it = json_it; // Move iterator past parsed JSON
1517-
1517+
15181518
// Handle close tags
15191519
consume_spaces(it, end);
15201520
if (!close_tag.empty() && !parse_literal(it, end, close_tag)) {

scripts/tool_bench.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@
3131
# ///
3232
from contextlib import contextmanager
3333
from pathlib import Path
34-
from pathlib import Path
3534
import re
3635
from statistics import mean, median
37-
from typing import Annotated, List, Optional
38-
from typing import Dict, List, Tuple, Set, Any
36+
from typing import Annotated, Dict, List, Optional, Tuple
3937
import atexit
4038
import json
4139
import logging
@@ -49,9 +47,9 @@
4947
import typer
5048

5149
sys.path.insert(0, Path(__file__).parent.parent.as_posix())
52-
print(sys.path)
53-
from examples.server.tests.utils import ServerProcess
54-
from examples.server.tests.unit.test_tool_call import TIMEOUT_SERVER_START, do_test_calc_result, do_test_hello_world, do_test_weather
50+
if True:
51+
from examples.server.tests.utils import ServerProcess # type: ignore
52+
from examples.server.tests.unit.test_tool_call import TIMEOUT_SERVER_START, do_test_calc_result, do_test_hello_world, do_test_weather # type: ignore
5553

5654

5755
@contextmanager
@@ -74,6 +72,7 @@ def stop():
7472

7573
app = typer.Typer()
7674

75+
7776
@app.command()
7877
def plot(files: List[Path], output: Optional[Path] = None, test_regex: Optional[str] = None, server_regex: Optional[str] = None):
7978

@@ -146,15 +145,13 @@ def plot(files: List[Path], output: Optional[Path] = None, test_regex: Optional[
146145
tests = list(sorted(tests))
147146
server_names = list(sorted(server_names))
148147

149-
150148
logger.info(f"Processed {len(lines)} lines")
151149
logger.info(f"Found {len(data_dict)} valid data points")
152150
logger.info(f"Models: {models}")
153151
logger.info(f"Temperatures: {temps}")
154152
logger.info(f"Tests: {tests}")
155153
logger.info(f"Servers: {server_names}")
156154

157-
158155
matrix = []
159156
index = []
160157

@@ -198,6 +195,7 @@ def plot(files: List[Path], output: Optional[Path] = None, test_regex: Optional[
198195
else:
199196
plt.show()
200197

198+
201199
@app.command()
202200
def run(
203201
output: Annotated[Path, typer.Option(help="Output JSON file")],
@@ -259,8 +257,10 @@ def run(server: ServerProcess, *, server_name: str, model_id: str, temp: float |
259257
print(f"Running {test_name} ({server_name}, {model}): ", file=sys.stderr, flush=True)
260258
for i in range(n):
261259
start_time = time.time()
260+
262261
def elapsed():
263262
return time.time() - start_time
263+
264264
try:
265265
test(server)
266266
success_times.append(elapsed())
@@ -273,6 +273,8 @@ def elapsed():
273273
failure_count += 1
274274
failure_times.append(elapsed())
275275
failures.append(str(e))
276+
# import traceback
277+
# traceback.print_exc()
276278
print('\n', file=sys.stderr, flush=True)
277279
output_file.write(json.dumps({**output_kwargs, **dict(
278280
model=model,
@@ -352,5 +354,6 @@ def elapsed():
352354
),
353355
)
354356

357+
355358
if __name__ == "__main__":
356-
app()
359+
app()

0 commit comments

Comments
 (0)