Skip to content

Commit

Permalink
fix(prompt): resolve params format error (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoushaw authored Jan 31, 2025
1 parent 6c90884 commit 16914bb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
27 changes: 25 additions & 2 deletions packages/midscene/src/ai-model/prompt/llm-planning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,33 @@ export const planSchema: ResponseFormatJSONSchema = {
description: 'Type of action, like "Tap", "Hover", etc.',
},
param: {
type: ['object', 'null'],
anyOf: [
{ type: 'null' },
{
type: 'object',
properties: { value: { type: ['string', 'number'] } },
required: ['value'],
additionalProperties: false,
},
{
type: 'object',
properties: { timeMs: { type: ['number', 'string'] } },
required: ['timeMs'],
additionalProperties: false,
},
{
type: 'object',
properties: {
direction: { type: 'string' },
scrollType: { type: 'string' },
distance: { type: ['number', 'string', 'null'] },
},
required: ['direction', 'scrollType', 'distance'],
additionalProperties: false,
},
],
description:
'Parameter of the action, can be null ONLY when the type field is Tap or Hover',
additionalProperties: true,
},
locate: {
type: ['object', 'null'],
Expand Down
2 changes: 0 additions & 2 deletions packages/midscene/tests/ai/evaluate/plan/planning.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ describe('automation - planning', () => {
context,
},
);

expect(actions.length).toBe(3);
expect(actions[0].type).toBe('Input');
expect(actions[1].type).toBe('Sleep');
Expand Down Expand Up @@ -53,7 +52,6 @@ describe('automation - planning', () => {
context,
},
);

expect(actions).toBeTruthy();
expect(actions[0].type).toBe('Scroll');
expect(actions[0].locate).toBeTruthy();
Expand Down

0 comments on commit 16914bb

Please sign in to comment.