Creating an app from human text
In this example we will demionstrate our tsql-app custom trained GPT tha knows the tsql-app framework and can create a functional app from human text.
Prompt to TSQL.APP GPT:
Please create a script where I can input my name (in @name) and when I click a button, a text file must be download to me with the name "message from tracy.txt" and the content of the file must be: hello to {@name}
Response:
Certainly! I'll create a script using the TSQL.APP framework to accomplish this task. Here's a script that will allow you to input your name, and when you click a button, it will generate a text file for download with the specified content.
Resulting APP:
Generated code:
DECLARE @Name NVARCHAR(100)
DECLARE @ButtonPressed NVARCHAR(100)
DECLARE @FileContent NVARCHAR(MAX)
DECLARE @FileName NVARCHAR(100)
-- Get the current value of @Name from the modal (if it exists)
EXEC sp_api_modal_get_value @name='@Name', @value=@Name OUT
-- Create an input field for the name
EXEC sp_api_modal_input @name='@Name', @value=@Name OUT, @placeholder='Enter your name'
-- Create a button to trigger the file download
EXEC sp_api_modal_button @name='@DownloadButton', @value='Download File', @valueout=@ButtonPressed OUT
if @ButtonPressed is null return
exec sp_api_toast @ButtonPressed
-- Check if the button was pressed
IF @ButtonPressed = 'Download File'
BEGIN
-- Prepare the file content
SET @FileContent = N'hello to ' + ISNULL(@Name, 'friend')
-- Set the file name
SET @FileName = 'message from tracy.txt'
DECLARE @d varbinary(max)=CAST(@FileContent AS VARBINARY(MAX))
-- Generate the file for download
EXEC sp_api_modal_download
@filename = @FileName,
@mimetype = 'text/plain',
@rawdata = @d
-- Display a confirmation message
EXEC sp_api_modal_text @text='File has been prepared for download.'
END