-
-
- Copilot
-
-
- {
- inputEdited.current = true;
- setShowSamplePrompts(true);
- }}
- onKeyDown={(e) => {
- if (e.key === "Enter") {
- inputEdited.current = true;
- startGenerateQueryProcess();
- }
- }}
- style={{ lineHeight: 30 }}
- styles={{ root: { width: "95%" } }}
- disabled={isGeneratingQuery}
- autoComplete="off"
- />
- {copilotTeachingBubbleVisible && (
-
- Write a prompt here and Copilot will generate the query for you. You can also choose from our{" "}
- {
- setShowSamplePrompts(true);
- toggleCopilotTeachingBubbleVisible();
- }}
- style={{ color: "white", fontWeight: 600 }}
- >
- sample prompts
- {" "}
- or write your own query
-
- )}
- startGenerateQueryProcess()}
- />
- {isGeneratingQuery && }
- {showSamplePrompts && (
- setShowSamplePrompts(false)}
- directionalHintFixed={true}
- directionalHint={DirectionalHint.bottomLeftEdge}
- alignTargetEdge={true}
- gapSpace={4}
- >
-
- {filteredHistories?.length > 0 && (
-
-
- Recent
-
- {filteredHistories.map((history, i) => (
- {
- setUserPrompt(history);
- setShowSamplePrompts(false);
- inputEdited.current = true;
- }}
- onRenderIcon={() => }
- styles={promptStyles}
- >
- {history}
-
- ))}
-
- )}
- {filteredSuggestedPrompts?.length > 0 && (
-
-
- Suggested Prompts
-
- {filteredSuggestedPrompts.map((prompt) => (
- {
- setUserPrompt(prompt.text);
- setShowSamplePrompts(false);
- inputEdited.current = true;
- }}
- onRenderIcon={() => }
- styles={promptStyles}
- >
- {prompt.text}
-
- ))}
-
- )}
- {(filteredHistories?.length > 0 || filteredSuggestedPrompts?.length > 0) && (
-
-
-
- Learn about{" "}
-
- writing effective prompts
-
-
-
- )}
-
-
- )}
-
-
-
-
- AI-generated content can have mistakes. Make sure it's accurate and appropriate before using it.{" "}
-
- Read preview terms
-
- {showErrorMessageBar && (
-
- We ran into an error and were not able to execute query.
-
- )}
- {showInvalidQueryMessageBar && (
-
- We were unable to generate a query based upon the prompt provided. Please modify the prompt and try
- again. For examples of how to write a good prompt, please read
-
- this article.
- {" "}
- Our content guidelines can be found
-
- here.
-
-
- )}
-
-
-
- {showFeedbackBar && (
-
- Provide feedback on the query generated
- {showCallout && !hideFeedbackModalForLikedQueries && (
- {
- setShowCallout(false);
- SubmitFeedback({
- params: {
- generatedQuery: generatedQuery,
- likeQuery: likeQuery,
- description: "",
- userPrompt: userPrompt,
- },
- explorer: explorer,
- });
- }}
- directionalHint={DirectionalHint.topCenter}
- >
-
- Thank you. Need to give{" "}
- {
- setShowCallout(false);
- useQueryCopilot.getState().openFeedbackModal(generatedQuery, true, userPrompt);
- }}
- >
- more feedback?
-
-
-
- )}
- {
- setShowCallout(!likeQuery);
- setLikeQuery(!likeQuery);
- if (dislikeQuery) {
- setDislikeQuery(!dislikeQuery);
- }
- }}
- />
- {
- if (!dislikeQuery) {
- useQueryCopilot.getState().openFeedbackModal(generatedQuery, false, userPrompt);
- setLikeQuery(false);
- }
- setDislikeQuery(!dislikeQuery);
- setShowCallout(false);
- }}
- />
-
-
- Copy code
-
- {
- setShowDeletePopup(true);
- }}
- iconProps={{ iconName: "Delete" }}
- style={{ margin: "0 10px", backgroundColor: "#FFF8F0", transition: "background-color 0.3s ease" }}
- >
- Delete code
-
-
+ {copilotActive && (
+
)}
-
= ({ explorer }: Query
-
- {isSamplePromptsOpen && }
- {query !== "" && query.trim().length !== 0 && (
-
- )}
-
);
diff --git a/src/Explorer/QueryCopilot/Shared/QueryCopilotClient.ts b/src/Explorer/QueryCopilot/Shared/QueryCopilotClient.ts
index 3074e7ac1..9c9f1de61 100644
--- a/src/Explorer/QueryCopilot/Shared/QueryCopilotClient.ts
+++ b/src/Explorer/QueryCopilot/Shared/QueryCopilotClient.ts
@@ -21,6 +21,7 @@ import { userContext } from "UserContext";
import { queryPagesUntilContentPresent } from "Utils/QueryUtils";
import { useQueryCopilot } from "hooks/useQueryCopilot";
import { useTabs } from "hooks/useTabs";
+import * as StringUtility from "../../../Shared/StringUtility";
export const SendQueryRequest = async ({
userPrompt,
@@ -184,15 +185,20 @@ export const QueryDocumentsPerPage = async (
correlationId: useQueryCopilot.getState().correlationId,
});
} catch (error) {
+ const isCopilotActive = StringUtility.toBoolean(
+ localStorage.getItem(`${userContext.databaseAccount?.id}-queryCopilotToggleStatus`),
+ );
const errorMessage = getErrorMessage(error);
traceFailure(Action.ExecuteQueryGeneratedFromQueryCopilot, {
correlationId: useQueryCopilot.getState().correlationId,
errorMessage: errorMessage,
});
- useQueryCopilot.getState().setErrorMessage(errorMessage);
handleError(errorMessage, "executeQueryCopilotTab");
useTabs.getState().setIsQueryErrorThrown(true);
- useQueryCopilot.getState().setShowErrorMessageBar(true);
+ if (isCopilotActive) {
+ useQueryCopilot.getState().setErrorMessage(errorMessage);
+ useQueryCopilot.getState().setShowErrorMessageBar(true);
+ }
} finally {
useQueryCopilot.getState().setIsExecuting(false);
useTabs.getState().setIsTabExecuting(false);
diff --git a/src/Explorer/QueryCopilot/__snapshots__/QueryCopilotTab.test.tsx.snap b/src/Explorer/QueryCopilot/__snapshots__/QueryCopilotTab.test.tsx.snap
index 3ef6c1eab..64f5be5a8 100644
--- a/src/Explorer/QueryCopilot/__snapshots__/QueryCopilotTab.test.tsx.snap
+++ b/src/Explorer/QueryCopilot/__snapshots__/QueryCopilotTab.test.tsx.snap
@@ -5,7 +5,6 @@ exports[`Query copilot tab snapshot test should render with initial input 1`] =
className="tab-pane"
style={
Object {
- "padding": 24,
"width": "100%",
}
}
@@ -18,103 +17,6 @@ exports[`Query copilot tab snapshot test should render with initial input 1`] =
}
}
>
-