MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / _calc_segments

Method _calc_segments

AgentBench.old/src/agent.py:50–75  ·  view source on GitHub ↗
(self, msg: str)

Source from the content-addressed store, hash-verified

48 return result
49
50 def _calc_segments(self, msg: str):
51 segments = 0
52 current_segment = ""
53 inside_word = False
54
55 for char in msg:
56 if char.isalpha():
57 current_segment += char
58 if not inside_word:
59 inside_word = True
60 if len(current_segment) >= 7:
61 segments += 1
62 current_segment = ""
63 inside_word = False
64 else:
65 if inside_word:
66 segments += 1
67 current_segment = ""
68 inside_word = False
69 if char not in [" ", "\n"]:
70 segments += 1
71
72 if len(current_segment) > 0:
73 segments += 1
74
75 return segments
76
77 def wrap_inference(self, inference_function: Callable[[List[dict]], str]) -> Callable[[List[dict]], str]:
78 def _func(history: List[dict]) -> str:

Callers 1

filter_messagesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected