- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
New Components - deepseek #15502
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
                    New Components - deepseek #15502
Changes from 3 commits
      Commits
    
    
            Show all changes
          
          
            4 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    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
        
          
          
            136 changes: 136 additions & 0 deletions
          
          136 
        
  components/deepseek/actions/create-chat-completion/create-chat-completion.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,136 @@ | ||
| import { RESPONSE_FORMAT_TYPE_OPTIONS } from "../../common/constants.mjs"; | ||
| import { parseObject } from "../../common/util.mjs"; | ||
| import deepseek from "../../deepseek.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "deepseek-create-chat-completion", | ||
| name: "Create Chat Completion", | ||
| description: "Creates a chat completion using the DeepSeek API. [See the documentation](https://api-docs.deepseek.com/api/create-chat-completion)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| deepseek, | ||
| messages: { | ||
| type: "string[]", | ||
| label: "Messages", | ||
| description: "The messages for the chat conversation as JSON strings. Each message should be a JSON string like '{\"role\": \"user\", \"content\": \"Hello!\"}'. [See the documentation](https://api-docs.deepseek.com/api/create-chat-completion) for further details.", | ||
| }, | ||
| frequencyPenalty: { | ||
| type: "string", | ||
| label: "Frequency Penalty", | ||
| description: "Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.", | ||
| optional: true, | ||
| }, | ||
| maxTokens: { | ||
| type: "integer", | ||
| label: "Max Tokens", | ||
| description: "Integer between 1 and 8192. The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length. If `max_tokens` is not specified, the default value 4096 is used.", | ||
| optional: true, | ||
| }, | ||
| presencePenalty: { | ||
| type: "string", | ||
| label: "Presence Penalty", | ||
| description: "Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.", | ||
| optional: true, | ||
| }, | ||
| responseFormatType: { | ||
| type: "string", | ||
| label: "Response Format Type", | ||
| description: "The format that the model must output. Setting to JSON Object enables JSON Output, which guarantees the message the model generates is valid JSON.", | ||
| options: RESPONSE_FORMAT_TYPE_OPTIONS, | ||
| optional: true, | ||
| }, | ||
| stop: { | ||
| type: "string[]", | ||
| label: "Stop Sequences", | ||
| description: "Up to 16 sequences where the API will stop generating further tokens.", | ||
| optional: true, | ||
| }, | ||
| stream: { | ||
| type: "boolean", | ||
| label: "Stream", | ||
| description: "If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events (SSE) as they become available, with the stream terminated by a `data: [DONE]` message.", | ||
| optional: true, | ||
| reloadProps: true, | ||
| }, | ||
| streamIncludeUsage: { | ||
| type: "string", | ||
| label: "Stream Include Usage", | ||
| description: "If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value.", | ||
| optional: true, | ||
| hidden: true, | ||
| }, | ||
| temperature: { | ||
| type: "string", | ||
| label: "Temperature", | ||
| description: "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or Top P but not both.", | ||
| optional: true, | ||
| }, | ||
| topP: { | ||
| type: "string", | ||
| label: "Top P", | ||
| description: "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or Temperature but not both.", | ||
| optional: true, | ||
| }, | ||
| tools: { | ||
| type: "string[]", | ||
| label: "Tools", | ||
| description: "A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.", | ||
| optional: true, | ||
| }, | ||
| toolChoice: { | ||
| type: "string", | ||
| label: "Tool Choice", | ||
| description: "Controls which (if any) tool is called by the model. [See the documentation](https://api-docs.deepseek.com/api/create-chat-completion) for further details.", | ||
| optional: true, | ||
| }, | ||
| logprobs: { | ||
| type: "boolean", | ||
| label: "Log Probs", | ||
| description: "Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`.", | ||
| optional: true, | ||
| }, | ||
| topLogprobs: { | ||
| type: "string", | ||
| label: "Top Log Probabilities", | ||
| description: "An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async additionalProps(props) { | ||
| props.streamIncludeUsage.hidden = !this.stream; | ||
| return {}; | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.deepseek.createModelResponse({ | ||
| $, | ||
| data: { | ||
| messages: parseObject(this.messages), | ||
| model: "deepseek-chat", | ||
| frequency_penalty: this.frequencyPenalty && parseInt(this.frequencyPenalty), | ||
| max_tokens: this.maxTokens, | ||
| presence_penalty: this.presencePenalty && parseInt(this.presencePenalty), | ||
| response_format: this.responseFormatType | ||
| ? { | ||
| type: this.responseFormatType, | ||
| } | ||
| : null, | ||
| stop: parseObject(this.stop), | ||
| stream: this.stream, | ||
| stream_options: this.stram | ||
|         
                  luancazarine marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| ? { | ||
| include_usage: this.streamIncludeUsage, | ||
| } | ||
| : null, | ||
| temperature: this.temperature && parseInt(this.temperature), | ||
| top_p: this.topP && parseInt(this.topP), | ||
| tools: parseObject(this.tools), | ||
| tool_choice: parseObject(this.toolChoice), | ||
| logprobs: this.logprobs, | ||
| top_logprobs: this.topLogprobs && parseInt(this.topLogprobs), | ||
| }, | ||
| }); | ||
| $.export("$summary", "Chat completion created"); | ||
| 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,19 @@ | ||
| import deepseek from "../../deepseek.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "deepseek-get-balance", | ||
| name: "Get User Balance", | ||
| description: "Retrieves the user's current balance. [See the documentation](https://api-docs.deepseek.com/api/get-user-balance)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| deepseek, | ||
| }, | ||
| async run({ $ }) { | ||
| const response = await this.deepseek.getUserBalance({ | ||
| $, | ||
| }); | ||
| $.export("$summary", "Successfully retrieved user balance"); | ||
| 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,19 @@ | ||
| import deepseek from "../../deepseek.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "deepseek-list-models", | ||
| name: "List Models", | ||
| description: "Lists the currently available models, and provides basic information about each one such as the owner and availability. [See the documentation](https://api-docs.deepseek.com/api/list-models)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| deepseek, | ||
| }, | ||
| async run({ $ }) { | ||
| const models = await this.deepseek.listModels({ | ||
| $, | ||
| }); | ||
| $.export("$summary", "Successfully listed models"); | ||
| return models; | ||
| }, | ||
| }; | 
  
    
      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,10 @@ | ||
