- 
                Notifications
    
You must be signed in to change notification settings  - Fork 5.5k
 
[Components] wolfram_alpha - new action component #15527
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
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
  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
        
          
          
            81 changes: 81 additions & 0 deletions
          
          81 
        
  components/wolfram_alpha/actions/perform-computation/perform-computation.mjs
  
  
      
      
   
        
      
      
    
  
    
      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,81 @@ | ||
| import app from "../../wolfram_alpha.app.mjs"; | ||
| 
     | 
||
| export default { | ||
| key: "wolfram_alpha-perform-computation", | ||
| name: "Perform Computation", | ||
| description: "Executes a computation query using the Wolfram Alpha API. [See the documentation](https://products.wolframalpha.com/api/documentation)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| input: { | ||
| type: "string", | ||
| label: "Input", | ||
| description: "Text specifying the input string.", | ||
| }, | ||
| width: { | ||
| type: "string", | ||
| label: "Width", | ||
| description: "Specify an approximate width limit for text and tables. Eg. `200`, `500`. This parameter does not affect plots or graphics. Width values are approximate; behavior may vary for different content.", | ||
| optional: true, | ||
| }, | ||
| maxWidth: { | ||
| type: "string", | ||
| label: "Max Width", | ||
| description: "Specify an extended maximum width for large objects. Eg. `200`, `500`. This parameter does not affect plots or graphics. Width values are approximate; behavior may vary for different content.", | ||
| optional: true, | ||
| }, | ||
| plotWidth: { | ||
| type: "string", | ||
| label: "Plot Width", | ||
| description: "Specify an approximate width limit for plots and graphics. Eg. `100`, `200`. This parameter does not affect text or tables. Width values are approximate; behavior may vary for different content.", | ||
| optional: true, | ||
| }, | ||
| mag: { | ||
| type: "string", | ||
| label: "Magnification", | ||
| description: "Specify magnification of objects within a pod. Eg. `0.5`, `1.0`, `2.0`. Changing this parameter does not affect the overall size of pods.", | ||
| optional: true, | ||
| }, | ||
| assumption: { | ||
| type: "string", | ||
| label: "Assumption", | ||
| description: "Specifies an assumption, such as the meaning of a word or the value of a formula variable. Eg. `*C.pi-_*Movie`, `DateOrder_**Day.Month.Year--`. Assumptions made implicitly by the API. Values for this parameter are given by the input properties of `<value>` subelements of `<assumption>` elements in XML results.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| performComputation(args = {}) { | ||
| return this.app.makeRequest({ | ||
| path: "/llm-api", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| performComputation, | ||
| input, | ||
| width, | ||
| maxWidth, | ||
| plotWidth, | ||
| mag, | ||
| assumption, | ||
| } = this; | ||
| 
     | 
||
| const response = await performComputation({ | ||
| $, | ||
| params: { | ||
| input, | ||
| width, | ||
| maxwidth: maxWidth, | ||
| plotwidth: plotWidth, | ||
| mag, | ||
| assumption, | ||
| }, | ||
| }); | ||
| 
     | 
||
| $.export("$summary", "Computation performed successfully"); | ||
| return response; | ||
| }, | ||
| }; | ||
  
    
      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,7 @@ | ||
| const BASE_URL = "https://www.wolframalpha.com"; | ||
| const VERSION_PATH = "/api/v1"; | ||
| 
     | 
||
| export default { | ||
| BASE_URL, | ||
| VERSION_PATH, | ||
| }; | 
  
    
      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 | 
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/wolfram_alpha", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream Wolfram Alpha Components", | ||
| "main": "wolfram_alpha.app.mjs", | ||
| "keywords": [ | ||
| 
        
          
        
         | 
    @@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | ||
| } | ||
  
    
      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 | 
|---|---|---|
| @@ -1,11 +1,27 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
| import constants from "./common/constants.mjs"; | ||
| 
     | 
||
| export default { | ||
| type: "app", | ||
| app: "wolfram_alpha", | ||
| propDefinitions: {}, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| getUrl(path) { | ||
| return `${constants.BASE_URL}${constants.VERSION_PATH}${path}`; | ||
| }, | ||
| getAuthParams(params) { | ||
| return { | ||
| ...params, | ||
| appid: this.$auth.app_id, | ||
| }; | ||
| }, | ||
| makeRequest({ | ||
| $ = this, path, params, ...args | ||
| } = {}) { | ||
| return axios($, { | ||
| ...args, | ||
| url: this.getUrl(path), | ||
| params: this.getAuthParams(params), | ||
| }); | ||
| }, | ||
| }, | ||
| }; | 
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
      
      Oops, something went wrong.
      
    
  
      
      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.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.