[INTEG-3262] feat: create ai content type parser agent - #10255
[INTEG-3262] feat: create ai content type parser agent#10255Harika Kondur (harikakondur) merged 20 commits into
Conversation
…ent-content-type-parser
| apiKey?: string; | ||
| apiKeyLength?: number; | ||
| apiKeySuffix?: string; | ||
| openAiApiKey?: string; | ||
| openAiApiKeyLength?: number; | ||
| openAiApiKeySuffix?: string; | ||
| } | ||
|
|
||
| const VISIBLE_SUFFIX_LENGTH = 4; | ||
|
|
||
| const ConfigScreen = () => { | ||
| const sdk = useSDK<ConfigAppSDK>(); | ||
| const [apiKeyInput, setApiKeyInput] = useState<string>(''); | ||
| const [apiKeyObfuscatedDisplay, setApiKeyObfuscatedDisplay] = useState<string>(''); | ||
| const [apiKeyIsValid, setApiKeyIsValid] = useState<boolean>(true); | ||
| const [isValidatingApiKey, setIsValidatingApiKey] = useState<boolean>(false); | ||
| const [openAiApiKeyInput, setOpenAiApiKeyInput] = useState<string>(''); | ||
| const [openAiApiKeyObfuscatedDisplay, setOpenAiApiKeyObfuscatedDisplay] = useState<string>(''); | ||
| const [openAiApiKeyIsValid, setOpenAiApiKeyIsValid] = useState<boolean>(true); | ||
| const [isValidatingOpenAiApiKey, setIsValidatingOpenAiApiKey] = useState<boolean>(false); |
There was a problem hiding this comment.
renaming for clarity
| <Heading as="h3" marginBottom="spacingS"> | ||
| Analysis Result | ||
| </Heading> | ||
| <Paragraph marginBottom="spacingS"> | ||
| Raw output from the content type analysis agent: | ||
| </Paragraph> | ||
| <Box | ||
| style={{ | ||
| maxHeight: '400px', | ||
| overflow: 'auto', | ||
| background: '#f7f9fa', | ||
| padding: '16px', | ||
| borderRadius: '4px', | ||
| fontFamily: 'monospace', | ||
| fontSize: '12px', | ||
| whiteSpace: 'pre-wrap', | ||
| wordBreak: 'break-word', | ||
| }}> | ||
| {JSON.stringify(analysisResult.result.response, null, 2)} | ||
| </Box> | ||
| </Box> | ||
| )} |
There was a problem hiding this comment.
this ui is temporary for testing
Adrian Meyer (primeinteger)
left a comment
There was a problem hiding this comment.
Looks really solid! I left a few comments on some small things I noticed.
| const result = await sdk.cma.appActionCall.createWithResult( | ||
| { | ||
| appDefinitionId, | ||
| appActionId: '3nLAuoEuepbJMvdgp1qX6g', | ||
| }, | ||
| { | ||
| parameters: { contentTypeIds }, | ||
| } | ||
| ); |
There was a problem hiding this comment.
Can this app action be assigned an ID that describes the action, and then use that ID here instead of the system-generated one?
That would help make this app code work with multiple installations so that we can eventually have dev/staging/prod versions of the app.
There was a problem hiding this comment.
Agreed, this should be done before merging otherwise when we install this into staging and production, this wiill break. I can help you with this
There was a problem hiding this comment.
done ✅
| // TODO: Double check these values and make sure they are compatible because not every user will have a key | ||
| // to access all models | ||
| const modelVersion = 'gpt-4o'; | ||
| const temperature = 0.3; |
There was a problem hiding this comment.
If we go with using OpenAI for the GA release, we could allow the user to select their model from a dropdown list in the app configuration. We could get the list of available models from an API, similar to what we do in the other OpenAI apps: https://github.com/contentful/apps/blob/master/apps/ai-content-generator/src/components/config/model/Model.tsx#L23
There was a problem hiding this comment.
I'll add this to a fast follow ticket
* feat: helper function to fetch content types * wip: content parser agent * chore:cleanup * feat: content type service * ct picker modal for testing * fix: allow for multi select in content type picker modal * calls app action * app action fetches a single content type * app action fetches multiple content types * app action calls agent!!! * fix: openai api key parameter bug * chore: cleanup config page * chore: cleanup variable names * cleanup:logs n comments * fic: agent loader * chore: cleanup styles * fix: creating a `getAppActionId()` util to clean up code
Purpose
This PR adds the content type analyzer agent to the google docs import app.
Approach
generateObjectmethod for content type parsing/analysisContentTypeSummary)FinalContentTypesResultSummary)Testing steps
To test:
If you are adding logs in the function (
createEntriesFromDocument), you can access them in the actions tab of the app definition. Be sure to runnpm run deploy:devDependencies and/or References
https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-object
Screenshots
Screen.Recording.2025-11-17.at.5.37.26.PM.mov
Content Type Picker

