-
Notifications
You must be signed in to change notification settings - Fork 33
Feature/natural language template selection #894
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
Open
chsrimanaswi
wants to merge
8
commits into
adobe:ai-app-init
Choose a base branch
from
chsrimanaswi:feature/natural-language-template-selection
base: ai-app-init
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+437
−7
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7f8c907
add AI template recommendation prompt to init command
4e6f23a
removed comments
527cae9
chore: update API endpoint to use deployed backend
c0c1a4d
Updated logs
0db8372
Updated console logs
d79fef3
Added Flag chat for AI prompt
d60d345
Added Flag chat for AI prompt
92fe742
Add logic to select between env
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| Copyright 2025 Adobe. All rights reserved. | ||
| This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. You may obtain a copy | ||
| of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software distributed under | ||
| the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| OF ANY KIND, either express or implied. See the License for the specific language | ||
| governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:template-recommendation', { provider: 'debug' }) | ||
| const { TEMPLATE_RECOMMENDATION_API_ENDPOINTS } = require('./defaults') | ||
| const { getCliEnv } = require('@adobe/aio-lib-env') | ||
|
|
||
| /** | ||
| * Calls the template recommendation API to get AI-based template suggestions | ||
| * @param {string} prompt - User's natural language description of what they want to build | ||
| * @param {string} [apiUrl] - Optional API URL (defaults to env var TEMPLATE_RECOMMENDATION_API or environment-based URL) | ||
| * @returns {Promise<object>} Template recommendation from the API | ||
| * @throws {Error} If API call fails | ||
| */ | ||
| async function getAIRecommendation (prompt, apiUrl) { | ||
| // Select URL based on environment (same pattern as aio-lib-state) | ||
| const env = getCliEnv() | ||
| const url = apiUrl || process.env.TEMPLATE_RECOMMENDATION_API || TEMPLATE_RECOMMENDATION_API_ENDPOINTS[env] | ||
| aioLogger.debug(`Calling template recommendation API: ${url} (env: ${env})`) | ||
| aioLogger.debug(`Prompt: ${prompt}`) | ||
|
|
||
| const payload = { prompt } | ||
| const options = { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/json' | ||
| }, | ||
| body: JSON.stringify(payload) | ||
| } | ||
|
|
||
| const response = await fetch(url, options) | ||
|
|
||
| if (!response.ok) { | ||
| const errorText = await response.text() | ||
| aioLogger.error(`API returned status ${response.status}: ${errorText}`) | ||
| throw new Error(`API returned status ${response.status}`) | ||
| } | ||
|
|
||
| const data = await response.json() | ||
| aioLogger.debug(`API response: ${JSON.stringify(data)}`) | ||
| return data.body || data | ||
| } | ||
|
|
||
| module.exports = { | ||
| getAIRecommendation | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we have any auth enabled for recommendation API? If not it can lead to DOS attacks very easily.
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.
We initially wanted everyone to access the AI prompt. We will look into how to achieve the auth part.
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.
@sandeep-paliwal This would be good to discuss - I was thinking maybe we could pass the CLI token and do IMS auth on the backend. That of course would make it so we only allow the recommend flow for the logged in use cases and not noLogin. But maybe that's okay since noLogin is usually non-interactive?