File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 1
1
import re
2
2
3
+ from ..logger import logger
4
+
3
5
4
6
def transform_string_function_style (name : str ) -> str :
5
7
# Replace spaces with underscores
6
8
name = name .replace (" " , "_" )
7
9
8
10
# Replace non-alphanumeric characters with underscores
9
- name = re .sub (r"[^a-zA-Z0-9]" , "_" , name )
11
+ transformed_name = re .sub (r"[^a-zA-Z0-9_]" , "_" , name )
12
+
13
+ if transformed_name != name :
14
+ final_name = transformed_name .lower ()
15
+ logger .warning (
16
+ f"Tool name { name !r} contains invalid characters for function calling and has been "
17
+ f"transformed to { final_name !r} . Please use only letters, digits, and underscores "
18
+ "to avoid potential naming conflicts."
19
+ )
10
20
11
- return name .lower ()
21
+ return transformed_name .lower ()
You can’t perform that action at this time.
0 commit comments