Skip to content
Open
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
100 changes: 100 additions & 0 deletions app/client/src/ce/actions/aiAssistantActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import type { ReduxAction } from "actions/ReduxActionTypes";
import { ReduxActionTypes } from "ee/constants/ReduxActionConstants";

export interface AIMessage {
role: "user" | "assistant";
content: string;
timestamp: number;
}

export interface UpdateAISettingsPayload {
provider?: string;
hasApiKey?: boolean;
isEnabled?: boolean;
}

export const updateAISettings = (
payload: UpdateAISettingsPayload,
): ReduxAction<UpdateAISettingsPayload> => ({
type: ReduxActionTypes.UPDATE_AI_SETTINGS,
payload,
});

export interface FetchAIResponsePayload {
prompt: string;
context?: {
functionName?: string;
cursorLineNumber?: number;
functionString?: string;
mode?: string;
currentValue?: string;
entityId?: string;
};
}

export const fetchAIResponse = (
payload: FetchAIResponsePayload,
): ReduxAction<FetchAIResponsePayload> => ({
type: ReduxActionTypes.FETCH_AI_RESPONSE,
payload,
});

export const fetchAIResponseSuccess = (payload: {
response: string;
}): ReduxAction<{ response: string }> => ({
type: ReduxActionTypes.FETCH_AI_RESPONSE_SUCCESS,
payload,
});

export const fetchAIResponseError = (payload: {
error: string;
}): ReduxAction<{ error: string }> => ({
type: ReduxActionTypes.FETCH_AI_RESPONSE_ERROR,
payload,
});

export const loadAISettings = (): ReduxAction<undefined> => ({
type: ReduxActionTypes.LOAD_AI_SETTINGS,
payload: undefined,
});

export const clearAIResponse = (): ReduxAction<undefined> => ({
type: ReduxActionTypes.CLEAR_AI_RESPONSE,
payload: undefined,
});

export const openAIPanel = (): ReduxAction<undefined> => ({
type: ReduxActionTypes.OPEN_AI_PANEL,
payload: undefined,
});

export const closeAIPanel = (): ReduxAction<undefined> => ({
type: ReduxActionTypes.CLOSE_AI_PANEL,
payload: undefined,
});

export interface AIEditorContextPayload {
functionName?: string;
cursorLineNumber?: number;
functionString?: string;
mode?: string;
currentValue?: string;
editorId?: string;
entityName?: string;
entityId?: string;
propertyPath?: string;
}

export const updateAIContext = (
context: AIEditorContextPayload,
): ReduxAction<{ context: AIEditorContextPayload }> => ({
type: ReduxActionTypes.UPDATE_AI_CONTEXT,
payload: { context },
});

export const openAIPanelWithContext = (
context: AIEditorContextPayload,
): ReduxAction<{ context: AIEditorContextPayload }> => ({
type: ReduxActionTypes.OPEN_AI_PANEL_WITH_CONTEXT,
payload: { context },
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface AISidePanelProps {
onClose: () => void;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function AISidePanel(_props: AISidePanelProps) {
return null;
}
2 changes: 2 additions & 0 deletions app/client/src/ce/components/editorComponents/GPT/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import type { EntityNavigationData } from "entities/DataTree/dataTreeTypes";
import React from "react";
import type CodeMirror from "codemirror";

export { AISidePanel } from "./AISidePanel";

export type AIEditorContext = Partial<{
functionName: string;
cursorLineNumber: number;
Expand Down
10 changes: 9 additions & 1 deletion app/client/src/ce/components/editorComponents/GPT/trigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ import type { EntityTypeValue } from "ee/entities/DataTree/types";

export const APPSMITH_AI = "Appsmith AI";

export function isAIEnabled(ff: FeatureFlags, mode: TEditorModes) {
export function isAISupportedMode(mode: TEditorModes) {
return false;
}

export function isAIEnabled(
ff: FeatureFlags,
mode: TEditorModes,
hasApiKey?: boolean,
) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function GlobalAISidePanel() {
return null;
}
9 changes: 9 additions & 0 deletions app/client/src/ce/constants/ReduxActionConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,15 @@ const OneClickBindingActionTypes = {
const AIActionTypes = {
UPDATE_AI_CONTEXT: "UPDATE_AI_CONTEXT",
UPDATE_AI_TRIGGERED: "UPDATE_AI_TRIGGERED",
UPDATE_AI_SETTINGS: "UPDATE_AI_SETTINGS",
LOAD_AI_SETTINGS: "LOAD_AI_SETTINGS",
FETCH_AI_RESPONSE: "FETCH_AI_RESPONSE",
FETCH_AI_RESPONSE_SUCCESS: "FETCH_AI_RESPONSE_SUCCESS",
FETCH_AI_RESPONSE_ERROR: "FETCH_AI_RESPONSE_ERROR",
CLEAR_AI_RESPONSE: "CLEAR_AI_RESPONSE",
OPEN_AI_PANEL: "OPEN_AI_PANEL",
CLOSE_AI_PANEL: "CLOSE_AI_PANEL",
OPEN_AI_PANEL_WITH_CONTEXT: "OPEN_AI_PANEL_WITH_CONTEXT",
};

const PlatformActionErrorTypes = {
Expand Down
47 changes: 47 additions & 0 deletions app/client/src/ce/selectors/aiAssistantSelectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type { DefaultRootState } from "react-redux";

export function getAIAssistantState(state: DefaultRootState) {
return undefined;
}

export function getHasAIApiKey(_state: DefaultRootState): boolean {
return false;
}

export function getAIProvider(_state: DefaultRootState): string | undefined {
return undefined;
}

export function getIsAILoading(_state: DefaultRootState): boolean {
return false;
}

export function getAIMessages(_state: DefaultRootState): never[] {
return [];
}

export function getAILastResponse(
_state: DefaultRootState,
): string | undefined {
return undefined;
}

export function getAIError(_state: DefaultRootState): string | undefined {
return undefined;
}

export function getIsAIEnabled(_state: DefaultRootState): boolean {
return false;
}

export function getIsAIConfigLoaded(_state: DefaultRootState): boolean {
return false;
}

export function getIsAIPanelOpen(_state: DefaultRootState): boolean {
return false;
}

export function getAIEditorContext(_state: DefaultRootState): null {
return null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ export const generateQuickCommands = (
displayText: APPSMITH_AI,
shortcut: Shortcuts.ASK_AI,
triggerCompletionsPostPick: true,
isBeta: true,
action: () => {
executeCommand({
actionType: SlashCommand.ASK_AI,
Expand Down
Loading
Loading