Package: lmt-cli
Language Models Terminallmtis a versatile CLI tool that enables you to interact directly with OpenAI's ChatGPT models from the comfort of your terminal.Table of ContentsFeaturesInstallationpippipx, the Easy WayGetting StartedConfiguring your OpenAI API keyUsageBasic ExampleAdd a PersonaSwitching ModelsTemplate UtilizationEmoji IntegrationPrompt Cost EstimationReading fromstdinAppend an Additional Prompt to PipedstdinOutput RedirectionUsinglmtas a Vim Filter CommandTheming Colors for Code BlocksExampleLicenseFeaturesAccess All ChatGPT Models:lmtsupports all available ChatGPT models (gpt-3.5-turbo, gpt-3.5-turbo-16k, gpt-4, gpt-4-32k), giving you the power to choose the most suitable one for your task.Custom Templates: Design your own toolbox of templates to streamline your workflow.Read File: Incorporate file content into your prompts seamlessly.Output to a File: Redirect standard output (stdout) to a file or another program as needed.Easy Vim Integration: Integrate ChatGPT into Vim effortlessly by usinglmtas a filter command.Installationpippython3-mpipinstalllmt-clipipx, the Easy Waypipxinstalllmt-cliGetting StartedConfiguring your OpenAI API keyFor LMT to work properly, it is necessary to acquire and configure an OpenAI API key. Follow these steps to accomplish this:Acquire the OpenAI API key: You can do this by creating an account on theOpenAI website. Once registered, you will have access to your unique API key.Set usage limit: Before you start using the API, you need to define a usage limit. You can configure this in your OpenAI account settings by navigating toBilling -> Usage limits.Configure the OpenAI API key: Once you have your API key, you can set it up by running thelmt key setcommand.lmtkeysetWith these steps, you should now have successfully set up your OpenAI API key, ready for use with the LMT.UsageBasic ExampleThe simplest way to uselmtis by entering a prompt for the model to respond to.Here's a basic usage example where we ask the model to generate a greeting:lmt"Say hello"In this case, the model will generate and return a greeting based on the given prompt.Add a PersonaYou can also instruct the model to adopt a specific persona using the--systemflag. This is useful when you want the model's responses to emulate a certain character or writing style.Here's an example where we instruct the model to write like the philosopher Cioran:lmt"Tell me what you think of large language models."\--system"You are Cioran. You write like Cioran."In this case, the model will generate a response based on its understanding of Cioran's writing style and perspective.Switching ModelsSwitching between different models is a breeze withlmt. Use the-mflag followed by the alias of the model you wish to employ.lmt"Explain what is a large language model"-m4Below is a table outlining available model aliases for your convenience:AliasCorresponding Modelchatgptgpt-3.5-turbochatgpt-16kgpt-3.5-turbo-16k3.5gpt-3.5-turbo3.5-16kgpt-3.5-turbo-16k4gpt-4gpt4gpt-44-32kgpt-4-32kgpt4-32kgpt-4-32kFor instance, if you want to use thegpt-4model, simply include-m 4in your command.Template UtilizationTemplates, stored in~/.config/lmt/templatesand written in YAML, can be generated using the following command:lmttemplatesaddFor help regarding thetemplatessubcommand, use:lmttemplates--helpHere's an example of invoking a template named "cioran":lmt"Tell me how AI will change the world."--templatecioranYou can also use the shorter version:-t cioran.Emoji IntegrationTo infuse a touch of emotion into your requests, append the--emojiflag option.Prompt Cost EstimationFor an estimation of your prompt's cost before sending, utilize the--tokensflag option.Reading fromstdinlmtfacilitates reading inputs directly fromstdin, allowing you to pipe in the content of a file as a prompt. This feature can be particularly useful when dealing with longer or more complex prompts, or when you want to streamline your workflow by incorporatinglmtinto a larger pipeline of commands.To use this feature, you simply need to pipe your content into thelmtcommand like this:catyour_file.txt|lmtIn this example,lmtwould use the content ofyour_file.txtas the input for thepromptcommand.Also, remember that you can still use all other command line options withstdin. For instance, you might run:catyour_file.py|lmt\--system"You explain code in the style of \a fast-talkin' wise guy from a 1940's gangster movie"\-m4--emojiIn this example,lmttakes the content ofyour_file.pyas the input for thepromptcommand. With thegpt-4model selected via-m 4, the system is instructed to respond in the style of a fast-talking wiseguy from a 1940s gangster movie, as specified in the-s/--systemoption. The--emojiflag indicates that the response may include emojis for added expressiveness.Append an Additional Prompt to PipedstdinBeyond the-s/--systemoption,lmtoffers the capability to append an additional user prompt when reading fromstdin. This is especially useful when you want to add context or specific instructions to the piped input without altering the system prompt.For example, with agrocery_list.txtfile, you can append a prompt for healthy alternatives and set the system prompt to guide the AI's chef-like response.catgrocery_list.txt|lmt"What are some healthy alternatives to these items?"\--system"You are a chef with a focus on healthy and sustainable cooking."Output RedirectionYou can use output redirections. For instance:lmt"List 5 Wikipedia articles">wiki_articles.mdUsinglmtas a Vim Filter CommandTo invokelmtas a filter command in Vim, you can use the command:.!lmt. Remember, Vim offers the shortcut!!as a quick way to enter:.!. This means you can simply type!!lmtto initiate your prompt.Example::.!lmt write an implementation of binary searchAdditionally, you can filter specific lines from your text and pass them as a prompt tolmt. To achieve this, highlight the desired lines inVISUALmode (or useexsyntax), and then enter:.!lmt "Your additional prompt here".Theming Colors for Code BlocksOnce you usedlmt, you should have a configuration file (~/.config/lmt/config.json) in which you can configure the colors for inline code and code blocks.Here are the styles for the code blocks:https://pygments.org/styles/As for the inline code blocks, they can be styled with the 256 colors (names or hexadecimal code).Example{"code_block_theme":"default","inline_code_theme":"blue on #f0f0f0"}Licenselmtis licensed under Apache License version 2.0.https://github.com/sderev/lmt