Skip to content

Commit

Permalink
in data editor, show message and block ai prompt if no schema defined (
Browse files Browse the repository at this point in the history
…#598)

* in data editor, show message and block ai prompt if no schema defined

* apply formatting changes

---------

Co-authored-by: Logende <[email protected]>
  • Loading branch information
Logende and Logende authored Jan 22, 2025
1 parent 43085fb commit 0cc8d77
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import AiPromptsTemplate from '@/components/panels/ai-prompts/AiPromptsTemplate.vue';
import {queryDataConversion, queryDataModification, queryDataQuestion} from '@/utility/openai';
import {SessionMode} from '@/store/sessionMode';
import {getDataForMode} from '@/data/useDataLink';
import _ from 'lodash';
import ApiKey from '@/components/panels/ai-prompts/ApiKey.vue';
import Divider from 'primevue/divider';
function queryDocumentCreation(apiKey: string, prompt: string, schema: string): Promise<string> {
return queryDataConversion(apiKey, prompt, schema);
Expand All @@ -24,10 +28,15 @@ function queryDocumentQuestion(
): Promise<string> {
return queryDataQuestion(apiKey, prompt, currentData, schema);
}
function isSchemaEmpty() {
return _.isEmpty(getDataForMode(SessionMode.SchemaEditor).data.value);
}
</script>

<template>
<AiPromptsTemplate
v-if="!isSchemaEmpty()"
:session-mode="SessionMode.DataEditor"
default-text-create-document="Enter or describe your Data in any format"
default-text-modify-document="How do you want your Data to be modified?"
Expand All @@ -37,6 +46,29 @@ function queryDocumentQuestion(
:function-query-document-creation="queryDocumentCreation"
:function-query-document-modification="queryDocumentModification"
:function-query-document-question="queryDocumentQuestion" />
<div v-else>
<ApiKey class="api-key-top" />
<Divider />

<label class="heading">AI Prompts</label>
<span>
Before using the AI prompts to generate data, please create or select a schema in the Schema
Editor tab.
</span>
</div>
</template>

<style scoped></style>

<style scoped>
.heading {
font-size: 24px; /* Make the text bigger */
font-weight: bold; /* Make the text bold */
text-align: center; /* Center the text horizontally */
display: block; /* Ensure the label behaves like a block element */
margin-bottom: 10px; /* Add some space below the label */
}
.api-key-top {
margin-bottom: auto;
}
</style>

0 comments on commit 0cc8d77

Please sign in to comment.