Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@builder6/piece-openai-pro

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@builder6/piece-openai-pro - npm Package Compare versions

Comparing version 0.3.26 to 0.3.27

2

package.json
{
"name": "@builder6/piece-openai-pro",
"version": "0.3.26",
"version": "0.3.27",
"dependencies": {

@@ -5,0 +5,0 @@ "@sinclair/typebox": "0.26.8",

@@ -14,2 +14,4 @@ export declare const askOpenAI: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{

roles: import("@activepieces/pieces-framework").JsonProperty<false>;
tools: import("@activepieces/pieces-framework").JsonProperty<false>;
tool_choice: import("@activepieces/pieces-framework").JsonProperty<false>;
}>;

@@ -9,2 +9,3 @@ "use strict";

const common_1 = require("../common/common");
const lodash_1 = require("lodash");
exports.askOpenAI = (0, pieces_framework_1.createAction)({

@@ -106,2 +107,14 @@ auth: __1.openaiAuth,

}),
tools: pieces_framework_1.Property.Json({
displayName: 'tools',
required: false,
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.',
defaultValue: []
}),
tool_choice: pieces_framework_1.Property.Json({
displayName: 'tool choice',
required: false,
description: 'Controls which (if any) function is called by the model.',
defaultValue: {},
}),
},

@@ -115,3 +128,3 @@ run({ auth, propsValue, store }) {

});
const { model, temperature, maxTokens, topP, frequencyPenalty, presencePenalty, prompt, memoryKey, } = propsValue;
const { model, temperature, maxTokens, topP, frequencyPenalty, presencePenalty, prompt, memoryKey, tools, tool_choice } = propsValue;
let messageHistory = [];

@@ -148,5 +161,16 @@ // If memory key is set, retrieve messages stored in history

presence_penalty: presencePenalty,
tool_choice: (0, lodash_1.isEmpty)(tool_choice) ? undefined : tool_choice,
tools: tools.length > 0 ? tools : undefined
});
// Add response to message history
messageHistory = [...messageHistory, completion.choices[0].message];
let rev = null;
if ((0, lodash_1.isEmpty)(tool_choice)) {
rev = completion.choices[0].message.content;
messageHistory = [...messageHistory, completion.choices[0].message];
}
else {
rev = completion.choices[0].message.tool_calls[0].function.arguments;
messageHistory = [...messageHistory, { content: completion.choices[0].message.tool_calls[0].function.arguments }];
}
// messageHistory = [...messageHistory, completion.choices[0].message];
// Check message history token size

@@ -163,3 +187,3 @@ // System limit is 32K tokens, we can probably make it bigger but this is a safe spot

}
return completion.choices[0].message.content;
return rev;
});

@@ -166,0 +190,0 @@ },

@@ -87,2 +87,3 @@ "use strict";

const calculateTokensFromString = (string, model) => {
console.log(`calculateTokensFromString string===>`, string);
try {

@@ -89,0 +90,0 @@ const encoder = (0, tiktoken_1.encoding_for_model)(model);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc