Skip to content

Commit

Permalink
Merge pull request activepieces#6339 from alegria-solutions/twin-labs…
Browse files Browse the repository at this point in the history
…-changes

feat(twin-lab): improved user experience
  • Loading branch information
abuaboud authored Dec 16, 2024
2 parents db8e1b5 + 93573d9 commit 8b11509
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/pieces/community/twin-labs/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-twin-labs",
"version": "0.0.1"
"version": "0.0.2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,29 @@ import { twinLabsAuth } from '../..';
export const startBrowsingTask = createAction({
name: 'startBrowsingTask',
auth: twinLabsAuth,
displayName: 'Start Browsing Task',
displayName: 'Browse',
description:
'Browse the internet with an AI web navigation agent that can find information for you',
props: {
goal: Property.ShortText({
displayName: 'Goal',
required: true,
description: 'The goal or objective of the browsing task',
}),


startUrl: Property.ShortText({
displayName: 'startUrl',
required: true,
description: 'The URL where the browsing task should begin',
defaultValue: 'https://',
defaultValue: '',
}),

goal: Property.ShortText({
displayName: 'Goal',
required: true,
description: 'The goal or objective of the browsing task',
}),
},

async run(context) {
interface ApiResponse {
output: any;
status: string;
taskId: string;
[key: string]: any;
Expand All @@ -49,7 +52,8 @@ export const startBrowsingTask = createAction({
const taskId = res.body.taskId;
let taskStatus = res.body.status;

const maxTime = Date.now() + 5 * 60 * 1000; // 5 minutes timeout
const maxTime = Date.now() + 15 * 60 * 1000; // 15 minutes timeout


// Initialize statusResponse to store the last response
let statusResponse: ApiResponse = res.body;
Expand All @@ -71,10 +75,6 @@ export const startBrowsingTask = createAction({
taskStatus = statusResponse.status;
}

// Add a timeout message if the task did not complete within 5 minutes
if (taskStatus !== 'COMPLETED') {
statusResponse.status = 'TIMEOUT';
}

// Return the final statusResponse in all cases
return statusResponse;
Expand Down

0 comments on commit 8b11509

Please sign in to comment.