Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SKaplanOfficial committed Jul 18, 2023
1 parent b0487eb commit 488ccd7
Show file tree
Hide file tree
Showing 14 changed files with 193 additions and 105 deletions.
109 changes: 63 additions & 46 deletions DEVLOG.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,73 @@
# PromptLab DevLog - A More Detailed ChangeLog

## v1.1.1 Release

### 2023-07-17

- Added Dialog Window command response view
- Fixed bug where list and grid output views would fail to display any content due to condensing of symbols
- Fixed bug where command-specific temperature settings would not be applied
- Fixed bug where old-style URL placeholders using HTTP instead of HTTPS would not be processed.

## v1.1.0 Release

### 2023-07-15

- Fixed bug where event/reminder placeholders require both event and reminder permissions, even if only one is used

### 2023-06-27

- Added advanced settings JSON file & integration throughout the extension
- Control which actions are available in the action menu
- Control default command/model/chat settings
- Control placeholder processing
- Control which actions are available in the action menu
- Control default command/model/chat settings
- Control placeholder processing

### 2023-06-25

- Added setting for specifying additional custom placeholder file paths
- Added placeholder detection when writing prompts + information about detected placeholders in the prompt info box.
- Added support for Orion browser.
- Added action to copy command ID.
- PromptLab command placeholders can now use the command ID instead of the command name.
- URL placeholders now support `raw` parameter to return the raw HTML instead of the visible text.
- Added support for Orion browser
- Added action to copy command ID
- PromptLab command placeholders can now use the command ID instead of the command name
- URL placeholders now support `raw` parameter to return the raw HTML instead of the visible text
- Moved many scripts into the `scripts` folder as `.scpt` files -- more efficient + easier to edit
- Switched command QuickLinks to use command IDs. Name-based QuickLinks are still supported.

### 2023-06-24

