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
  • Loading branch information
Logende committed Jan 22, 2025
1 parent 43085fb commit b3aa369
Showing 1 changed file with 33 additions and 1 deletion.
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,14 @@ function queryDocumentQuestion(
): Promise<string> {
return queryDataQuestion(apiKey, prompt, currentData, schema);
}
function isSchemaEmpty() {
return _.isEmpty(getDataForMode(SessionMode.SchemaEditor).data.value)
}
</script>

<template>
<AiPromptsTemplate
<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 +45,30 @@ 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 b3aa369

Please sign in to comment.