- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
Component code gen: updating prompt, adding support for bug fixes #14218
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,36 +1,58 @@ | ||
| additional_rules = """## Additional rules for actions | ||
| additional_rules = """<AdditionalRules> | ||
|  | ||
| 1. Always import the app file like this: | ||
|  | ||
| ```javascript | ||
| import appName from "../../appName.app.mjs"; | ||
| ``` | ||
|  | ||
| and pass the app file as a prop to the component: | ||
|  | ||
| ```javascript | ||
| export default { | ||
| props: { | ||
| appName, | ||
| }, | ||
| // rest of the component ... | ||
| } | ||
| ``` | ||
|  | ||
| 2. `return` the final value from the step. The data returned from steps must be JSON-serializable. The returned data is displayed in Pipedream. Think about it: if you don't return the data, the user won't see it. | ||
|  | ||
| 3. Always use this signature for the run method: | ||
|  | ||
| ```javascript | ||
| async run({ $ }) { | ||
| // your code here | ||
| // you must fill in the actual code here | ||
| } | ||
| ``` | ||
|  | ||
| Always pass { $ }, even if you don't use them in the code. | ||
| Always pass `{ $ }` in the arguments to the `run` method, even if you don't use it in the code. | ||
|  | ||
| 4. Remember that `@pipedream/platform` axios returns a Promise that resolves to the HTTP response data. There is NO `data` property in the response that contains the data. The data from the HTTP response is returned directly in the response, not in the `data` property. Think about it: if you try to extract a data property that doesn't exist, the variable will hold the value `undefined`. You must return the data from the response directly and extract the proper data in the format provided by the API docs. | ||
| 4. `@pipedream/platform` axios returns a Promise that resolves to the HTTP response data. There is NO `data` property in the response that contains the data. The data from the HTTP response is returned directly in the response, not in the `data` property. Think about it: if you try to extract a data property that doesn't exist, the variable will hold the value `undefined`. You must return the data from the response directly and extract the proper data in the format provided by the API docs. | ||
|  | ||
| For example, do this: | ||
|  | ||
| ```javascript | ||
| const response = await axios(this, { | ||
| url: `https://api.stability.ai/v1/engines/list`, | ||
| headers: { | ||
| Authorization: `Bearer ${this.dreamstudio.$auth.api_key}`, | ||
| }, | ||
| }); | ||
| // process the response data. response.data is undefined | ||
| // process the `response` as the return data. `response.data` is undefined, data is directly in `response` | ||
| ``` | ||
|  | ||
| not this: | ||
|  | ||
| ```javascript | ||
| // this is incorrect — there is no `data` property in the response | ||
| const { data } = await axios(this, { | ||
| url: `https://api.stability.ai/v1/engines/list`, | ||
| headers: { | ||
| Authorization: `Bearer ${this.dreamstudio.$auth.api_key}`, | ||
| }, | ||
| });""" | ||
| }); | ||
| ``` | ||
|  | ||
| </AdditionalRules>""" | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,12 +1,15 @@ | ||
| export_summary = """## Export summary | ||
| export_summary = """<ExportSummary> | ||
|  | ||
| A short summary should be exported before the end so that the user can quickly read what has happened. This is done by calling `$.export("$summary", "Your summary here")`. This is not optional. | ||
| You must call `$.export` to export a short text summary near the end of the `run` method so the user knows the call was successful. This is done by calling `$.export("$summary", "Your summary here")`. | ||
|  | ||
| The summary should contain relevant metadata about the object that was created, updated, or deleted. For example, if you are creating a new issue, you should include the issue name or ID in the summary. | ||
| The summary should contain relevant metadata about the object that was created, updated, or deleted. For example, if you are creating a new issue, you should include the issue name or ID in the summary. Include information here that you think will be most relevant for the user reading the summary. | ||
|  | ||
| ``` | ||
| `$.export("$summary", `Created issue ${name}`) | ||
| Generally, this should happen immediately before you return the data at the end of the component's `run` method. | ||
|  | ||
| ```javascript | ||
| $.export("$summary", `Created issue ${name}`) | ||
| return data | ||
| ``` | ||
|  | ||
| Include information here that you think will be most relevant for the user. | ||
| </ExportSummary> | ||
| """ | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,9 +1,31 @@ | ||
| introduction = """## Instructions | ||
| introduction = """<Instructions> | ||
| Your goal is to create Pipedream Action Components. Your code should solve the requirements provided below. | ||
| <Goal> | ||
| Your goal is to create Pipedream action components, defined in the <Definitions> section below. | ||
| Other GPT agents will be reviewing your work, and will provide feedback on your code. I'll give you $500 for every rule you follow accurately, so you'll get a bigger tip if you follow all of the rules. | ||
| Your code should solve the requirements provided below. | ||
| ## Pipedream components | ||
| Think step by step: | ||
| All Pipedream components are Node.js modules that have a default export: an javascript object - a Pipedream component - as its single argument.""" | ||
| 1. Review the requirements | ||
| 2. Map out the `props`, `methods`, `run` method, and any other code you need to solve the requirements. | ||
| 3. Review whether you need async options for props (see the <AsyncOptions> section below) | ||
| 4. Review all of the rules carefully before producing code | ||
| 5. Produce full, complete, working code. This code is going straight to production. | ||
| 6. Review the code against the rules again, iterating or fixing items as necessary. | ||
| 7. Output the final code according to the rules of the <Output> section below. | ||
| Other GPT agents will be reviewing your work, and will provide feedback on your code. Please review it before producing output. | ||
| </Goal> | ||
| <Defintions> | ||
| <PipedreamActionComponents> | ||
| All Pipedream components are Node.js modules that have a default export: an javascript object - a Pipedream component - as its single argument. | ||
| See the <Rules>, <AsyncOptions>, <AdditionalRules>, and other sections below for details on how to structure components. | ||
| </PipedreamActionComponents> | ||
| </Definitions> | ||
| 
      Comment on lines
    
      +22
     to 
      +29
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance the section with more details and examples While the section provides a basic understanding of Pipedream components, it could be more comprehensive. Consider the following improvements: 
 Here's a suggested expansion of the section:  <PipedreamActionComponents>
 
 All Pipedream components are Node.js modules that have a default export: an javascript object - a Pipedream component - as its single argument.
 
