mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-09-23 18:43:18 +08:00
fix: display default prompt in the schema drawer if general bot is selected
This commit is contained in:
@ -22,26 +22,20 @@ const SchemaDrawer = (props: Props) => {
|
|||||||
|
|
||||||
const getPrompt = async () => {
|
const getPrompt = async () => {
|
||||||
if (!currentConversation) return;
|
if (!currentConversation) return;
|
||||||
if (!connectionStore.currentConnectionCtx?.database) return;
|
|
||||||
const promptGenerator = getPromptGeneratorOfAssistant(getAssistantById(currentConversation.assistantId)!);
|
const promptGenerator = getPromptGeneratorOfAssistant(getAssistantById(currentConversation.assistantId)!);
|
||||||
let dbPrompt = promptGenerator();
|
let dbPrompt = promptGenerator();
|
||||||
const maxToken = getModel(settingStore.setting.openAIApiConfig?.model || "").max_token;
|
|
||||||
const schemaList = await connectionStore.getOrFetchDatabaseSchema(connectionStore.currentConnectionCtx?.database);
|
|
||||||
|
|
||||||
if (connectionStore.currentConnectionCtx?.database) {
|
if (connectionStore.currentConnectionCtx?.database) {
|
||||||
try {
|
const maxToken = getModel(settingStore.setting.openAIApiConfig?.model || "").max_token;
|
||||||
dbPrompt = generateDbPromptFromContext(
|
const schemaList = await connectionStore.getOrFetchDatabaseSchema(connectionStore.currentConnectionCtx?.database);
|
||||||
promptGenerator,
|
dbPrompt = generateDbPromptFromContext(
|
||||||
schemaList,
|
promptGenerator,
|
||||||
currentConversation.selectedSchemaName || "",
|
schemaList,
|
||||||
currentConversation.selectedTablesName || [],
|
currentConversation.selectedSchemaName || "",
|
||||||
maxToken
|
currentConversation.selectedTablesName || [],
|
||||||
);
|
maxToken
|
||||||
setPrompt(dbPrompt);
|
);
|
||||||
} catch (error: any) {
|
|
||||||
toast.error(error.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
setPrompt(dbPrompt);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Reference in New Issue
Block a user