|
1 | 1 | # Getting started with LLM Assistant |
2 | 2 |
|
3 | | -Collection of simple LLM applications |
| 3 | +Collection of tools to work with LLMs. |
4 | 4 |
|
5 | 5 | ## Features |
6 | 6 |
|
| 7 | +- CLI for interactive prompt execution. |
| 8 | +- Prompt versioning tool. |
| 9 | +- Prompt definition format and general runner. |
7 | 10 |
|
8 | | -## Examples |
| 11 | + |
| 12 | +## How to use |
| 13 | + |
| 14 | +### Configuring a LLM provider |
| 15 | + |
| 16 | +The first step is to create a `llm-assistannt-config.toml` file |
| 17 | +to hold runner and prompt settings. |
| 18 | + |
| 19 | +```toml |
| 20 | +[runner] |
| 21 | +openai_key = "<OPENAI_KEY>" |
| 22 | +model = "gpt-3.5-turbo" |
| 23 | +use_cache = true |
| 24 | +cache_path = "/home/user/.config/llm-assistant/cache.db" |
| 25 | + |
| 26 | +[prompt] |
| 27 | +git_user = "danoan-prompts" |
| 28 | +prompt_collection_folder = "/home/user/.config/llm-assistant/cache.db" |
| 29 | + |
| 30 | +[prompt.versioning] |
| 31 | +alternative-expression = "v2.0.0" |
| 32 | +word-definition = "v1.0.0" |
| 33 | +``` |
| 34 | + |
| 35 | +**Configuration file search**: The application backtracks the current working directory searching for the |
| 36 | +`llm-assistant-config.toml` file starting from CWD. If not such file is found, it searches in the location |
| 37 | +specified by the environment variable `LLM_ASSISTANT_CONFIGURATION_FOLDER`. |
| 38 | + |
| 39 | +You can check which configuration file is being used by running |
| 40 | + |
| 41 | +```bash |
| 42 | +llm-assistant setup |
| 43 | +``` |
| 44 | + |
| 45 | + |
| 46 | +### Running a prompt |
| 47 | + |
| 48 | +Consider the `alternative-expression` prompt configuration file: |
| 49 | + |
| 50 | +```toml |
| 51 | +name="Alternative Expressions" |
| 52 | +system_prompt=''' |
| 53 | +You are fluent speaker of the {language} language and your task is to list at most five expressions that encodes the meaning of a sentence or a word enclosed by double angle brackets. |
| 54 | +
|
| 55 | +Your response must be given as a json list and the items must be written in {language}. |
| 56 | +
|
| 57 | +Examples |
| 58 | +-------- |
| 59 | +
|
| 60 | +Language: English. |
| 61 | +Sentence: <<It is an unusual day today.>> |
| 62 | +Response: [ |
| 63 | + "It is an odd day today", |
| 64 | + "Today is quite unusual", |
| 65 | + "It is an atypical day", |
| 66 | + "Today feels out of the ordinary", |
| 67 | + "Today stands out differently" |
| 68 | +] |
| 69 | +-- |
| 70 | +
|
| 71 | +Language: french |
| 72 | +Sentence: <<gentil>> |
| 73 | +Response: [ |
| 74 | + "aimable", |
| 75 | + "doux" |
| 76 | +] |
| 77 | +-- |
| 78 | +
|
| 79 | +''' |
| 80 | +user_prompt=''' |
| 81 | +Language: {language} |
| 82 | +Sentence: <<{message}>> |
| 83 | +Response: |
| 84 | +''' |
| 85 | +``` |
| 86 | + |
| 87 | +It is possible to run the prompt in three different ways |
| 88 | + |
| 89 | +```bash |
| 90 | +echo "{}" | llm-assistant run alternative-expression --p language portuguese --p message "ganhar a vida" |
| 91 | +echo '{"message":"ganhar a vida"}' | llm-assistant run alternative-expression --p language portuguese |
| 92 | +echo '{"message":"ganhar a vida", "language":"portuguese"}' | llm-assistant run alternative-expression |
| 93 | +``` |
| 94 | + |
| 95 | +### Starting an interactive session |
| 96 | + |
| 97 | +To start an interactive session, type: |
| 98 | + |
| 99 | +```bash |
| 100 | +llm-assistant session |
| 101 | +``` |
| 102 | + |
| 103 | +You are invited to select one of the prompts located at `prompt.prompt_collection_folder` and then to load or |
| 104 | +create a new instance for the prompt. |
| 105 | + |
| 106 | +**Prompt Instance**: A prompt instance is a subset of pre-defined prompt variables. For example, in the alternative-expression |
| 107 | +prompt, we could have a french instance (language=french) and a portuguese instance (language=portuguese). |
| 108 | + |
| 109 | +```bash |
| 110 | +╭────────────────────────────────────────────────────────────────────────────────────────╮ |
| 111 | +│ Select prompt │ |
| 112 | +╰────────────────────────────────────────────────────────────────────────────────────────╯ |
| 113 | +1. Alternative Expressions 2. Word Definition |
| 114 | + |
| 115 | +Prompt index: 2 |
| 116 | +╭────────────────────────────────────────────────────────────────────────────────────────╮ |
| 117 | +│ Choose an option │ |
| 118 | +╰────────────────────────────────────────────────────────────────────────────────────────╯ |
| 119 | +1. New instance 2. Load instance |
| 120 | + |
| 121 | +Option index: 1 |
| 122 | +Enter the instance name: portuguese |
| 123 | +Enter variable assignment: language=portuguese |
| 124 | +╭─────────────────────────────────────── New Chat ───────────────────────────────────────╮ |
| 125 | +│ Prompt: Word Definition │ |
| 126 | +│ Instance:portuguese │ |
| 127 | +╰────────────────────────────────────────────────────────────────────────────────────────╯ |
| 128 | +Enter messaó |
| 129 | +Enter message: $$ |
| 130 | +╭───────────────────────────── Word Definition::portuguese ─────────────────────────────╮ |
| 131 | +│ borogodó │ |
| 132 | +╰───────────────────────────────────────────────────────────────────────────────────────╯ |
| 133 | +╭───────────────────────────── Word Definition::portuguese ─────────────────────────────╮ |
| 134 | +│ [ │ |
| 135 | +│ "Encanto, atração irresistível e misteriosa; charme", │ |
| 136 | +│ "Qualidade ou característica que atrai e seduz de maneira peculiar ou especial.", │ |
| 137 | +│ "Dom, habilidade natural para seduzir ou encantar as pessoas.", │ |
| 138 | +│ "Magia, feitiço; algo que exerce influência sobre os outros de forma inexplicável." │ |
| 139 | +│ ] │ |
| 140 | +╰───────────────────────────────────────────────────────────────────────────────────────╯ |
| 141 | +``` |
| 142 | + |
| 143 | +### Syncing prompts |
| 144 | + |
| 145 | +The `sync` feature allows to fetch the most recent updates from the remote prompt repository |
| 146 | +and to update the local view. |
| 147 | + |
| 148 | +```bash |
| 149 | +prompt-manager sync |
| 150 | +``` |
| 151 | + |
| 152 | +The synchronization is done according with the `prompt.versioning` settings. |
| 153 | + |
| 154 | +```toml |
| 155 | +[prompt] |
| 156 | +git_user = "danoan-prompts" |
| 157 | +prompt_collection_folder = "/home/user/.config/llm-assistant/cache.db" |
| 158 | + |
| 159 | +[prompt.versioning] |
| 160 | +alternative-expression = "v2.0.0" |
| 161 | +word-definition = "v1.0.0" |
| 162 | +``` |
| 163 | + |
| 164 | +For the settings above, the sync will seach for the repositories: |
| 165 | + |
| 166 | +- danoan-prompts/alternative-expression |
| 167 | +- danoan-prompts/word-definition |
| 168 | + |
| 169 | +on github and then fetch the specified version. |
| 170 | + |
| 171 | +### Push prompt version assistant |
| 172 | + |
| 173 | +The `prompt-manager versioning push` commands guides the user to the creation of a |
| 174 | +new prompt version. |
9 | 175 |
|
10 | 176 |
|
11 | 177 | ## Contributing |
|
0 commit comments