- Added conditional prompting using filetype placeholders
- {{images:...}} - Content (including other placeholders) will only be evaluated if there is at least on selected image files
- Other file categories: {{textfiles:...}}, {{videos:...}}, {{audio:...}}
- For image, text, audio, and video file extensions, use {{ext:...}} to single out a specific file extension, e.g. {{svg:...}} or {{mov:...}}
- Also supports {{pdf:...}}
- Conditional prompting have other placeholders nested inside them, e.g. {{images:{{url:https://www.example.com}}}}
- Inner placeholders will only be evaluated if the condition is met (e.g. if there is at least one image file)
- {{images:...}} - Content (including other placeholders) will only be evaluated if there is at least on selected image files
- Other file categories: {{textfiles:...}}, {{videos:...}}, {{audio:...}}
- For image, text, audio, and video file extensions, use {{ext:...}} to single out a specific file extension, e.g. {{svg:...}} or {{mov:...}}
- Also supports {{pdf:...}}
- Conditional prompting have other placeholders nested inside them, e.g. {{images:{{url:<https://www.example.com}}}}>
- Inner placeholders will only be evaluated if the condition is met (e.g. if there is at least one image file)
- Added Custom Placeholders stored in supportPath/custom_placeholders.json
- Added action to edit the custom placeholders file
- Added Placeholders Guide and an action to open it
- Added automatic detection of placeholders in prompts
- If a placeholder is detected, the info box for the prompt will show the detected placeholder, its description, and an example
- If a placeholder is detected, the info box for the prompt will show the detected placeholder, its description, and an example

### 2023-06-22

- Redesigned the placeholders system to be more efficient and more versatile
- Added several new placeholders
- {{day locale="en-US"}} - Returns the name of the current day of the week
- {{jxa:...}} - Run a JXA script and return the output
- {{shortcuts}} - List of names of all Siri Shortcuts
- {{shortcut:shortcutName:input}} - Run a Siri Shortcut with the given input and return the output
- {{uuid}} - Generate a UUID
- {{usedUUIDs}} - List of all UUIDs generated via the {{uuid}} placeholder thus far
- Expanded functionality of many placeholders by adding support for optional customizations
- {{date format="d MMMM, YYYY"}} - Added optional format parameter
- {{time format="h:mm a"}} - Added optional format parameter
- Expanded persistent variable support with new directives
- {{set x:y}} - Set the persistent variable x to y
- {{get x}} - Get the value of the persistent variable x
- {{reset x}} - Reset the persistent variable x to its initial value
- {{delete x}} - Delete the persistent variable x
- {{vars}} - List of stored persistent variable names
- Now using bulkApply strategy that uses memoization to improve performance, especially when using multiple placeholders in a single command
- Added several new placeholders
- {{day locale="en-US"}} - Returns the name of the current day of the week
- {{jxa:...}} - Run a JXA script and return the output
- {{shortcuts}} - List of names of all Siri Shortcuts
- {{shortcut:shortcutName:input}} - Run a Siri Shortcut with the given input and return the output
- {{uuid}} - Generate a UUID
- {{usedUUIDs}} - List of all UUIDs generated via the {{uuid}} placeholder thus far
- Expanded functionality of many placeholders by adding support for optional customizations
- {{date format="d MMMM, YYYY"}} - Added optional format parameter
- {{time format="h:mm a"}} - Added optional format parameter
- Expanded persistent variable support with new directives
- {{set x:y}} - Set the persistent variable x to y
- {{get x}} - Get the value of the persistent variable x
- {{reset x}} - Reset the persistent variable x to its initial value
- {{delete x}} - Delete the persistent variable x
- {{vars}} - List of stored persistent variable names
- Now using bulkApply strategy that uses memoization to improve performance, especially when using multiple placeholders in a single command
- Added settings for displaying icons & icon colors in menu bar menu
- Added settings for displaying core PromptLab commands in menu bar menu
- Added settings for displaying favorites & categories in menu bar menu
Expand All @@ -64,7 +79,9 @@
- Added option to show a command in the menu bar menu
- Added option to speak responses
- Added {{prompt:text}} placeholder


## v1.0.0 Release

### 2023-05-17

#### v1.1.0
Expand All @@ -76,7 +93,7 @@
- Added ability to delete chats individually or in bulk
- Added chat statistics
- Added {{nearbyLocations:searchTerm}} placeholder
- Returns a list of nearby location addresses matching the search term
- Returns a list of nearby location addresses matching the search term

#### v1.0.0

Expand Down Expand Up @@ -107,15 +124,15 @@
- Fixed bug where commands whose acceptedFileExtensions fields were empty would yield an error
- Fixed bug where the `{input}` placeholder in model schemas was not provided when in a chat view

## 2023-05-12
### 2023-05-12

- Added setting to group commands by category
- Added setting for prompt length limit
- Added setting for export location to use when exporting all commands
- Added previousCommand, previousPrompt, and previousResponse placeholders
- Added {{youtube:URL}} and {{youtube:searchTerm}} placeholders
- Both placeholders will return the transcript of the first matching video result
- Transcript text is limited to the configured prompt length limit
- Both placeholders will return the transcript of the first matching video result
- Transcript text is limited to the configured prompt length limit
- Fixed allocation error when analyzing images with a dimension < 100px
- Fixed bug where placeholder replacements were run multiple times
- Fixed bug where no-view commands would not pop to root view after being run
Expand All @@ -137,9 +154,9 @@
### 2023-04-23

- Added "Allow AI To Run Commands" checkbox in chat views
- The AI will run other PromptLab commands to fulfil the user's request
- The AI will run other PromptLab commands to fulfil the user's request
- Removed "Allow AI To Control Computer" checkbox in chat views, at least for now
- It was too unreliable, and the commands approach is more understandable to users
- It was too unreliable, and the commands approach is more understandable to users

### 2023-04-21

Expand All @@ -156,8 +173,8 @@
- Added syntax highlighting to action script blocks
- Updated PromptLab Chat command to use the new CommandChatView component
- Added customizable base prompt for the PromptLab Chat command (see the command's settings)
- Also added a setting for using selected files as context by default
- Also added a setting for using conversation history as context by default
- Also added a setting for using selected files as context by default
- Also added a setting for using conversation history as context by default
- Added command placeholders
- Fixed bug where only the initially selected files where recognized when using "Use Selected Files As Context" in Chat response views

Expand All @@ -174,13 +191,13 @@

- Added saliency analysis option in the create command form
- Adjusted names of PromptLab's built-in commands
- `Create PromptLab Command` --> `New PromptLab Command`
- `Search PromptLab Commands` --> `My PromptLab Commands`
- `Create PromptLab Command` --> `New PromptLab Command`
- `Search PromptLab Commands` --> `My PromptLab Commands`
- Added `{basePrompt}` and `{prompt}` placeholders for custom model JSON schemas
- `{basePrompt}` is the prompt before any user input (but still including placeholder substitutions)
- `{prompt}` is the full prompt after any user input
- `{basePrompt}` is the prompt before any user input (but still including placeholder substitutions)
- `{prompt}` is the full prompt after any user input
- Adjusted behavior of `{input}` placeholder for custom model JSON schemas
- Now, the placeholder is replaced with the input text/select file contents, instead of the entire prompt. Use `{prompt}` to get the entire prompt instead.
- Now, the placeholder is replaced with the input text/select file contents, instead of the entire prompt. Use `{prompt}` to get the entire prompt instead.
- Added support for asynchronous output from custom model endpoints
- Fixed bug where Quicklink commands were unable to reference the current application and thus prevented several placeholder substitutions from working
- Fixed error when trying to run `Search PromptLab Commands` command without any commands saved`
- Fixed error when trying to run `Search PromptLab Commands` command without any commands saved`
2 changes: 1 addition & 1 deletion assets/scripts/ImageFeatureExtractor.scpt
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ on run (argv)
end if
end try

imageData's setValue:promptText forKey:"output"
imageData's setValue:promptText forKey:"stringValue"

set jsonObj to current application's NSJSONSerialization's dataWithJSONObject:imageData options:(current application's NSJSONWritingFragmentsAllowed) |error|:(missing value)
set jsonString to current application's NSString's alloc()'s initWithData:jsonObj encoding:(current application's NSUTF8StringEncoding)
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/PDFTextExtractor.scpt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ on run (argv)
" & (thePDF's documentAttributes()'s description() as text)
end if

pdfData's setValue:pdfText forKey:"imageText"
pdfData's setValue:pdfText forKey:"stringValue"

set pageCount to thePDF's pageCount()
pdfData's setValue:pageCount forKey:"pageCount"
Expand Down
1 change: 1 addition & 0 deletions src/components/Commands/CommandForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ export default function CommandForm(props: {
<Form.Dropdown.Item title="List" value="list" icon={Icon.List} />
<Form.Dropdown.Item title="Grid" value="grid" icon={Icon.Message} />
<Form.Dropdown.Item title="Chat" value="chat" icon={Icon.Message} />
<Form.Dropdown.Item title="Dialog Window" value="dialogWindow" icon={Icon.List} />
</Form.Dropdown>
) : null}

Expand Down
12 changes: 8 additions & 4 deletions src/components/Commands/CommandResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useModels } from "../../hooks/useModels";
import CommandSetupForm from "./CommandSetupForm";
import SpeechInputView from "./SpeechInputView";
import { useFiles } from "../../hooks/useFiles";
import { showDialog } from "../../utils/scripts";

export default function CommandResponse(props: {
commandName: string;
Expand Down Expand Up @@ -60,10 +61,10 @@ export default function CommandResponse(props: {
Promise.resolve(runReplacements(prompt, context, [commandName], options)).then((subbedPrompt) => {
if (options.outputKind == "list" && subbedPrompt.trim().length > 0) {
subbedPrompt +=
"<Format the output as a single list with each item separated by '~~~'. Do not provide any other commentary, headings, or data.>";
"\n\n<Format the output as a single list with each item separated by '~~~'. Do not provide any other commentary, headings, or data.>";
} else if (options.outputKind == "grid" && subbedPrompt.trim().length > 0) {
subbedPrompt +=
"<Format the output as a single list with each item separated by '~~~'. At the start of each item, put an object emoji or person emoji that represents that item followed by '$$$'. Do not provide any other commentary, headings, or data.>";
"\n\n<Format the output as a single list with each item separated by '~~~'. At the start of each item, put an object emoji or person emoji that represents that item followed by '$$$'. Do not provide any other commentary, headings, or data.>";
}

setSubstitutedPrompt(subbedPrompt);
Expand Down Expand Up @@ -112,6 +113,9 @@ export default function CommandResponse(props: {

// Update previous command placeholders
if (!loadingData && !loading && !isLoading && data.length) {
if (options.outputKind == "dialogWindow") {
Promise.resolve(showDialog(commandName, text));
}
setPreviousCommand(commandName);
setPreviousResponse(text);
setPreviousPrompt(fullPrompt);
Expand Down Expand Up @@ -159,8 +163,8 @@ export default function CommandResponse(props: {
}

// Don't show the response if the user has disabled it
if (options.showResponse == false || (!loadingData && substitutedPrompt == "")) {
if (options.showResponse == false) {
if (options.showResponse == false || options.outputKind == "dialogWindow" || (!loadingData && substitutedPrompt == "")) {
if (options.showResponse == false || options.outputKind == "dialogWindow") {
Promise.resolve(showHUD(`Running '${commandName}'...`));
}

Expand Down
2 changes: 1 addition & 1 deletion src/data/default-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ export const defaultCommands = {
useSubjectClassification: false,
outputKind: "detail",
prompt:
"Provide a weather report based on the following forecast data for the next 7 days in {{location}}: ###{{weather}}###\n\nDiscuss how this might affect my events over the next week. Consider the purpose and type of each event. My events are: ###{{weekEvents}}###",
"Provide a weather report based on the following forecast data for the next 7 days in {{location}}: ###{{weekWeather}}###\n\nDiscuss how this might affect my events over the next week. Consider the purpose and type of each event. My events are: ###{{weekEvents}}###",
icon: "cloud-sun-16",
useSoundClassification: false,
useRectangleDetection: false,
Expand Down
1 change: 0 additions & 1 deletion src/data/file-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ export const textFileExtensions = [
"hsc",
"htm",
"html",
"http",
"hxx",
"hy",
"icl",
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const addPDFDetails = async (
) => {
const preferences = getPreferenceValues<ExtensionPreferences>();
const pdfText = await ScriptRunner.PDFTextExtractor(filepath, preferences.pdfOCR, 3, options.useMetadata || false);
currentData.contents += filterString(pdfText.imageText);
currentData.contents += filterString(pdfText.stringValue);
currentData["pdfRawText"] = filterString(pdfText.pdfRawText);
currentData["pdfOCRText"] = filterString(pdfText.pdfOCRText);
};
Expand Down Expand Up @@ -276,7 +276,7 @@ const addAudioDetails = async (
currentData["audioTranscription"] = audioDetails;
} else if (options.useSubjectClassification) {
const audioClassifications = await getAudioDetails(filepath);
currentData.contents += audioClassifications.contents;
currentData.contents += audioClassifications.stringValue;
currentData["soundClassifications"] = audioClassifications.soundClassifications;
}
};
Expand All @@ -287,7 +287,7 @@ const addImageDetails = async (
options: CommandOptions
) => {
const imageDetails = await getImageDetails(filepath, options);
const imageVisionInstructions = filterString(imageDetails.output);
const imageVisionInstructions = filterString(imageDetails.stringValue);
currentData.contents += imageVisionInstructions;
Object.assign(currentData, imageDetails);
};
Expand Down
8 changes: 3 additions & 5 deletions src/hooks/useModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@ export default function useModel(
targetModel.endpoint == "" ||
(models.isLoading && !modelOverride && preferenceModel.endpoint == "");

const temp = modelOverride
? parseFloat(targetModel.temperature)
: preferences.includeTemperature
? parseFloat(temperature) || 1.0
const temp = preferences.includeTemperature
? parseFloat(temperature) == undefined ? 1.0 : parseFloat(temperature)
: 1.0;

// Get the value at the specified key path
Expand Down Expand Up @@ -153,7 +151,7 @@ export default function useModel(
: input.replaceAll(/[\n\r\s]+/g, " ").replaceAll('"', '\\"') + preferences.promptSuffix
)
);
if (preferences.includeTemperature || modelOverride) {
if (preferences.includeTemperature) {
modelSchema["temperature"] = temp;
}

Expand Down
6 changes: 3 additions & 3 deletions src/utils/context-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ export const filterString = (str: string, cutoff?: number): string => {
if (preferences.condenseAmount == "high") {
// Remove some useful characters for the sake of brevity
return str
.replaceAll(/[^A-Za-z0-9,.?!\-'()/[\]{}@: \n\r<>]/g, "")
.replaceAll(/[^A-Za-z0-9,.?!\-'()/[\]{}@: ~\n\r<>]/g, "")
.replaceAll('"', "'")
.substring(0, cutoff || parseInt(preferences.lengthLimit) + 500 || 3000);
} else if (preferences.condenseAmount == "medium") {
// Remove uncommon characters
return str
.replaceAll(/[^A-Za-z0-9,.?!\-'()/[\]{}@: \n\r<>+*&|]/g, "")
.replaceAll(/[^A-Za-z0-9,.?!\-'()/[\]{}@: ~\n\r<>+*&|]/g, "")
.replaceAll('"', "'")
.substring(0, cutoff || parseInt(preferences.lengthLimit) + 500 || 3000);
} else if (preferences.condenseAmount == "low") {
// Remove all characters except for letters, numbers, and punctuation
return str
.replaceAll(/[^A-Za-z0-9,.?!\-'()/[\]{}@:; \n\r\t<>%^$~+*_&|]/g, "")
.replaceAll(/[^A-Za-z0-9,.?!\-'()/[\]{}@:; ~\n\r\t<>%^$~+*_&|]/g, "")
.replaceAll('"', "'")
.substring(0, cutoff || parseInt(preferences.lengthLimit) + 500 || 3000);
} else {
Expand Down
Loading

0 comments on commit 488ccd7

Please sign in to comment.