()
| 21 | const [prompt, setPrompt] = useState<string>(""); |
| 22 | |
| 23 | const getPrompt = async () => { |
| 24 | if (!currentConversation) return; |
| 25 | const promptGenerator = getPromptGeneratorOfAssistant(getAssistantById(currentConversation.assistantId)!); |
| 26 | let dbPrompt = promptGenerator(); |
| 27 | if (connectionStore.currentConnectionCtx?.database) { |
| 28 | const schemaList = await connectionStore.getOrFetchDatabaseSchema(connectionStore.currentConnectionCtx?.database); |
| 29 | dbPrompt = generateDbPromptFromContext( |
| 30 | promptGenerator, |
| 31 | connectionStore.currentConnectionCtx.connection.engineType, |
| 32 | schemaList, |
| 33 | currentConversation.selectedSchemaName || "", |
| 34 | currentConversation.selectedTableNameList || [], |
| 35 | maxToken |
| 36 | ); |
| 37 | } |
| 38 | setPrompt(dbPrompt); |
| 39 | }; |
| 40 | |
| 41 | useEffect(() => { |
| 42 | // TODO: initial state with current conversation. |
no test coverage detected