Skip to content

Commit

Permalink
feat: Store extraction run id
Browse files Browse the repository at this point in the history
  • Loading branch information
bo-dun-1 committed Dec 6, 2024
1 parent e8561df commit f77ef1c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
27 changes: 18 additions & 9 deletions src/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -932,13 +932,14 @@ function Form({
}

try {
const data = await client.extractAIDocument(
const data = await client.extractAIDocument({
extractionId,
runAsync,
pages
);
updateFieldValues(data);
return data;
});
const vals = data.data ?? {};
updateFieldValues(vals);
return vals;
} catch (err) {
console.error(err);
return {};
Expand Down Expand Up @@ -1887,11 +1888,19 @@ function Form({
} else if (type === ACTION_AI_DOCUMENT_EXTRACT) {
try {
await submitPromise;
const data = await client.extractAIDocument(
action.extraction_id,
action.run_async
);
updateFieldValues(data);
const data = await client.extractAIDocument({
extractionId: action.extraction_id,
runAsync: action.run_async
});
const vals = data.data ?? {};
const runField = action.extraction_run_field_key;
if (runField && data.runs?.length) {
let runs = data.runs;
if (runs.length === 1) runs = runs[0];
vals[runField] = runs;
await client.submitCustom({ runField: runs });
}
updateFieldValues(vals);
} catch (e: any) {
setElementError((e as Error).message);
break;
Expand Down
12 changes: 10 additions & 2 deletions src/utils/featheryClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,15 @@ export default class FeatheryClient extends IntegrationClient {
}

// AI
extractAIDocument(extractionId: string, runAsync: boolean, pages?: number[]) {
extractAIDocument({
extractionId,
runAsync,
pages
}: {
extractionId: string;
runAsync: boolean;
pages?: number[];
}) {
const { userId } = initInfo();
const data = {
fuser_key: userId,
Expand Down Expand Up @@ -794,7 +802,7 @@ export default class FeatheryClient extends IntegrationClient {
const data = await response.json();

if (data.status === 'complete') {
return resolve(data.data);
return resolve(data);
} else {
attempts += 1;

Expand Down

0 comments on commit f77ef1c

Please sign in to comment.