Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
afadingthought authored Feb 12, 2024
1 parent 4e2a32e commit f370044
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
55 changes: 42 additions & 13 deletions Kiki/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3211,6 +3211,8 @@ end tell</string>
<false/>
<key>focusedappvariablename</key>
<string></string>
<key>keyword</key>
<string>km</string>
</dict>
<key>type</key>
<string>alfred.workflow.trigger.snippet</string>
Expand Down Expand Up @@ -5110,8 +5112,6 @@ resultString;</string>
<string>4</string>
<key>kikiSplit4</key>
<string>-</string>
<key>theText</key>
<string>{query}</string>
</dict>
</dict>
<key>type</key>
Expand Down Expand Up @@ -5289,8 +5289,6 @@ resultString;</string>
<string>4</string>
<key>kikiSplit4</key>
<string>customPrompt</string>
<key>theText</key>
<string>{query}</string>
</dict>
</dict>
<key>type</key>
Expand Down Expand Up @@ -5440,8 +5438,6 @@ resultString;</string>
<string>4</string>
<key>kikiSplit4</key>
<string>useAsPrompt</string>
<key>theText</key>
<string>{query}</string>
</dict>
</dict>
<key>type</key>
Expand Down Expand Up @@ -5625,7 +5621,15 @@ resultString;</string>
<key>readme</key>
<string># Kiki
**AI-Powered Chat &amp; Text Tools**
![](assets/images/kiki.png)
*[*Features Overview Video*](https://youtu.be/fB0YwMdkumQ)*
*[*Setup &amp; Walkthrough Video*](https://youtu.be/nbYF9pyQyqc)*
---
## INTRODUCTION
Kiki is an AI utility to interact with OpenAI Chat GPT and OpenRouter LLM models. It is specifically designed with the following features in mind:
Expand All @@ -5651,8 +5655,10 @@ Kiki is an AI utility to interact with OpenAI Chat GPT and OpenRouter LLM models
**OPTIONAL.** To utilize the Markdown Chat feature, ensure that your text editor copies selected text as markdown, rather than as formatted rich text.
*Note: ‘Jq’ is necessary for Kiki to correctly format requests through OpenAI or OpenRouter APIs. In Terminal, simply run `brew install jq`. If you do not have [Homebrew](https://brew.sh/) in your system, you may need to install that first in order to install ‘jq’.*
---
## SETUP
**The workflow’s configuration was prepared so that you:**
1. Enter either an OpenRouter or OpenAI API Token.
2. If you plan to use OpenRouter exclusively, remember to change the default Model to an Open Router model.
Expand All @@ -5666,9 +5672,11 @@ Kiki is an AI utility to interact with OpenAI Chat GPT and OpenRouter LLM models
4. **MD Chat Pattern ID.** If you use a text editor that supports Markdown, you may need to change this to another character. For example, I use [Bear](https://bear.app/), which supports organization through tags, so my Pattern ID is "#". The purpose of this setting will become clearer as you read through this documentation.
All the other options allow you to further customize Kiki according to your personal needs. However, the default settings should suffice for most use cases. If you ever need to reconfigure the workflow, simply right-click on the workflow's name in Alfred and select "Configure...".
---
## HOW TO
Kiki is powerful, flexible, and offers extensive customization options. It’s easy to get lost with everything it can do. To simplify this guide, I will categorize its features and modes of use into basic, intermediate, and advanced levels. If you find that the basic level meets your requirements, there's no need to feel overwhelmed by all the additional options.
---
## BASIC
### Keywords
Expand All @@ -5684,27 +5692,35 @@ Kiki is powerful, flexible, and offers extensive customization options. It’s e
![](assets/images/screenshot04.jpg)
---
### Tips
* In a chat, text preset, or even in the popup dialogs, you can **use the contents of your clipboard with the placeholder** set during configuration.
* Alfred's command bar does not support multi-line input (it does support multi-line pasting). However, **if you need to enter a line break in your chat through dialogs, press OPT + RETURN.**
* When you have initiated a chat through dialogs, you can press escape to close. **Press continue or return with an empty reply to quickly copy the last response received.**
* Accidentally closed a dialog? **You can resume your last chat** either from the Kiki options menu, or by pressing and holding CTRL when initiating a chat with the "kc" keyword.
* For a convenient way to initiate a simple and quick chat, **you can add Kiki as a fallback search within Alfred.** This allows you to start a chat without the need to type a keyword. To setup Kiki as a Fallback search in Alfred go to Features &gt; Default Results &gt; Setup fallback results (all the way to the bottom). Look for workflow trigger. Keep in mind that using this method means you won't have access to modifier options.
---
### Modifiers
When using Kiki, you can have more options in your interactions by holding down different modifiers while initiating a chat or preset from Alfred's command bar. Here's a simple breakdown of what each modifier does:
![](assets/images/screenshot05.jpg)
- **CMD:** This allows you to use an alternative model and, if configured, an alternative system role.
- **OPT:** By holding OPT, you can paste the response directly into your frontmost window instead of displaying it in a dialog.
- **CTRL:** When using CTRL, the existing context file will not be reset. Keep in mind that if the number of existing messages in the file exceeds the threshold set in the workflow's configuration, the oldest message will be removed.
- **SHIFT:** This modifier triggers Kiki to reply in a dialog. It is the default way Kiki answers chats or presets initiated from Alfred's command bar. As we will learn soon, this "default" may change.
- **FN:** Holding FN allows you to get Kiki's answer below your selected text. This option is only available when using Kiki on selected text through a universal action, hotkey, snippet, or external trigger.
---
### Universal Actions on Text
Select text and trigger your hotkey for Alfred's Universal Actions. Search for "Kiki" to be presented with some options for what to do with the selected text. In this mode, Kiki will automatically paste the result. If you want to customize this behavior, you can do so using modifiers once Alfred's command bar appears, as explained above.
![](assets/images/screenshot06.jpg)
*NOTE: the "Send to Chat" option won't present you with Alfred's bar, essentially being the only action that will always replace your selected text.*
---
### Custom Triggers
Kiki provides various options for triggering chats, presets, actions, or menus, in addition to using Alfred keywords. You can zoom out with CMD &amp; “-“ in the workflow editor to see them clearly. These options are color-coded as follows:
* **Yellow-colored hotkeys** are the most basic and perform the same actions as the Kiki keywords.
Expand All @@ -5724,8 +5740,9 @@ The chat feature is quick and convenient, but you can save even more time by usi
5. **JSON is very flexible with special characters,** but if you want to include a `"` quotation mark in your prompts, you need to escape it by adding a `\` before it. It's best to avoid using slashes `/` and backslashes `\` in your prompts unless you are familiar with their specific usage in JSON format. For instance, I use `\n` to indicate a line break. Additionally, keep in mind that the placeholder `[[txt]]` will be replaced with your actual input when using your preset.
6. **If you're unsure about your formatting or if a preset isn't appearing in your list, you can ask Kiki to fix any JSON formatting issues for you 😀️**.
*Note: We will talk more settings for presets in the advanced section, when we talk about presets for Mardown chat.*
*Note: We will talk more settings for presets in the advanced section, when we talk about presets for Markdown chat.*
---
### Resuming Chats from Context Files
**Kiki is designed to handle one chat at a time.** When you start a new chat, the previous context file is replaced, unless you specify otherwise. However, you can still pause a chat and resume it later, allowing for multiple conversations.
Expand All @@ -5745,7 +5762,9 @@ Here are a few things to keep in mind:
- OPT to resume your chat from within the Markdown Chat feature. Do not use this modifier until you learn how this feature works.
![](assets/images/screenshot07.jpg)
*Note: When you resume chats using Alfred's Universal Action, your previous messages and system role will be retained, but all other settings will be based on Kiki's default configuration. For maximum flexibility, it is recommended to use the Markdown Chat feature.*
---
## ADVANCED
### Markdown Chat
Expand Down Expand Up @@ -5773,6 +5792,7 @@ If your Mac automatically joins the hyphens when typing them as in the image, yo
![](assets/images/screenshot09.jpg)
![](assets/images/screenshot10.jpg)
*My recommendation is that you either setup your notes you start with the header already there, or that you create a snippet within Alfred to insert the header for you.*
**To make the most of the Markdown Chat feature, it's important to understand how Kiki prioritizes different formatting within your text:**
Expand All @@ -5791,7 +5811,7 @@ And simply continue with a Markdown Chat in a completely blank note, or after in
But there’s more! You can use presets to configure the settings in which the Markdown Chat will prepare your AI Request.
**Markdown Chat Presets**
### Markdown Chat Presets
Kiki will recognize presets or commands for your conversation within the header of your note. These will override the default settings in Kiki's workflow. **To trigger these presets and commands, they must be preceded by a whitespace and include the correct identifier.** Here are the available options:
* M_&lt;id&gt;: sets the model to be used. Models are read from the models.json file in your presets folder. The model ID must include "M_".
* S_&lt;id&gt;: sets the system role or persona to be used. You can define your own system roles in the systems.json file in your presets folder. The system ID must include "S_".
Expand All @@ -5810,12 +5830,13 @@ Oh, and remember when we talked about custom text presets? You can also use most
*Note: Notice that you cannot directly set the context limit as a parameter when creating text presets. Instead, you need to define this within the workflow configuration. You can always override this setting when triggering a text preset by holding down the CTRL key, or by using the parameter specified in the header of a Markdown Chat.*
**Resume Chats from within a Markdown Chat**
### Resume Chats from within a Markdown Chat
If your markdown text editor allows you to include media and files on your notes, you can use Alfred's Universal Actions to trigger "Kiki Resume Chat" on an attached context file. To resume your chat within your Markdown Chat instead of a dialog, hold the OPT modifier key while selecting the option. Kiki will then read the conversation settings from your note header.
![](assets/images/screenshot15.jpg)
*Note: As a helpful tip, you can save time by setting your most frequently used header parameter combinations as Alfred snippets.*
---
## FOR AUTOMATION NINJAS
In Kiki, there is a feature that can greatly enhance efficiency and productivity for users who want to make the most out of their system. This feature involves external triggers, which can be activated using AppleScript or Alfred's URL handler. By utilizing these triggers, you can access almost all of Kiki's functions from other third-party apps that can run Applescripts or even from other workflows.
Expand All @@ -5830,6 +5851,7 @@ The simplest external triggers in Kiki are "kikiWorkflow" and "kikiChat". These
- filesOpenContext: This will open your current context file in your system's default JSON file editor.
- filesRevealPath: This will reveal your Kiki data directory in Finder.
---
### The All-in-One Trigger
There is one external trigger which can replace a lot of your hotkeys, universal action triggers, snippet triggers, and it can even replace the use of Alfred’s command bar for text presets. This is the “kikiActions” trigger.
Expand All @@ -5838,9 +5860,10 @@ There is one external trigger which can replace a lot of your hotkeys, universal
**The All-in-One Trigger in Kiki receives four arguments, which should be entered without spaces and separated by commas.** Let's break down what each argument means:
1. **The first argument can be either "menu" or "direct."** This determines whether the user will be directed to the Kiki Text Presets menu or if a specific preset will be processed directly.
2. **The second argument can be "copy," "snippet," or "custom."**
2. **The second argument can be "copy," "snippet," "incoming," or "custom."**
- If "copy" is chosen, it assumes that the user has selected text and wants to run it through the text presets menu or process it with a preset. If you use “copy” and there’s no text selected, Kiki will use whatever there is already in your clipboard 😉.
- Using "snippet" triggers the CTRL + SHIFT + A shortcut, which selects text up to the previous line break. The selected text is then run through the text presets menu or directly processed with a preset.
- If the second argument is defined as "incoming," Kiki will grab the user's current clipboard content and will use it as the input for the workflow. This option is particularly useful for users to create their own Universal Actions to directly trigger their own custom presets—since Alfred's Universal Actions place whatever text is selected on user's clipboard.
- Choosing "custom" means that no input is required initially. The user will be presented with Alfred's command bar to type an input something for either the text presets menu or an already-selected preset.
3. **The third argument must be a number from the list of modifiers below.** This argument simulates a modifier or modifier combinations within Alfred's command bar. By using this, you can skip the command bar entirely and still have control over the multiple processing options available with Kiki.
4. **The fourth argument refers is the ID of your text preset.** This argument is optional and must only be included if the first argument is "direct.”
Expand All @@ -5863,20 +5886,26 @@ There is one external trigger which can replace a lot of your hotkeys, universal
15. **Command + Control + Shift.** Continue in dialog, do not reset context, and use the alternative chat model.
16. **Command + Control + FN.** Insert below, do not reset context, and use the alternative chat model.
---
### Preset-Specific Triggers
**To make it easier to understand how to use the "kikiActions" trigger, let's create a snippet that allows us to trigger one of our text presets from outside Kiki's workflow.** This is useful because if you add more snippets or hotkeys within Kiki, they may be replaced if there is an update for the workflow.
1. Open the Alfred workflow editor and click the "+" button in the bottom bar. Select "Blank Workflow" and give it a name. Click "Create."
2. Right-click on the blank canvas and select "Trigger," then choose "Snippet." Enter your keyword and save.
3. Go back to Kiki and double-click on the "kikiActions" external trigger. Copy all the text in the Sample Code area.
4. Return to your newly created workflow and right-click on the canvas. Select "Actions," then "Run Script." In the "Language" dropdown, choose the option with AppleScript.
5. Paste the code you copied into the Script area. Replace "text" with your desired arguments. For example, you can use "direct,snippet,4,emojify." "Emojify" is one of the text presets and snippets already included, but you can replace it with the ID of your custom preset.
![](assets/images/screenshot19.jpg)
6. By using these arguments, you are telling Kiki to skip the menu, directly grab the text from since the last line break, replace the selected text (as if using the modifiers from option 4), and run the text preset "emojify." If you want the result in a dialog instead of pasted in the frontmost window, you would use "direct,snippet,1,emojify" instead.
7. Connect the snippet block to your script block, and now you have a preset-specific trigger! Test it in your text editor.
7. Connect the snippet block to your script block, and now you have a preset-specific trigger! Test it in your text editor.
![](assets/images/screenshot18.jpg)
---
### My Karabiner Setup for Kiki
The "kikiActions" trigger provides endless possibilities when combined with custom text presets. To run Kiki, I personally use [Karabiner-Elements](https://karabiner-elements.pqrs.org/) the most. Karabiner is a powerful tool that allows you to remap and customize your keyboard, enabling you to trigger scripts, open apps, and more. I have set up a virtual layer on my keyboard specifically for Kiki where. If you're familiar with Karabiner and [Goku](https://github.com/yqrashawn/GokuRakuJoudo), you can refer to my EDN file configuration [here](https://github.com/afadingthought/dotfiles/blob/main/karabiner/karabiner.edn).
---
## FAQ &amp; LIMITATIONS
Expand Down Expand Up @@ -7013,7 +7042,7 @@ The inspiration to create Kiki came from ToolVox AI. If you know about Shortcuts
<key>description</key>
<string></string>
<key>label</key>
<string>Open AI API Token</string>
<string>OpenAI API Token</string>
<key>type</key>
<string>textfield</string>
<key>variable</key>
Expand Down Expand Up @@ -7432,7 +7461,7 @@ The inspiration to create Kiki came from ToolVox AI. If you know about Shortcuts
<key>variablesdontexport</key>
<array/>
<key>version</key>
<string>1.0.2</string>
<string>1.0.4</string>
<key>webaddress</key>
<string>https://afadingthought.substack.com</string>
</dict>
Expand Down
4 changes: 3 additions & 1 deletion Kiki/scripts/presets_receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@ function handleKikiCopy() {
simulateKeystroke('c', { using: 'command down' });
delay(delayClipboard);
theText = copyFromClipboard();
} else if (kikiCopy === 'incoming') {
theText = copyFromClipboard();
}
}

if (theText === '' && kikiCopy !== 'custom' && kikiCopy !== '-') {
if (theText === '' && kikiCopy !== 'custom' && kikiCopy !== '-') { // When will it be -?
handleKikiCopy();
}

Expand Down

0 comments on commit f370044

Please sign in to comment.