Skip to content

Commit

Permalink
Merge pull request #30904 from appsmithorg/feat/knowledge-retrieval-a…
Browse files Browse the repository at this point in the history
…ppsmith-ai

feat: Add knowledge retrieval in Appsmith AI
  • Loading branch information
trishaanand authored Feb 5, 2024
2 parents 6037a63 + f8f6b76 commit b66cd24
Show file tree
Hide file tree
Showing 45 changed files with 1,179 additions and 165 deletions.
31 changes: 31 additions & 0 deletions app/client/src/api/PluginApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { AxiosPromise } from "axios";
import type { ApiResponse } from "api/ApiResponses";
import type { PluginPackageName, PluginType } from "entities/Action";
import type { DependencyMap } from "utils/DynamicBindingUtils";
import { FILE_UPLOAD_TRIGGER_TIMEOUT_MS } from "@appsmith/constants/ApiConstants";

export type PluginId = string;
export type GenerateCRUDEnabledPluginMap = Record<PluginId, PluginPackageName>;
Expand Down Expand Up @@ -84,6 +85,36 @@ class PluginsApi extends Api {
> {
return Api.get(PluginsApi.url + `/default/icons`);
}

static async uploadFiles(
pluginId: string,
files: File[],
params?: Record<string, any>,
): Promise<AxiosPromise<ApiResponse>> {
const url = this.dynamicTriggerURLForInternalPlugins(pluginId);
const formData = new FormData();
files.forEach((file) => {
formData.append("files", file);
});

if (params) {
Object.keys(params).forEach((key) => {
formData.append(key, params[key]);
});
}

return Api.post(
url,
formData,
{},
{
headers: {
"Content-Type": "multipart/form-data",
},
timeout: FILE_UPLOAD_TRIGGER_TIMEOUT_MS,
},
);
}
}

export default PluginsApi;
1 change: 1 addition & 0 deletions app/client/src/ce/constants/ApiConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const DEFAULT_ACTION_TIMEOUT = 10000;
export const DEFAULT_EXECUTE_ACTION_TIMEOUT_MS = 15000;
export const DEFAULT_TEST_DATA_SOURCE_TIMEOUT_MS = 30000;
export const DEFAULT_APPSMITH_AI_QUERY_TIMEOUT_MS = 60000;
export const FILE_UPLOAD_TRIGGER_TIMEOUT_MS = 60000;

export enum API_STATUS_CODES {
REQUEST_NOT_AUTHORISED = 401,
Expand Down
1 change: 1 addition & 0 deletions app/client/src/ce/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1937,6 +1937,7 @@ export const CLOSE_SIDEBAR_MESSAGE = () => `Close sidebar`;
// Datasource/New query
export const NEW_QUERY_BUTTON_TEXT = () => "New query";
export const NEW_API_BUTTON_TEXT = () => "New API";
export const NEW_AI_BUTTON_TEXT = () => "New AI Query";
export const GENERATE_NEW_PAGE_BUTTON_TEXT = () => "Generate new page";
export const RECONNECT_BUTTON_TEXT = () => "Reconnect";
export const SAVE_BUTTON_TEXT = () => "Save";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
generateCreateNewDSOption,
isMatching,
SEARCH_ITEM_TYPES,
appsmithAIActionOperation,
} from "./utils";
import { PluginType } from "entities/Action";
import { integrationEditorURL } from "@appsmith/RouteBuilder";
Expand Down Expand Up @@ -57,7 +56,6 @@ export const useFilteredFileOperations = ({
const { appWideDS = [], otherDS = [] } = useAppWideAndOtherDatasource();
const plugins = useSelector(getPlugins);
const moduleOptions = useModuleOptions();
const showAppsmithAIQuery = useFeatureFlag(FEATURE_FLAG.ab_appsmith_ai_query);
const workflowOptions = useWorkflowOptions();

// helper map for sorting based on recent usage
Expand Down Expand Up @@ -92,7 +90,6 @@ export const useFilteredFileOperations = ({
plugins,
recentlyUsedDSMap,
query,
showAppsmithAIQuery,
});
};

Expand All @@ -104,7 +101,6 @@ export const useFilteredAndSortedFileOperations = ({
plugins = [],
query,
recentlyUsedDSMap = {},
showAppsmithAIQuery = false,
workflowOptions = [],
}: {
allDatasources?: Datasource[];
Expand All @@ -115,17 +111,11 @@ export const useFilteredAndSortedFileOperations = ({
query: string;
recentlyUsedDSMap?: Record<string, number>;
workflowOptions?: ActionOperation[];
showAppsmithAIQuery?: boolean;
}) => {
const fileOperations: ActionOperation[] = [];

if (!canCreateActions) return fileOperations;

// Add appsmith AI operation if the feature flag is enabled
const allActionOperations = showAppsmithAIQuery
? [...actionOperations, appsmithAIActionOperation]
: actionOperations;

// Add Workflow operations
if (workflowOptions.length > 0) {
workflowOptions.map((workflowOp) => fileOperations.push(workflowOp));
Expand All @@ -135,7 +125,7 @@ export const useFilteredAndSortedFileOperations = ({
* Work around to get the rest api cloud image.
* We don't have it store as a svg
*/
const actionOps = updateActionOperations(plugins, allActionOperations);
const actionOps = updateActionOperations(plugins, actionOperations);

// Add JS Object operation
fileOperations.push(actionOps[2]);
Expand Down
21 changes: 0 additions & 21 deletions app/client/src/components/editorComponents/GlobalSearch/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { getPluginByPackageName } from "@appsmith/selectors/entitiesSelector";
import type { AppState } from "@appsmith/reducers";
import WidgetFactory from "WidgetProvider/factory";
import {
AppsmithAIIcon,
CurlIconV2,
EntityIcon,
GraphQLIconV2,
Expand Down Expand Up @@ -272,26 +271,6 @@ export interface ActionOperation {
entityExplorerTitle?: string;
}

export const appsmithAIActionOperation: ActionOperation = {
title: "New Appsmith AI Query",
entityExplorerTitle: "Appsmith AI",
desc: "Create an Appsmith AI Query",
icon: <AppsmithAIIcon />,
kind: SEARCH_ITEM_TYPES.actionOperation,
action: (
entityId: string,
location: EventLocation,
entityType?: ActionParentEntityTypeInterface,
) =>
createNewAPIBasedOnParentEntity(
entityId,
location,
PluginPackageName.APPSMITH_AI,
entityType,
),
focusEntityType: FocusEntity.API,
};

export const actionOperations: ActionOperation[] = [
{
title: "New blank API",
Expand Down
1 change: 1 addition & 0 deletions app/client/src/components/formControls/DropDownControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ function renderDropdown(
return (
<Option
aria-label={option.label}
disabled={option.disabled}
isDisabled={option.isDisabled}
key={option.value}
value={option.value}
Expand Down
Loading

0 comments on commit b66cd24

Please sign in to comment.