Skip to content

Commit e058903

Browse files
committed
Merge branch 'main' into cezudas/OPS-3021-infrastructure
2 parents 5bac42d + 9b3ff93 commit e058903

18 files changed

Lines changed: 482 additions & 250 deletions

File tree

packages/blocks/ai/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createBlock } from '@openops/blocks-framework';
22
import { aiAuth } from '@openops/common';
33
import { BlockCategory } from '@openops/shared';
4-
import { askAi } from './lib/actions/askAi';
4+
import { aiStep } from './lib/actions/ai-step';
55

66
export const ai = createBlock({
77
displayName: 'AI',
@@ -10,6 +10,6 @@ export const ai = createBlock({
1010
minimumSupportedRelease: '0.7.1',
1111
logoUrl: 'https://static.openops.com/blocks/openops-ai.svg',
1212
authors: [],
13-
actions: [askAi],
13+
actions: [aiStep],
1414
triggers: [],
1515
});

packages/blocks/ai/src/lib/actions/askAi.ts renamed to packages/blocks/ai/src/lib/actions/ai-step.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import {
1313
import { AiProviderEnum, analysisLLMSchema } from '@openops/shared';
1414
import { generateObject, generateText } from 'ai';
1515

16-
export const askAi = createAction({
17-
displayName: 'Ask AI',
16+
export const aiStep = createAction({
17+
displayName: 'AI Step',
1818
description:
19-
'Ask AI a question or transform input using an LLM based on a prompt',
19+
'Transform an input into a desired output through an AI analysis',
2020
name: 'analyze',
2121
auth: aiAuth,
2222
isWriteAction: false,

packages/blocks/ai/test/askAi-action.test.ts renamed to packages/blocks/ai/test/ai-step-action.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ jest.mock('ai', () => ({
1313

1414
import { AiProviderEnum, analysisLLMSchema } from '@openops/shared';
1515
import { generateObject, generateText } from 'ai';
16-
import { askAi } from '../src/lib/actions/askAi';
16+
import { aiStep } from '../src/lib/actions/ai-step';
1717

1818
describe('analyze action', () => {
1919
beforeEach(() => {
2020
jest.clearAllMocks();
2121
});
2222

2323
test('should expose correct props', () => {
24-
expect(askAi.props).toMatchObject({
24+
expect(aiStep.props).toMatchObject({
2525
model: {
2626
type: 'DYNAMIC',
2727
displayName: 'Model',
@@ -59,7 +59,7 @@ describe('analyze action', () => {
5959

6060
const context = createContext(auth, { prompt: 'Hello' });
6161

62-
const result = await askAi.run(context as any);
62+
const result = await aiStep.run(context as any);
6363

6464
expect(generateObject).toHaveBeenCalledWith(
6565
expect.objectContaining({
@@ -100,7 +100,7 @@ describe('analyze action', () => {
100100
additionalInput: ['s1', 's2'],
101101
});
102102

103-
const result = await askAi.run(context as any);
103+
const result = await aiStep.run(context as any);
104104

105105
expect(generateObject).toHaveBeenCalledTimes(1);
106106
const args = (generateObject as jest.Mock).mock.calls[0][0];
@@ -134,7 +134,7 @@ describe('analyze action', () => {
134134

135135
const context = createContext(auth, { prompt: 'Hi' });
136136

137-
const result = await askAi.run(context as any);
137+
const result = await aiStep.run(context as any);
138138

139139
expect(getAiProviderLanguageModel).toHaveBeenCalledWith({
140140
provider: AiProviderEnum.OPENAI,
@@ -174,7 +174,7 @@ describe('analyze action', () => {
174174
model: { model: 'gpt-from-props' },
175175
});
176176

177-
const result = await askAi.run(context as any);
177+
const result = await aiStep.run(context as any);
178178

179179
expect(getAiProviderLanguageModel).toHaveBeenCalledWith({
180180
provider: AiProviderEnum.OPENAI,
@@ -217,7 +217,7 @@ describe('analyze action', () => {
217217
const context = createContext(auth, { prompt: 'P' });
218218

219219
isLLMTelemetryEnabled.mockReturnValueOnce(isLLMTelemetryEnabledValue);
220-
await askAi.run(context as any);
220+
await aiStep.run(context as any);
221221

222222
expect(generateObject).toHaveBeenCalledWith(
223223
expect.objectContaining({
@@ -247,7 +247,7 @@ describe('analyze action', () => {
247247

248248
const context = createContext(auth, { prompt: 'Q' });
249249

250-
const result = await askAi.run(context as any);
250+
const result = await aiStep.run(context as any);
251251

252252
expect(generateText).toHaveBeenCalledWith(
253253
expect.objectContaining({ model: 'lm', prompt: 'Q' }),

packages/openops/src/lib/cloud-cli-common.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ export function handleCliError({
1010
command: string;
1111
error: unknown;
1212
}): never {
13-
logger.error(`${provider} CLI execution failed.`, {
14-
command,
15-
error,
16-
});
13+
logger.error(
14+
`${provider} CLI execution failed.`,
15+
error instanceof Error
16+
? { command, error }
17+
: { command, errorMessage: error },
18+
);
1719

1820
const message = `An error occurred while running ${provider} CLI command: ${error}`;
1921

packages/openops/src/lib/command-wrapper.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ export async function executeFile(
4242

4343
async function getResult(childProcess: ChildProcess, fullCommand: string) {
4444
let stdout = '';
45-
let error = '';
45+
let errorMessage = '';
4646

4747
childProcess.stderr?.on('data', function (data) {
48-
error += data;
48+
errorMessage += data;
4949
});
5050

5151
childProcess.stdout?.on('data', (data) => {
@@ -62,13 +62,13 @@ async function getResult(childProcess: ChildProcess, fullCommand: string) {
6262
command: fullCommand,
6363
exitCode,
6464
stdout,
65-
error,
65+
errorMessage,
6666
});
6767

6868
return {
6969
exitCode: exitCode,
7070
stdOut: trimNewLines(stdout),
71-
stdError: trimNewLines(error),
71+
stdError: trimNewLines(errorMessage),
7272
};
7373
}
7474

packages/react-ui/public/locales/en/translation.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@
99
"+{remainingBlocksCount} more": "+{remainingBlocksCount} more",
1010
"General": "General",
1111
"Appearance": "Appearance",
12-
"AI": "AI",
12+
"OpenOps AI": "OpenOps AI",
1313
"No results found.": "No results found.",
1414
"Something went wrong": "Something went wrong",
1515
"If it's a persistant issue, please contact support with steps to reproduce and include any relevant error messages.": "If it's a persistant issue, please contact support with steps to reproduce and include any relevant error messages.",
1616
"Refresh Page": "Refresh Page",
1717
"Contact Support": "Contact Support",
18-
"AI Assistant": "AI Assistant",
19-
"OpenOps Assistant": "OpenOps Assistant",
20-
"OpenOps Agent": "OpenOps Agent",
21-
"Enable AI": "Enable AI",
18+
"Enable OpenOps AI": "Enable OpenOps AI",
2219
"Save": "Save",
2320
"Valid Connection": "Valid Connection",
2421
"Loading chat...": "Loading chat...",
@@ -31,6 +28,11 @@
3128
"AI Chat Error": "AI Chat Error",
3229
"There was an error while processing your request, please try again or open a new chat": "There was an error while processing your request, please try again or open a new chat",
3330
"There was an error creating the new chat, please try again": "There was an error creating the new chat, please try again",
31+
"Your network connection was lost. Please check your internet connection and try again.": "Your network connection was lost. Please check your internet connection and try again.",
32+
"Failed to delete chat. Please try again.": "Failed to delete chat. Please try again.",
33+
"Failed to rename chat. Please try again.": "Failed to rename chat. Please try again.",
34+
"OpenOps Assistant": "OpenOps Assistant",
35+
"OpenOps Agent": "OpenOps Agent",
3436
"MCP": "MCP",
3537
"AWS Cost": "AWS Cost",
3638
"Connection": "Connection",
@@ -434,7 +436,6 @@
434436
"The redirection works!": "The redirection works!",
435437
"You will be redirected in a few seconds.": "You will be redirected in a few seconds.",
436438
"Base URL is required for OpenAI-compatible providers": "Base URL is required for OpenAI-compatible providers",
437-
"AI providers": "AI providers",
438439
"Customize the appearance of the app. Automatically switch between day and night themes.": "Customize the appearance of the app. Automatically switch between day and night themes.",
439440
"Select the theme for the dashboard.": "Select the theme for the dashboard.",
440441
"Light": "Light",
@@ -460,6 +461,8 @@
460461
"It looks like AI hasn’t been configured in OpenOps yet.": "It looks like AI hasn’t been configured in OpenOps yet.",
461462
"Please go to ": "Please go to ",
462463
" to complete the setup.": " to complete the setup.",
464+
"Close history": "Close history",
465+
"Open history": "Open history",
463466
"New chat": "New chat",
464467
"Generating ...": "Generating ...",
465468
"Use code": "Use code",
@@ -469,7 +472,7 @@
469472
"AI Chat": "AI Chat",
470473
"Toggle AI Chat": "Toggle AI Chat",
471474
"How can I help you today?": "How can I help you today?",
472-
"The AI is taking a bit longer than expected. Please wait...": "The AI is taking a bit longer than expected. Please wait...",
475+
"Looks like your connection is a bit slow, this may cause delays in the AI responses.": "Looks like your connection is a bit slow, this may cause delays in the AI responses.",
473476
"Scroll to bottom": "Scroll to bottom",
474477
"Write a message...": "Write a message...",
475478
"Send": "Send",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FlagsMap } from '@/app/lib/flags-api';
22

3-
export const getFederatedUrlBasedOnFlags = (flags: FlagsMap) =>
4-
flags.FEDERATED_LOGIN_ENABLED
3+
export const getFederatedUrlBasedOnFlags = (flags?: FlagsMap) =>
4+
flags?.FEDERATED_LOGIN_ENABLED
55
? (flags.FRONTEGG_URL as string | undefined)
66
: undefined;

packages/react-ui/src/app/common/components/project-settings-layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const appearanceNavItem = {
2222
};
2323

2424
const aiNavItem = {
25-
title: t('AI'),
25+
title: t('OpenOps AI'),
2626
href: '/settings/ai',
2727
icon: <Sparkles size={iconSize} />,
2828
};

packages/react-ui/src/app/features/ai/ai-settings-form.tsx

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,32 +84,47 @@ const AiSettingsForm = ({
8484
});
8585
};
8686

87+
const descriptionText =
88+
'Enables OpenOps Assistant and other AI-powered features such as the CLI command generation.';
89+
8790
return (
8891
<Form {...form}>
89-
<form className="flex-1 flex flex-col gap-4 max-w-[516px]">
92+
<form className="flex-1 flex flex-col gap-4">
9093
<FormField
9194
control={form.control}
9295
name="enabled"
9396
render={({ field }) => (
94-
<FormItem className="flex gap-[6px]">
95-
<Switch
96-
id="enabled"
97-
checked={field.value}
98-
onCheckedChange={field.onChange}
99-
/>
100-
<Label htmlFor="enabled">{t('Enable AI')}</Label>
97+
<FormItem className="flex flex-col">
98+
<div className="flex items-center gap-[6px]">
99+
<Switch
100+
id="enabled"
101+
checked={field.value}
102+
onCheckedChange={field.onChange}
103+
/>
104+
<Label
105+
className="text-lg font-bold leading-6"
106+
htmlFor="enabled"
107+
>
108+
{t('Enable OpenOps AI')}
109+
</Label>
110+
</div>
111+
<p className="mt-8 text-base font-normal leading-6 text-primary-900">
112+
{descriptionText}
113+
</p>
101114
</FormItem>
102115
)}
103116
/>
104-
<ConnectionSelect
105-
disabled={!currentFormValue.enabled}
106-
allowDynamicValues={false}
107-
block={block}
108-
providerKey={'AI'}
109-
name={'connection'}
110-
/>
117+
<div className="max-w-[516px]">
118+
<ConnectionSelect
119+
disabled={!currentFormValue.enabled}
120+
allowDynamicValues={false}
121+
block={block}
122+
providerKey={'AI'}
123+
name={'connection'}
124+
/>
125+
</div>
111126

112-
<div className="flex items-center justify-between ">
127+
<div className="flex items-center justify-between max-w-[516px]">
113128
<div className="flex gap-2">
114129
<Button
115130
variant="outline"

packages/react-ui/src/app/features/builder/blocks-selector/block-selector-utils.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
Trigger,
1414
TriggerType,
1515
} from '@openops/shared';
16-
1716
import { createDefaultOptionSettings } from '../step-settings/split-settings/utils';
1817

1918
const defaultCode = `export const code = async (inputs) => {
@@ -37,13 +36,7 @@ const getStepName = (block: StepMetadata, flowVersion: FlowVersion) => {
3736
if (block.type === TriggerType.BLOCK) {
3837
return 'trigger';
3938
}
40-
const baseName = 'step_';
41-
let number = 1;
42-
const steps = flowHelper.getAllSteps(flowVersion.trigger);
43-
while (steps.some((step) => step.name === `${baseName}${number}`)) {
44-
number++;
45-
}
46-
return `${baseName}${number}`;
39+
return flowHelper.findAvailableStepName(flowVersion, 'step');
4740
};
4841

4942
const getDefaultStep = ({

0 commit comments

Comments
 (0)