-
Notifications
You must be signed in to change notification settings - Fork 294
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
make slash command required in command configs #841
Conversation
…sh-command-required
…sh-command-required
for (const key in prompts) { | ||
if (Object.prototype.hasOwnProperty.call(prompts, key)) { | ||
const prompt = prompts[key] | ||
prompt.name = key | ||
prompt.type = type | ||
// replace any '/' from the start | ||
const slashCommand = prompt.slashCommand?.replace(/^\//, '') | ||
if (slashCommand?.length) { | ||
prompt.slashCommand = `/${slashCommand}` | ||
} | ||
prompt.slashCommand = key.startsWith('/') ? key : '/' + key | ||
this.myPromptsMap.set(key, prompt) | ||
} | ||
} |
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.
Open question: how to ensure these changes are backward compatible (users with the previous format of cody.json
with command names as keys, users with recipes)?
cc: @abeatrix
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.
A possible solution could be to apply new logic if the description
field exists in a command. This would mean that slash command is used as a key.
If the description
field is missing, store the command only if the slashCommand
is defined.
However, this will lead to partial use of cody.json
content (in "old" format commands only with slash commands will be stored). Maybe we should rewrite (make slash command a key) the cody.json
content when we spot the old format? WDYT?
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.
Left comments in line regarding migrating current file into next format
} | ||
this.myPromptsMap.set(key, prompt) | ||
// ensure there is only one leading forward slash | ||
prompt.slashCommand = key.replace(/^\/+/, '').replace(/^/, '/') |
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 you think we should also update the save
method to handle backward compatibility?
I think we should also extract the first words from all the current keys and turn them into the prompt.slashCommand option here to auto-migrate the current commands without the "slashCommand" settings for our users?
Maybe we can add a CTA to let them know how they can change the command keyword afterward. What do you think?
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.
Thanks for pointing this out! Updated the PR. Now we transform "old" format commands to the new format, update the corresponding config files, and inform the user about the change.
This PR converts names to dash-case (not the first word in the command as it's not guaranteed to be unique) and uses them as slash commands.
@toolmantim, except for the overall implementation, I'm looking for your feedback on:
|
@abeatrix, it seems so. But it doesn't seem to be caused by te current PR changes. |
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.
Works great! I gave it a thorough test locally, and popped on some commits to update a bunch of the UI labels.
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.
Works beautifully! Thanks @taras-yemets!
I have a PR opened that would be affected by the changes in this PR. Since my changes are closer to the main branch as it is using the old format, can you review my PR and see if we can merge mine before yours? Or would it cause other conflicts that would not matter which one gets merged first?
Here is the PR: #907
Part of https://github.com/sourcegraph/sourcegraph/issues/56182 Here's how to get this running: 1. Azure keys * https://portal.azure.com > Azure OpenAI > sourcegraph-test-oai > Keys and Endpoint * Copy the key and `export AZURE_API_KEY="<paste the key here>"` 1. `export SRC_ENDPOINT=https://sourcegraph.sourcegraph.com` 1. `export SRC_ACCESS_TOKEN="<s2 access token goes here>"` 1. Run like so: `pnpm run start --label="Beam search" --output="$HOME/test.results" --provider=azure` * single beam search test runs faster than total # test cases * output file actually allows you to drill into the LLM interaction details ## Test plan Manually verified: ### success scenario with Azure OpenAI and ``` ➜ e2e git:(cb/s/56182-azure) ✗ pnpm run start --label="Beam search" --output="$HOME/azure.results" --provider=azure > @sourcegraph/cody-e2e@0.0.1 start /Users/cbart/cody/e2e > pnpm run --silent build && node dist/e2e "--label=Beam search" "--output=/Users/cbart/azure.results" "--provider=azure" Run 1 of 1 Testing (1/1): Beam search (github.com/huggingface/transformers) Incorrect answers (LLM judge): 0/2 (0%) Incorrect or partial answers (LLM judge): 1/2 (50%) Missing facts: 5/9 (56%) Hallucinated entities: 9/9 (100%) Run 1 of 1 summary: Incorrect answers (LLM judge): 0/2 (0%) Incorrect or partial answers (LLM judge): 1/2 (50%) Missing facts: 5/9 (56%) Hallucinated entities: 9/9 (100%) ``` ### fast fail when not enough env vars provided ``` ➜ e2e git:(cb/s/56182-azure) unset AZURE_DEPLOYMENT_ID ➜ e2e git:(cb/s/56182-azure) ✗ pnpm run start --label="Beam search" --output="$HOME/azure.results" --provider=azure > @sourcegraph/cody-e2e@0.0.1 start /Users/cbart/cody/e2e > pnpm run --silent build && node dist/e2e "--label=Beam search" "--output=/Users/cbart/azure.results" "--provider=azure" Missing required environment variables: AZURE_DEPLOYMENT_ID 1. https://portal.azure.com > Azure OpenAI > sourcegraph-test-oai > Keys and Endpoint 2. Go to Model Deployments > Manage Deployments. Find the deployment name and: export AZURE_DEPLOYMENT_ID="<paste deployment name here>" ELIFECYCLE Command failed with exit code 1. ```
…sh-command-required
@abeatrix There is an ongoing discussion about whether the referenced PR will be included in the upcoming release, so I'm this one to have a bit more time to test it on |
Next iteration on #631
Follow-up on #798
Design
default-prompts.json
and.vscode/cody.json
:slashCommand
field on a command is removedScreen.Recording.2023-09-01.at.16.28.04.mov
Test plan
CI passes.