-
Notifications
You must be signed in to change notification settings - Fork 166
feat: preview step + functions refactor [INTEG-3348] #10356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: preview step + functions refactor [INTEG-3348] #10356
Conversation
…ling each agent in a separate function, + removing plan agent for now
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension. |
| const cma = initContentfulManagementClient(context); | ||
| const contentTypes = await fetchContentTypes(cma, new Set<string>(contentTypeIds)); | ||
|
|
||
| // Commented out to preserver as much time as possible due to the 30 second limit for App functions | ||
| // const contentTypeParserAgentResult = await analyzeContentTypes({ contentTypes, openAiApiKey }); | ||
|
|
||
| // INTEG-3261: Pass the ai content type response to the observer for analysis | ||
| // createContentTypeObservationsFromLLMResponse() | ||
|
|
||
| const aiDocumentResponse = await analyzeDocumentWithAgent({ | ||
| documentId, | ||
| oauthToken, | ||
| openAiApiKey, | ||
| contentTypes, | ||
| }); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part was split into
analyzeContentTypescreatePreview
| // INTEG-3264: Create the entries in Contentful using the entry service | ||
| // The aiDocumentResponse.entries is now ready to be passed to the CMA client | ||
| const creationResult = await createEntries(cma, aiDocumentResponse.entries, { | ||
| spaceId: context.spaceId, | ||
| environmentId: context.environmentId, | ||
| contentTypes, | ||
| }); | ||
| console.log('Created Entries Result:', creationResult); | ||
|
|
||
| // INTEG-3265: Create the assets in Contentful using the asset service | ||
| // await createAssets() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- this part went to
createEntries
| return ( | ||
| <Modal onClose={handleClose} isShown={isOpen} size="fullWidth"> | ||
| {() => ( | ||
| <> | ||
| <Modal.Header title="Preview Parsed Entries" onClose={handleClose} /> | ||
| <Modal.Content> | ||
| <Flex flexDirection="column" gap="spacingM"> | ||
| <Card> | ||
| <Flex flexDirection="column" gap="spacingS"> | ||
| <Paragraph> | ||
| Based off the document, the following entries are being suggested: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ui work will be in a followup ticket
| const analyzeContentTypesResponse = await analyzeContentTypesAction( | ||
| sdk, | ||
| contentTypeIds, | ||
| oauthToken | ||
| ); | ||
| console.log('analyzeContentTypesResponse', analyzeContentTypesResponse); | ||
|
|
||
| const processDocumentResponse = await createPreviewAction( | ||
| sdk, | ||
| contentTypeIds, | ||
| documentId, | ||
| oauthToken | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate app actions in action 😼
| "description": "Function to create content blocks from App Action.", | ||
| "path": "functions/createEntriesFromDocument.js", | ||
| "entryFile": "functions/createEntriesFromDocument.ts", | ||
| "id": "createPreview", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a huge deal but we should make sure functions are created and deleted as expected when changing the id
mgoudy91
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I skimmed over the UI code based on your comments, but the rest of this looks good
1b7d992
into
google-docs-xmas-fb
* fix: google docs package.json scripts so that it deploys correctly in ci (#10350) * feat: preview step + functions refactor [INTEG-3348] (#10356) * wip * simplify agent * organize oauth functions * reorganizing function handlers * reorganizing function handlers (prev `createEntriesfromDocument`) calling each agent in a separate function, + removing plan agent for now * fix: function manifest * minor edit to manifest * replacing single function with 2: one for analyzing ct + one for document processing * fix: add oauth token to analyze content type function * fix: adding entries to document processor o/p * feat: new app action to create entries, preview modal * cleanup + rename preview function * cleanup * chore: delete test docs * cleanup * rename handler for consistency * feat: rename functions and files to be consistent with each other (#10358) * [INTEG-3359] feat: got google doc picker working (#10357) * feat: got google doc picker working * feat: explicitly add api key for google docs oauth connection * feat(google-docs): review entries modal [INTEG-3363] (#10359) * feat: reorganize file structure to be more compact (#10361) * refactor: modal components in google docs to be its own component (#10362) * refactor: content type analysis app action names to be consistent with other app actions (#10364) * fix: retries for oauth to be 5 instead of 10 (#10365) * [INTEG-3372] feat: google docs app works with references (#10366) * feat: ai document parser can handle references now * fix: console logs and fixed issues with creating entries and references being mapped * fix: use correct prod deploy s3 base in google docs (#10368) * fix: closing the modal from google docs picker no longer errors out (#10370) * fix: update preview entry card ui [INTEG-3341] (#10367) * fix: preview entry cards ui * fix: using displayField for entry title * pass sdk prop * chore:fix gapi path * feat: helper function to fetch entry titles * chore: using forma style tokens for entry cards * fix entry title helper functions * fix: styles * chore: rename title * fix: copy * fix: moving fetchEntryTitle logic to useGeneratePreview hook * chore: remove logs * chore: remove redundant title * fix any type for entry * replace magic number for title length * rename and move getEntryTitle util * handle zero entries better * cleanup: remove null type for preview response and unused props( summary, total entries) * cleanup * rename previewData -> previewEntries * cleanup * refactor getEntryTitle to use a new getContentType util * [INTEG-3381] refactor: preview modal changes (#10372) * fix: refactor the preview modal logic to have cleaner typings * feat: update app action typing using generics * fix: multiple entries (#10371) * fix: replacing select with multiselect for content type picker modal [INTEG-3378] (#10380) * fix: replacing select with multiselect for content type picker modal, removing `SelectedContentTypes` type * cleanup * feat: file picker upgrade [INTEG-3368] (#10379) * feat: file picker upgrade * removing suggested folders logic * feat: consolidate asset creation (#10377) * feat: loading state modal [INTEG-3382] (#10391) * feat: loading modal for google doc app * loadting state for creating entries * chore: cleanup * chore: cleanup up modal hook * chore: remove extra fragment tags * fixing ModalOrchestrator * empty commit to trigger circleci --------- Co-authored-by: ryunsong-contentful <124832189+ryunsong-contentful@users.noreply.github.com> Co-authored-by: Adrian Meyer <8539634+primeinteger@users.noreply.github.com> Co-authored-by: david-shibley-contentful <149433784+david-shibley-contentful@users.noreply.github.com> Co-authored-by: david shibley <david.shibley@contentful.com>
Purpose
https://contentful.atlassian.net/browse/INTEG-3348
Preview Step UI
useModalManagement()Hook(ui in progress!!!)
528336719-e1f834a3-fb54-48c5-ab60-e4bdc2713629.mov
Function Refactor:
Split up
createEntriesfromDocumentinto 3 functions to avoid timeout:analyzeContentTypes-> summarizes content typescreatePreview-> processes document and and creates preview entriescreateEntries-> calls cma to create entry draftsCleanup: