Skip to content

Commit d861d1c

Browse files
authored
Merge branch 'main' into s3-widget-secure-paths-upload-fix
2 parents 4e4ba28 + 3090d71 commit d861d1c

37 files changed

Lines changed: 4083 additions & 3655 deletions

backend/src/ai-core/providers/langchain-bedrock.provider.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export class LangchainBedrockProvider implements IAIProvider {
185185
stream: AsyncIterable<AIMessageChunk>,
186186
): Promise<IterableReadableStream<AIStreamChunk>> {
187187
async function* generateChunks(): AsyncGenerator<AIStreamChunk> {
188-
let currentToolCalls: Map<number, AIToolCall> = new Map();
188+
let currentToolCalls: Map<number, { id: string; name: string; argsString: string }> = new Map();
189189

190190
for await (const chunk of stream) {
191191
if (chunk.tool_call_chunks && chunk.tool_call_chunks.length > 0) {
@@ -196,7 +196,7 @@ export class LangchainBedrockProvider implements IAIProvider {
196196
currentToolCalls.set(index, {
197197
id: toolCallChunk.id || '',
198198
name: toolCallChunk.name || '',
199-
arguments: {},
199+
argsString: '',
200200
});
201201
}
202202

@@ -209,12 +209,7 @@ export class LangchainBedrockProvider implements IAIProvider {
209209
currentCall.name = toolCallChunk.name;
210210
}
211211
if (toolCallChunk.args) {
212-
try {
213-
const parsedArgs = JSON.parse(toolCallChunk.args);
214-
currentCall.arguments = { ...currentCall.arguments, ...parsedArgs };
215-
} catch {
216-
// Accumulate partial JSON - will be parsed when complete
217-
}
212+
currentCall.argsString += toolCallChunk.args;
218213
}
219214
}
220215
}
@@ -231,11 +226,24 @@ export class LangchainBedrockProvider implements IAIProvider {
231226
}
232227
}
233228

234-
for (const toolCall of currentToolCalls.values()) {
235-
if (toolCall.name) {
229+
for (const toolCallData of currentToolCalls.values()) {
230+
if (toolCallData.name) {
231+
let parsedArgs: Record<string, unknown> = {};
232+
if (toolCallData.argsString) {
233+
try {
234+
parsedArgs = JSON.parse(toolCallData.argsString);
235+
} catch {
236+
// Failed to parse args, use empty object
237+
}
238+
}
239+
236240
yield {
237241
type: 'tool_call',
238-
toolCall,
242+
toolCall: {
243+
id: toolCallData.id,
244+
name: toolCallData.name,
245+
arguments: parsedArgs,
246+
},
239247
};
240248
}
241249
}

backend/src/ai-core/providers/langchain-openai.provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { getOptionalEnvVariable, getRequiredEnvVariable } from '../../helpers/ap
1818

1919
@Injectable()
2020
export class LangchainOpenAIProvider implements IAIProvider {
21-
private readonly defaultModelId = 'gpt-4o';
22-
private readonly responsesApiModel = 'gpt-4o';
21+
private readonly defaultModelId = 'gpt-5';
22+
private readonly responsesApiModel = 'gpt-5';
2323
private openaiClient: OpenAI;
2424

2525
constructor() {

backend/src/app.controller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { Controller, Get, Inject, UseInterceptors } from '@nestjs/common';
22
import { ApiTags } from '@nestjs/swagger';
33
import { UseCaseType } from './common/data-injection.tokens.js';
4+
import { Timeout } from './decorators/timeout.decorator.js';
45
import { InTransactionEnum } from './enums/index.js';
56
import { SentryInterceptor } from './interceptors/index.js';
67
import { IGetHello } from './use-cases-app/use-cases-app.interface.js';
78

89
@UseInterceptors(SentryInterceptor)
10+
@Timeout()
911
@Controller()
1012
@ApiTags('app')
1113
export class AppController {

backend/src/app.module.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
2-
import { APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
2+
import { APP_GUARD } from '@nestjs/core';
33
import { ScheduleModule } from '@nestjs/schedule';
44
import { ThrottlerGuard, ThrottlerModule } from '@nestjs/throttler';
55
import { AppController } from './app.controller.js';
@@ -36,7 +36,7 @@ import { UserActionModule } from './entities/user-actions/user-action.module.js'
3636
import { UserSecretModule } from './entities/user-secret/user-secret.module.js';
3737
import { SignInAuditModule } from './entities/user-sign-in-audit/sign-in-audit.module.js';
3838
import { TableWidgetModule } from './entities/widget/table-widget.module.js';
39-
import { TimeoutInterceptor } from './interceptors/index.js';
39+
4040
import { SaaSGatewayModule } from './microservices/gateways/saas-gateway.ts/saas-gateway.module.js';
4141
import { SaasModule } from './microservices/saas-microservice/saas.module.js';
4242
import { AppLoggerMiddleware } from './middlewares/logging-middleware/app-logger-middlewate.js';
@@ -101,10 +101,6 @@ import { DashboardWidgetModule } from './entities/visualizations/dashboard-widge
101101
],
102102
controllers: [AppController],
103103
providers: [
104-
{
105-
provide: APP_INTERCEPTOR,
106-
useClass: TimeoutInterceptor,
107-
},
108104
{
109105
provide: APP_GUARD,
110106
useClass: ThrottlerGuard,

backend/src/common/data-injection.tokens.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export enum UseCaseType {
158158
DELETE_API_KEY = 'DELETE_API_KEY',
159159

160160
REQUEST_INFO_FROM_TABLE_WITH_AI_V2 = 'REQUEST_INFO_FROM_TABLE_WITH_AI_V2',
161+
REQUEST_INFO_FROM_TABLE_WITH_AI_V3 = 'REQUEST_INFO_FROM_TABLE_WITH_AI_V3',
161162
REQUEST_AI_SETTINGS_AND_WIDGETS_CREATION = 'REQUEST_AI_SETTINGS_AND_WIDGETS_CREATION',
162163

163164
CREATE_TABLE_FILTERS = 'CREATE_TABLE_FILTERS',

backend/src/decorators/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export { BodyUuid } from './body-uuid.decorator.js';
77
export { QueryUuid } from './query-uuid.decorator.js';
88
export { BodyEmail } from './body-email.decorator.js';
99
export { QueryTableName } from './query-table-name.decorator.js';
10+
export { Timeout, TIMEOUT_KEY, TimeoutDefaults } from './timeout.decorator.js';
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { SetMetadata, applyDecorators, UseInterceptors } from '@nestjs/common';
2+
import { TimeoutInterceptor } from '../interceptors/timeout.interceptor.js';
3+
4+
export const TIMEOUT_KEY = 'custom_timeout';
5+
6+
export const TimeoutDefaults = {
7+
DEFAULT: 15000,
8+
DEFAULT_TEST: 200000,
9+
EXTENDED: 60000,
10+
EXTENDED_TEST: 300000,
11+
AI: 300000,
12+
AI_TEST: 600000,
13+
} as const;
14+
15+
export function Timeout(timeoutMs?: number): MethodDecorator & ClassDecorator {
16+
return applyDecorators(SetMetadata(TIMEOUT_KEY, timeoutMs), UseInterceptors(TimeoutInterceptor));
17+
}

backend/src/entities/ai/ai.module.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { UserEntity } from '../user/user.entity.js';
88
import { AiService } from './ai.service.js';
99
import { RequestAISettingsAndWidgetsCreationUseCase } from './use-cases/request-ai-settings-and-widgets-creation.use.case.js';
1010
import { RequestInfoFromTableWithAIUseCaseV5 } from './use-cases/request-info-from-table-with-ai-v5.use.case.js';
11+
import { RequestInfoFromTableWithAIUseCaseV6 } from './use-cases/request-info-from-table-with-ai-v6.use.case.js';
1112
import { UserAIRequestsControllerV2 } from './user-ai-requests-v2.controller.js';
1213

1314
@Global()
@@ -22,6 +23,10 @@ import { UserAIRequestsControllerV2 } from './user-ai-requests-v2.controller.js'
2223
provide: UseCaseType.REQUEST_INFO_FROM_TABLE_WITH_AI_V2,
2324
useClass: RequestInfoFromTableWithAIUseCaseV5,
2425
},
26+
{
27+
provide: UseCaseType.REQUEST_INFO_FROM_TABLE_WITH_AI_V3,
28+
useClass: RequestInfoFromTableWithAIUseCaseV6,
29+
},
2530
{
2631
provide: UseCaseType.REQUEST_AI_SETTINGS_AND_WIDGETS_CREATION,
2732
useClass: RequestAISettingsAndWidgetsCreationUseCase,
@@ -37,6 +42,7 @@ export class AIModule implements NestModule {
3742
.apply(AuthMiddleware)
3843
.forRoutes(
3944
{ path: '/ai/v2/request/:connectionId', method: RequestMethod.POST },
45+
{ path: '/ai/v3/request/:connectionId', method: RequestMethod.POST },
4046
{ path: '/ai/v2/setup/:connectionId', method: RequestMethod.GET },
4147
);
4248
}

backend/src/entities/ai/use-cases/request-info-from-table-with-ai-v5.use.case.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class RequestInfoFromTableWithAIUseCaseV5
3333
extends AbstractUseCase<RequestInfoFromTableDSV2, void>
3434
implements IRequestInfoFromTableV2
3535
{
36-
private readonly maxDepth: number = 5;
36+
private readonly maxDepth: number = 10;
3737

3838
constructor(
3939
@Inject(BaseType.GLOBAL_DB_CONTEXT)

0 commit comments

Comments
 (0)