+A typical Pipedream component structure includes:
+- `props`: Define the input parameters for the component.
+- `run`: The main method that executes when the component is triggered.
+- Other optional methods like `deploy`, `dedupe`, etc.
+
+Example of a basic component structure:
+
+```javascript
+export default {
+  key: "my-component",
+  name: "My Component",
+  version: "0.0.1",
+  props: {
+    myProp: "string",
+  },
+  async run({ steps, $ }) {
+    // Component logic here
+  },
+};
+```
+
 See the <Rules>, <AsyncOptions>, <AdditionalRules>, and other sections below for details on how to structure components.
 
 </PipedreamActionComponents>This expansion provides more context and a concrete example, which should help users better understand Pipedream components. | ||
| </Instructions>""" | ||
| 
      Comment on lines
    
      +1
     to 
      +31
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Address missing sections referenced in the introduction The introduction refers to several sections that are not present in this file, such as , , , and . This could lead to confusion for users expecting to find this information here. Consider the following options: 
 Would you like assistance in drafting placeholder content for these missing sections or in creating a note explaining their absence? | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| additional_rules = """## Additional rules | ||
| additional_rules = """<AdditionalRules> | ||
|  | ||
| ### Generate propDefinitions and methods for ALL requirements | ||
| 1. Generate `propDefinitions` and `methods` for ALL requirements | ||
|  | ||
| The instructions should note the actions and source components that are required for the app. The code generator should generate the propDefinitions and methods for ALL requirements. Think about it: this way other agents will be able to use the shared props + methods in the action and source components. Double-check your output to make sure that the propDefinitions and methods are generated for ALL requirements. | ||
| The instructions should note the actions and source components that are required for the app. The code generator should generate the `propDefinitions` and `methods` for ALL requirements. Think about it: this way other agents will be able to use the shared props + methods in the action and source components. Double-check your output to make sure that the propDefinitions and methods are generated for ALL requirements. | ||
| </AdditionalRules> | ||
| """ | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,20 +1,42 @@ | ||
| introduction = """## Instructions | ||
| introduction = """<Instructions> | ||
|  | ||
| Your goal is to create Pipedream app files. Your code should solve the requirements provided below. | ||
| <Goal> | ||
| Your goal is to create Pipedream app files, defined in the Definition section below. | ||
|  | ||
| DO NOT remove any propDefinitions or methods that already exist. You can only write more, if required. | ||
| Your code should solve the requirements provided below. | ||
|  | ||
| Other GPT agents will be reviewing your work, and will provide feedback on your code. I'll give you $500 for every rule you follow accurately, so you'll get a bigger tip if you follow all of the rules. | ||
| Think step by step: | ||
|  | ||
| ## Pipedream App files | ||
| 1. Review the requirements | ||
| 2. Map out the props and methods you need to solve the requirements | ||
| 3. Review whether you need async options for props (see the <AsyncOptions> section below) | ||
| 4. Review all of the rules carefully before producing code | ||
| 5. Produce full, complete, working code. This code is going straight to production. | ||
| 6. Review the code against the rules again, iterating or fixing items as necessary. | ||
| 7. Output the final code according to the rules of the <Output> section below. | ||
|  | ||
| Other GPT agents will be reviewing your work, and will provide feedback on your code. Please review it before producing output. | ||
| </Goal> | ||
|  | ||
| <Definition> | ||
| <PipedreamAppFiles> | ||
|  | ||
| All Pipedream app files are Node.js modules that have a default export: a javascript object - a Pipedream app - as its single argument. | ||
|  | ||
| All app objects have four properties: type, app, propDefinitions, and methods: | ||
| All app objects have four properties: `type`, `app`, `propDefinitions`, and `methods`: | ||
|  | ||
| - The `type` property is always set to "app". | ||
| - The `app` property is the name of the app, e.g. "google_sheets". | ||
| - The `propDefinitions` property is an object that contains the props for the app. | ||
| - The methods property is an object that contains the methods for the app. | ||
| - The `methods` property is an object that contains the methods for the app. | ||
|  | ||
| These props and methods are shared across components for this app file. You'll need to generate props and methods for ALL requirements for all components that you're passed below. | ||
| </PipedreamAppFiles> | ||
| </Definition> | ||
| <Output> | ||
| Output Node.js code. | ||
|  | ||
| DO NOT remove any `propDefinitions` or `methods` that already exist. You can only write more, if required. | ||
| </Output> | ||
|  | ||
| These props and methods are shared across components for this app file. You'll need to generate props and methods for ALL requirements for all components that you're passed below.""" | ||
| </Instructions>""" | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| prop_definitions = """## Prop Definitions | ||
| prop_definitions = """<PropDefinitions> | ||
|  | ||
| The app code should contain a `propDefinitions` property, which are the definitions for the props. | ||
| The app code should contain a `propDefinitions` property, which define the props. | ||
|  | ||
| You'll find a "Props" section below that outlines the rules for generating props. All of those rules are valid, BUT instead of placing them in a `props` property, you MUST place props in the `propDefinitions` property. This is how Pipedream app files expect props to be declared. | ||
| You'll find a <Props> section below that outlines the rules for generating props. All of those rules are valid, BUT instead of placing them in a `props` property, you MUST place props in the `propDefinitions` property. This is how Pipedream app files expect props to be declared. | ||
| </PropDefinitions> | ||
| """ | 
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.
🛠️ Refactor suggestion
Fix typo and consider adding a brief introduction
The section provides clear, step-by-step instructions for creating Pipedream action components. However, there's a minor typo that needs to be corrected:
Additionally, consider adding a brief introductory sentence before the numbered list to set the context for the steps that follow.
Here's a suggested improvement for the beginning of the section:
And fix the typo:
Also applies to: 21-21