| export const RESPONSE_FORMAT_TYPE_OPTIONS = [ | ||
| { | ||
| label: "Text", | ||
| value: "text", | ||
| }, | ||
| { | ||
| label: "JSON Object", | ||
| value: "json_object", | ||
| }, | ||
| ]; | 
  
    
      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,24 @@ | ||
| export const parseObject = (obj) => { | ||
| if (!obj) return undefined; | ||
|  | ||
| if (Array.isArray(obj)) { | ||
| return obj.map((item) => { | ||
| if (typeof item === "string") { | ||
| try { | ||
| return JSON.parse(item); | ||
| } catch (e) { | ||
| return item; | ||
| } | ||
| } | ||
| return item; | ||
| }); | ||
| } | ||
| if (typeof obj === "string") { | ||
| try { | ||
| return JSON.parse(obj); | ||
| } catch (e) { | ||
| return obj; | ||
| } | ||
| } | ||
| return obj; | ||
| }; | 
  
    
      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,44 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|  | ||
| export default { | ||
| type: "app", | ||
| app: "deepseek", | ||
| propDefinitions: {}, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.deepseek.com"; | ||
| }, | ||
| _headers() { | ||
| return { | ||
| "Authorization": `Bearer ${this.$auth.api_key}`, | ||
| }; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, path, ...opts | ||
| }) { | ||
| return axios($, { | ||
| url: this._baseUrl() + path, | ||
| headers: this._headers(), | ||
| ...opts, | ||
| }); | ||
| }, | ||
|         
                  luancazarine marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| createModelResponse(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/chat/completions", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| getUserBalance() { | ||
| return this._makeRequest({ | ||
| method: "GET", | ||
| path: "/user/balance", | ||
| }); | ||
| }, | ||
| listModels() { | ||
| return this._makeRequest({ | ||
| method: "GET", | ||
| path: "/models", | ||
| }); | ||
| }, | ||
|         
                  luancazarine marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| }, | ||
| }; | ||
  
    
      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/deepseek", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream DeepSeek Components", | ||
| "main": "deepseek.app.mjs", | ||
| "keywords": [ | ||
|  | @@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | ||
| } | ||
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.