Tweak generation
This commit is contained in:
parent
741c7154e1
commit
09f6bf2379
|
@ -105,6 +105,7 @@
|
|||
bind:expanded
|
||||
on:collapse={rejectSuggestion}
|
||||
readonly={!!suggestedCode}
|
||||
{expandedOnly}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -8,14 +8,18 @@
|
|||
export let onSubmit: (_prompt: string) => Promise<void>
|
||||
export let placeholder: string = ""
|
||||
export let expanded: boolean = false
|
||||
export let expandedOnly: boolean = false
|
||||
export let readonly: boolean = false
|
||||
export let value: string = ""
|
||||
export const submit = onPromptSubmit
|
||||
|
||||
$: expanded = expandedOnly || expanded
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
let promptInput: HTMLInputElement
|
||||
let buttonElement: HTMLButtonElement
|
||||
let promptLoading = false
|
||||
let promptText = ""
|
||||
let switchOnAIModal: Modal
|
||||
let addCreditsModal: Modal
|
||||
|
||||
|
@ -24,13 +28,13 @@
|
|||
$: aiEnabled = $auth?.user?.llm
|
||||
|
||||
$: creditsExceeded = $licensing.aiCreditsExceeded
|
||||
$: disabled = !aiEnabled || creditsExceeded || readonly
|
||||
$: disabled = !aiEnabled || creditsExceeded || readonly || promptLoading
|
||||
$: animateBorder = !disabled && expanded
|
||||
|
||||
function collapse() {
|
||||
dispatch("collapse")
|
||||
expanded = false
|
||||
promptText = ""
|
||||
expanded = expandedOnly
|
||||
value = ""
|
||||
animateBorder = false
|
||||
}
|
||||
|
||||
|
@ -63,7 +67,7 @@
|
|||
}
|
||||
promptLoading = true
|
||||
try {
|
||||
await onSubmit(promptText)
|
||||
await onSubmit(value)
|
||||
} finally {
|
||||
promptLoading = false
|
||||
}
|
||||
|
@ -95,7 +99,7 @@
|
|||
<input
|
||||
type="text"
|
||||
bind:this={promptInput}
|
||||
bind:value={promptText}
|
||||
bind:value
|
||||
class="prompt-input"
|
||||
{placeholder}
|
||||
on:keydown={handleKeyPress}
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
import { auth, licensing } from "@/stores/portal"
|
||||
import { ActionButton } from "@budibase/bbui"
|
||||
|
||||
let promptText = ""
|
||||
let aiInput: AiInput
|
||||
|
||||
$: isEnabled = $auth?.user?.llm && !$licensing.aiCreditsExceeded
|
||||
|
||||
async function submitPrompt(message: string) {
|
||||
|
@ -14,6 +17,8 @@
|
|||
<div class="ai-generation">
|
||||
<div class="ai-generation-prompt">
|
||||
<AiInput
|
||||
bind:this={aiInput}
|
||||
bind:value={promptText}
|
||||
placeholder="Generate data using AI..."
|
||||
onSubmit={submitPrompt}
|
||||
expandedOnly
|
||||
|
@ -22,8 +27,11 @@
|
|||
<div class="ai-generation-examples">
|
||||
{#if isEnabled}
|
||||
{#each ["Create a table called tickets with title, description, status fields", "Create a table called students with name and address fields"] as prompt}
|
||||
<ActionButton on:click={() => submitPrompt(prompt)}
|
||||
>{prompt}</ActionButton
|
||||
<ActionButton
|
||||
on:click={async () => {
|
||||
promptText = prompt
|
||||
await aiInput.submit()
|
||||
}}>{prompt}</ActionButton
|
||||
>
|
||||
{/each}
|
||||
{/if}
|
||||
|
|
Loading…
Reference in New Issue