Skip to content
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

Fetch standard prompts from remote prompts API #6150

Merged
merged 11 commits into from
Nov 20, 2024

Conversation

vovakulikov
Copy link
Contributor

Part of SRCH-1181

This PR checks the SG version and tries to fetch built-in prompts from the prompt library rather than using local hardcoded commands. Later prompts query will be unified and all custom/built-in prompts will be fetched with one query

Test plan

first?: number
signal?: AbortSignal
}): Promise<Prompt[]> {
const response = await this.fetchSourcegraphAPI<APIResponse<{ prompts: { nodes: Prompt[] } }>>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should check the siteVersion here to make sure the builtinOnly param is available.

Also why are we calling BuiltinOnly prompts standard prompts here? It gets confusion having different names for the same thing at different parts of the code.

Secondly the STANDARD_PROMPTS_QUERY isn't event accepting the builtinOnly argument. Its hard coded in the query.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should check the siteVersion here to make sure the builtinOnly param is available.

I do this version check in mergedPromptsAndLegacyCommands because this is how I check if we should fetch remote/built-in prompts or if we should use local (prompts-like) commands. So another check here won't be nessesary.

Secondly, the STANDARD_PROMPTS_QUERY isn't even accepting the builtinOnly argument. It's hardcoded in the query.

Yes, I couldn't change the original prompts query because it requires another version check, and we already have two versions of this query. So I created another one only for built-in prompts.

Copy link
Contributor Author

@vovakulikov vovakulikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thenamankumar I fixed naming issues, ready for the second round

first?: number
signal?: AbortSignal
}): Promise<Prompt[]> {
const response = await this.fetchSourcegraphAPI<APIResponse<{ prompts: { nodes: Prompt[] } }>>(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should check the siteVersion here to make sure the builtinOnly param is available.

I do this version check in mergedPromptsAndLegacyCommands because this is how I check if we should fetch remote/built-in prompts or if we should use local (prompts-like) commands. So another check here won't be nessesary.

Secondly, the STANDARD_PROMPTS_QUERY isn't even accepting the builtinOnly argument. It's hardcoded in the query.

Yes, I couldn't change the original prompts query because it requires another version check, and we already have two versions of this query. So I created another one only for built-in prompts.

@vovakulikov vovakulikov force-pushed the vk/fetch-built-in-prompts-from-api branch from 4a40ea8 to 940eaa9 Compare November 20, 2024 15:16
@vovakulikov vovakulikov merged commit 224ef27 into main Nov 20, 2024
19 of 20 checks passed
@vovakulikov vovakulikov deleted the vk/fetch-built-in-prompts-from-api branch November 20, 2024 19:33
@sourcegraph-release-bot
Copy link
Collaborator

The backport to v1.46.x failed at https://github.com/sourcegraph/cody/actions/runs/11940463989:

The process '/usr/bin/git' failed with exit code 128

To backport this PR manually, you can either:

Via the sg tool

Use the sg backport command to backport your commit to the release branch.

sg backport -r v1.46.x -p 6150
Via your terminal

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-v1.46.x v1.46.x
# Navigate to the new working tree
cd .worktrees/backport-v1.46.x
# Create a new branch
git switch --create backport-6150-to-v1.46.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 224ef27ccec297988b45fb0f769188ef4fb6ab1b
# Push it to GitHub
git push --set-upstream origin backport-6150-to-v1.46.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-v1.46.x

If you encouter conflict, first resolve the conflict and stage all files, then run the commands below:

git cherry-pick --continue
# Push it to GitHub
git push --set-upstream origin backport-6150-to-v1.46.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-v1.46.x
  • Follow above instructions to backport the commit.
  • Create a pull request where the base branch is v1.46.x and the compare/head branch is backport-6150-to-v1.46.x., click here to create the pull request.

Once the pull request has been created, please ensure the following:

  • Make sure to tag @sourcegraph/release in the pull request description.

  • kindly remove the release-blocker from this pull request.

@sourcegraph-release-bot
Copy link
Collaborator

The backport to vscode-v1.46.x failed at https://github.com/sourcegraph/cody/actions/runs/11941446594:

Reviews may only be requested from collaborators. One or more of the teams you specified is not a collaborator of the sourcegraph/cody repository.

To backport this PR manually, you can either:

Via the sg tool

Use the sg backport command to backport your commit to the release branch.

sg backport -r vscode-v1.46.x -p 6150
Via your terminal

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-vscode-v1.46.x vscode-v1.46.x
# Navigate to the new working tree
cd .worktrees/backport-vscode-v1.46.x
# Create a new branch
git switch --create backport-6150-to-vscode-v1.46.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 224ef27ccec297988b45fb0f769188ef4fb6ab1b
# Push it to GitHub
git push --set-upstream origin backport-6150-to-vscode-v1.46.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-vscode-v1.46.x

If you encouter conflict, first resolve the conflict and stage all files, then run the commands below:

git cherry-pick --continue
# Push it to GitHub
git push --set-upstream origin backport-6150-to-vscode-v1.46.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-vscode-v1.46.x
  • Follow above instructions to backport the commit.
  • Create a pull request where the base branch is vscode-v1.46.x and the compare/head branch is backport-6150-to-vscode-v1.46.x., click here to create the pull request.

Once the pull request has been created, please ensure the following:

  • Make sure to tag @sourcegraph/release in the pull request description.

  • kindly remove the release-blocker from this pull request.

kalanchan pushed a commit that referenced this pull request Nov 21, 2024
…API (#6166)

Part of
[SRCH-1181](https://linear.app/sourcegraph/issue/SRCH-1181/pre-load-single-tenant-instances-to-have-ootb-prompts)

This PR checks the SG version and tries to fetch built-in prompts from
the prompt library rather than using local hardcoded commands. Later
prompts query will be unified and all custom/built-in prompts will be
fetched with one query

## Test plan
- Check after
https://linear.app/sourcegraph/issue/SRCH-1316/create-seeder-for-ootm-prompts
is done that the VSCode extension renders built-in prompts in the
welcome area and prompts tabs
 <br> Backport 224ef27 from #6150

Co-authored-by: Vova Kulikov <vova@sourcegraph.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants