Package: yogpt
yogpt: Command-Line GPT UtilityThis utility has been created to provide support for all chat large language models supported by LangChain framework. You can install it by usingpipinstallyogptAfter this, you can invoke it just by callingyogpt:yogptHello,howareyoutoday?Sample usageThere are four main scenarios howyogptis normally used:By asking the question directly on the command lineyogpt What is the 10th digit of Pi?By piping stdin intoyogpt:echo What is the 10th digit of Pi | yogpt -. Ifyogptunderstands that it is invoked in the pipe, it will automatically assume-parameter, so it can be omitted.By callingyogptwithout input - this initiates console chat.If you want to further chat withyogptafter providing it with some input, you may specify-c/--chatflag. In this case it will consume input as first utterance to the bot, and then initiate a follow-up chat. For example:yogpt -s "You are a software expert. Please read python program provided and be ready to answer questions on this program." -c @program.pyThe example above also shows that you can use@filenamesyntax to get input from a file.You can specify different models using-m/--modelparameter. Possible models (including your personal credentials) should be specified in the config file (see details below).You can also use prompt templates. Here is an example that will explain what a Python program does:catprogram.py|yogpt-p"Please explain what the following Python code does:{}"Some prompt templates that you often use can be defined in the config file, and used just by specifying the template name (with some optional additional parameters):catenglish.txt|yogpt-ptranslate-1german-You can also use@filenamesyntax to get prompt template from a filename.You can specify system message using-s/--systemswitch. Similarly, it can be a name from config file,@filename, or verbatim system message in quotes.Specifying credentialsAll utility configuration is stored in the user's home directory in the.yogpt.config.jsonfile. A sample config file is provided in this repository, which you may use as a starting point.Config file specifies the following sections:ModelsEach model is defined by the following JSON snippet:{"name":"ygpt","classname":"langchain.chat_models.ChatYandexGPT","default":true,"params":{"api_key":"..."}}Here parameters mean the following:nameis the model name, which you can specify using-mor--modelparameter of the utilityclassnameis the full class name of the model classparamsis the dictionary with all the parameters that we pass to the class when creating the model. Depending on the model, there will probably be your personal credentials here, such as OpenAI API Key.TemplatesTo carry out some specific tasks, you can define templates in the same config file usingtemplatessection. Template definition looks like this:{"name":"translate","template":"Please, translate the text in triple backquotes below into the following language: {param_1}. Here is the text:\n```{}```"}nameis the name of the template that you can pass to-por--templateparameter.templateis the template itself. In this template,{param_1}through{param_3}are replaced by optional command-line parameters-1through-3, and{}is replaced by the user's query.You can also pass the actual template text to-p/--templateparameter, like in the following example:echoHello,howareyou?|yogpt-p"Translate the following text into Chinese: {}"-Have a look into sample config file for different templates that you can use in your setup.If you by mistake make a typo in the system message name when specifying--templateparameter, this word would be used as verbatim template, which may cause problems. If there are no spaces or{}characters in the specified template, and if the name is not found in config, a warning is printed.System MessagesBot system messages are in a way similar to templates. They define overall behavior of LLM. For example, you can use system message to set the tone of the conversation, or to specify task for the model to perform.System message can be specified on the command-line using--system "..."or-s "..."switch. You can also use@filenamesyntax to supply the filename, or use system message name to look it up in the config file.If you by mistake make a typo in the system message name, this word would be used as verbatim system message, which may cause problems. If there are no spaces in the specified system message, and if the name is not found in config, a warning is printed.Config section for system messages looks like this:"system_messages":[{"name":"rude","message":"You are extremely rude chatbot that does not want to talk to anyone."}]