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

update custom recipes: support premade, save user recipes to file #279

Merged
merged 8 commits into from
Jul 18, 2023

Conversation

abeatrix
Copy link
Contributor

@abeatrix abeatrix commented Jul 17, 2023

Summary

Changes included:

Non Custom Recipes related changes

  1. fix issue where cody would reply to the language prompt:
  • Before: image
  • After: image
  1. Do not include context when user input has less than 2 words. Currently, we are including context for all first interaction; however, that should not be the case when the user has only input one word, which most likely will not be a question and does not require context.
  • Before: image
  • After: image

Custom Recipes related changes

  1. add support for custom premade and starter for prompt testing purposes
  2. Create and store User Recipes to the .vscode directory in user's home directory instead of global storage
  3. Allow context selection for new recipes via UI
  • image
  1. Update examples files in cody.json for User and Worksapce recipes
  2. Add new context types for Custom Recipes building: filePath and directoryPath
  3. Fix current openTabs context logic that is not returning all the file context from open tabs

Test Plan

Non Custom Recipes related changes

  1. in the chat box, type ok? to check if Cody is replying to the language prompt or not
  2. Input with less than 2 words should not include any context for chat-questions

Custom Recipes related changes

This feature is only available to users connected to S2 instance.

  1. Follow the instruction in this Notebook to set up Custom Recipes
  2. Click on the + button in the Recipes tab and see if you can create a new recipe that is saved to the .vscode/cody.json for user recipes. You should see a step that allows you to select the context needed for the recipe
  3. Build a new recipe and see if the recipe is using the correct context type that you have defined for the recipe
To test custom premade:

This feature is only available to users connected to S2 instance.

  1. Follow the instruction in this Notebook to set up Custom Recipes
  2. In your .vscode/cody.json file, add the following in addition to the recipes field (thanks @jdorfman for this example 😂)
{
  "premade": {
    "rules": "You are always annoyed with Morty, that is the tone you should answer all your questions with. Make sure to throw in references from the show. For example: Jerry, Beth, Summer, Evil Morty, the Citadel, Blips and Chitz, Pickle Rick, or Jessica. The response shouldn't be too mean. Please don't ask for feedback. Just give the answer, no questions.",
    "actions": "You are Rick Sanchez, the smartest man in the universe, from the Adult Swim cartoon Rick and Morty. Morty. I am your grandson, and want to learn how to code from you. As Rick, you will teach me, Morty, how to code.",
    "answer": "Understood. I am Rick Sanchez, the smartest man in the universe, from the Adult Swim cartoon Rick and Morty. I am here to help you, my annoying grandson Morty, with programming tasks."
  },
  "starter": "Hi Grandpa Rick!",
  "recipes": {
  ... recipes
  }
}

Once you have saved the file, ask Cody a question. You should expect Cody to reply as Rick from Rick and Morty.

@abeatrix abeatrix requested review from philipp-spiess and a team July 17, 2023 21:53
Copy link
Contributor

@philipp-spiess philipp-spiess left a comment

Choose a reason for hiding this comment

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

Nice!

@@ -136,7 +136,7 @@ export class MyPrompt implements Recipe {
if (commandOutput) {
contextMessages.push(...MyPrompt.getTerminalOutputContext(commandOutput))
}
return contextMessages.slice(-12)
return contextMessages.slice(-15)
Copy link
Member

Choose a reason for hiding this comment

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

Can extract as a constant. Also why slice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea that's a good idea! I do have some questions regarding the number so will do that in a follow up.

Also why slice?

This is to return the last n context messages if more than n context messages are generated for the prompts & The context messages that are more important are added toward the end for Cody to read.

@abeatrix abeatrix merged commit 4989b66 into main Jul 18, 2023
5 checks passed
@abeatrix abeatrix deleted the bee/my-prompts-improvements branch July 18, 2023 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants