Skip to content

Commit b607567

Browse files
fix(action_parser): null values while parsing action inputs (#28)
* fix: null values while parsing action inputs * chore: add test cases for parsing action with square brackets
1 parent 0e560aa commit b607567

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

packages/action-parser/src/index.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,50 @@ describe('actionParser', () => {
7474
});
7575
});
7676

77+
it('should return parsed action with square brackets', () => {
78+
const result = actionParser({
79+
prediction:
80+
"Action_Summary: 左键单击窗口右上角的最小化按钮(图标为横线),将当前窗口最小化到任务栏。\nAction: click(start_box='[948,57]')",
81+
factor: 1000,
82+
});
83+
84+
expect(result).toEqual({
85+
parsed: [
86+
{
87+
action_inputs: {
88+
start_box: '[0.948,0.057,0.948,0.057]',
89+
},
90+
action_type: 'click',
91+
reflection: '',
92+
thought:
93+
'左键单击窗口右上角的最小化按钮(图标为横线),将当前窗口最小化到任务栏。',
94+
},
95+
],
96+
});
97+
});
98+
99+
it('should return parsed action english with square brackets', () => {
100+
const result = actionParser({
101+
prediction:
102+
'Thought: The task is to open Chrome, but the current screen shows a GitHub repository page in a different browser. To proceed, I need to close this window and open Chrome. The most efficient way to do this is by clicking the "X" button in the top-right corner of the current window to close it, which will allow me to access the desktop and open Chrome from there.\nClick on the "X" button in the top-right corner of the current window to close it.\nAction: click(start_box=\'[962,108]\')',
103+
factor: 1000,
104+
});
105+
106+
expect(result).toEqual({
107+
parsed: [
108+
{
109+
action_inputs: {
110+
start_box: '[0.962,0.108,0.962,0.108]',
111+
},
112+
action_type: 'click',
113+
reflection: '',
114+
thought:
115+
'The task is to open Chrome, but the current screen shows a GitHub repository page in a different browser. To proceed, I need to close this window and open Chrome. The most efficient way to do this is by clicking the "X" button in the top-right corner of the current window to close it, which will allow me to access the desktop and open Chrome from there.\nClick on the "X" button in the top-right corner of the current window to close it.',
116+
},
117+
],
118+
});
119+
});
120+
77121
it('should return Action_Summary', () => {
78122
const result = actionParser({
79123
prediction:

packages/action-parser/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function parseActionVlm(
9898
if (paramName.includes('start_box') || paramName.includes('end_box')) {
9999
const oriBox = trimmedParam;
100100
// Remove parentheses and split
101-
const numbers = oriBox.replace(/[()]/g, '').split(',');
101+
const numbers = oriBox.replace(/[()[\]]/g, '').split(',');
102102

103103
// Convert to float and scale
104104
const floatNumbers = numbers.map(

0 commit comments

Comments
 (0)