Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/pieces/community/ai/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-ai",
"version": "0.1.9",
"version": "0.1.10",
"type": "commonjs",
"main": "./src/index.js",
"types": "./src/index.d.ts",
Expand Down
67 changes: 54 additions & 13 deletions packages/pieces/community/ai/src/lib/actions/text/ask-ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ export const askAI = createAction({
props: async (propsValue) => {
const webSearchEnabled = propsValue['webSearch'] as unknown as boolean;
const provider = propsValue['provider'] as unknown as string;
const isOpenRouterProvider =
provider === AIProviderName.OPENROUTER ||
provider === AIProviderName.ACTIVEPIECES;
const supportsToolBasedWebSearch =
provider === AIProviderName.OPENAI ||
provider === AIProviderName.ANTHROPIC ||
provider === AIProviderName.GOOGLE;

if (!webSearchEnabled) {
return {};
Expand All @@ -61,17 +68,25 @@ export const askAI = createAction({
displayName: 'Max Web Search Uses',
required: false,
defaultValue: 5,
description: 'Maximum number of searches to use. Default is 5.',
}),
includeSources: Property.Checkbox({
displayName: 'Include Sources',
description:
'Whether to include the sources in the response. Useful for getting web search details (e.g. search queries, searched URLs, etc).',
required: false,
defaultValue: false,
description: isOpenRouterProvider
? 'For OpenRouter/Activepieces, this maps to OpenRouter web plugin max_results (1-10). Default is 5.'
: 'Maximum number of searches to use. Default is 5.',
}),
};

if (supportsToolBasedWebSearch) {
options = {
...options,
includeSources: Property.Checkbox({
displayName: 'Include Sources',
description:
'Whether to include the sources in the response. Useful for getting web search details (e.g. search queries, searched URLs, etc).',
required: false,
defaultValue: false,
}),
};
}

const userLocationOptions = {
userLocationCity: Property.ShortText({
displayName: 'User Location - City',
Expand Down Expand Up @@ -161,6 +176,11 @@ export const askAI = createAction({
const storage = context.store;
const webSearchOptions = context.propsValue.webSearchOptions as WebSearchOptions;

const isOpenRouterWebSearch =
context.propsValue.webSearch &&
(provider === AIProviderName.OPENROUTER ||
provider === AIProviderName.ACTIVEPIECES);

const model = await createAIModel({
provider: provider as AIProviderName,
modelId,
Expand All @@ -184,6 +204,28 @@ export const askAI = createAction({
}
}

const tools = !context.propsValue.webSearch || isOpenRouterWebSearch
? undefined
: createWebSearchTool(provider, webSearchOptions);

const stopWhen = tools
? stepCountIs(webSearchOptions?.maxUses ?? 5)
: undefined;

const providerOptions = isOpenRouterWebSearch
? {
openrouter: {
plugins: [{
id: 'web' as const,
max_results: Math.min(
Math.max(webSearchOptions?.maxUses ?? 5, 1),
10
),
}],
},
}
: undefined;

const response = await generateText({
model,
messages: [
Expand All @@ -195,10 +237,9 @@ export const askAI = createAction({
],
maxOutputTokens: context.propsValue.maxOutputTokens,
temperature: (context.propsValue.creativity ?? 100) / 100,
tools: context.propsValue.webSearch
? createWebSearchTool(provider, webSearchOptions)
: undefined,
stopWhen: stepCountIs(webSearchOptions?.maxUses ?? 5),
tools,
stopWhen,
providerOptions,
});

conversation?.push({
Expand All @@ -215,7 +256,7 @@ export const askAI = createAction({
await storage.put(conversationKey, conversation);
}

const includeSources = webSearchOptions.includeSources;
const includeSources = !isOpenRouterWebSearch && webSearchOptions.includeSources;
if (includeSources) {
return { text: response.text, sources: response.sources };
}
Expand Down
10 changes: 6 additions & 4 deletions packages/pieces/community/ai/src/lib/common/ai-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,18 @@ export async function createAIModel({
}
return provider.chatModel(modelId)
}
case AIProviderName.ACTIVEPIECES:
case AIProviderName.ACTIVEPIECES:
case AIProviderName.OPENROUTER: {
const provider = createOpenRouter({ apiKey: auth.apiKey })
return provider.chat(modelId) as LanguageModel
const openRouterProvider = createOpenRouter({ apiKey: auth.apiKey })
return openRouterProvider.chat(modelId) as LanguageModel
}
default:
throw new Error(`Provider ${provider} is not supported`)
}
}



export const anthropicSearchTool = anthropic.tools.webSearch_20250305;
export const openaiSearchTool = openai.tools.webSearchPreview;
export const googleSearchTool = google.tools.googleSearch;
Expand All @@ -168,4 +170,4 @@ const handleDefaultAiGatewayProvider = ({accountId, gatewayId, headers, isImage,
return provider.imageModel(modelId)
}
return provider.chatModel(modelId)
}
}
2 changes: 1 addition & 1 deletion packages/pieces/community/sftp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-sftp",
"version": "0.4.11",
"version": "0.5.0",
"dependencies": {
"basic-ftp": "5.0.5",
"ssh2-sftp-client": "9.1.0"
Expand Down
6 changes: 4 additions & 2 deletions packages/pieces/community/smtp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ export const smtpAuth = PieceAuth.CustomAuth({
}),
email: Property.ShortText({
displayName: 'Email',
required: true,
description: 'Leave blank if your mail relay does not require authentication.',
required: false,
}),
password: PieceAuth.SecretText({
displayName: 'Password',
required: true,
description: 'Leave blank if your mail relay does not require authentication.',
required: false,
}),
port: Property.StaticDropdown({
displayName: 'Port',
Expand Down
12 changes: 6 additions & 6 deletions packages/pieces/community/smtp/src/lib/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import nodemailer from 'nodemailer';

export const smtpCommon = {
constructConfig(auth: smtpAuthParams) {
const hasCredentials = auth.email && auth.password;
return {
host: auth.host,
port: auth.port,
requireTLS: auth.TLS,
auth: {
user: auth.email,
pass: auth.password,
},
...(hasCredentials
? { auth: { user: auth.email, pass: auth.password } }
: {}),
connectionTimeout: 60000,
secure: auth.port === 465,
};
Expand All @@ -23,8 +23,8 @@ export const smtpCommon = {

export type smtpAuthParams = {
host: string;
email: string;
password: string;
email?: string;
password?: string;
port: number;
TLS: boolean;
};
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ function DynamicValueToggle({
form.setValue(
`settings.propertySettings.${propertyName}`,
propertySettingsForSingleProperty,
{
shouldValidate: true,
},
);
}
function handleDynamicValueToggleChange(mode: PropertyExecutionType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type MultiSelectPiecePropertyProps = {
label: string;
}[];
onChange: (value: unknown[] | null) => void;
initialValues?: unknown[];
initialValues?: unknown;
disabled?: boolean;
showDeselect?: boolean;
showRefresh?: boolean;
Expand Down Expand Up @@ -60,16 +60,17 @@ const MultiSelectPieceProperty = ({
return option.label?.toLowerCase()?.includes(searchTerm?.toLowerCase());
});

const selectedIndicies = initialValues
? initialValues
.map((value) =>
[...cachedOptions, ...options].findIndex((option) =>
deepEqual(option.value, value),
),
)
.filter((index) => index > -1)
.map((index) => String(index))
: [];
const selectedIndicies =
initialValues && Array.isArray(initialValues)
? initialValues
.map((value) =>
[...cachedOptions, ...options].findIndex((option) =>
deepEqual(option.value, value),
),
)
.filter((index) => index > -1)
.map((index) => String(index))
: [];
const sendChanges = (indicides: string[]) => {
const newSelectedIndicies = indicides.filter(
(index) => index !== undefined,
Expand Down
Loading