What is it about ?
As our first release for our course Open source development, is rolling out. We had a chance to experience API or tools which are similar to ChatGPT, or in more technical term "Large Language models" (LLM's). We were instructed to create an CLI tool which can have any function using LLM, in this blog i will explain how i did my CLI tool with LLM.
What did i do ?
I decided to create an CLI tool with the help of python and the LLM called Gorq AI, which has the ability to accepts files and generate a README file for the user.
What it has
I tool runs with two python file one is called api.py which handles all api interactions and the another one which is called DocBot.py which has the main function and also it handles all the interaction from he user to the command line. I will explain a bit for for each below.
api.py
In this file i have the implementation of generate_readme
which handles the API key and the Gorq AI. So what it does is accepts a file to read it contents and pass it to the AI to create or generate a readme file for the user. Also this function can accept and custom user API Key if the user wishes to give one.
DocBot.py
In this file i have implemented main()
, which has the purpose to get all the flags or inputs given by the user in the command line to be made use with argparse
.
Features.
DocBot as some features which can be performed in the command line such as some special flags, which is explained below.
1. Version
This flag prints the current version of the tool,
it can be used by calling -v
.
Example: python DocBot.py -v
2. Help
This flag prints out all the flags which is available to use and some information about the app it self and what it does.
It can use used by calling -h
or --help
Example: python DocBot.py -h
3. Output
This flag, helps the user to specific an output file name, so that it copy the content generated by the AI to that file and saves the file in the folder.
It can be used by calling -o
or --output
.
Example: python DocBot.py -o <file_name>
4. Custom API Key
This flag allows the user to provide their on Groq API key to be used in the tool.
It can be used by calling --api-key
.
Example: python DocBot.py --api-key <your api key goes here>
5. Multi File
This flag allows the user to generate separate README.md files if two or more files are given as an argument.
It can be used by calling --multi-file
or -mf
Example: python DocBot.py -mf
Prerequisite
- Make sure to install the required dependencies (dotenv, groq) before running the script.
- Make sure that you create a .env folder after forking or
cloning the repo and add your own Gorq API key, it should be in
the format of
GROQ_API_KEY="<your key goes here>"
Conclusion
DocBot is available on GitHub for the public to use, it is licensed under MIT for free open source use. It has lot of potential to improve and continue as a friend for developers
AJO GEORGE 20-09-2024
Top comments (0)