{"id":20339055,"url":"https://github.com/szczyglis-dev/gpt3-py","last_synced_at":"2025-04-11T23:12:36.017Z","repository":{"id":61502307,"uuid":"551602448","full_name":"szczyglis-dev/gpt3-py","owner":"szczyglis-dev","description":"[Python] \"Bring-Your-Own-Key\" terminal based application allowing interaction with the OpenAI's GPT-3 artificial intelligence. It provides a chat mode, code generation in Python, C++, C#, Java, Javascript, TypeScript, PHP, Assembly, SQL, Bash, Ruby, Go, Perl, R, Matlab, Q# and more.","archived":false,"fork":false,"pushed_at":"2024-08-25T20:20:44.000Z","size":101,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T23:12:25.022Z","etag":null,"topics":["ai","api-client","artificial-intelligence","bot","chatbot","code","code-generation","codeanalysis","command-line","davinci","deep-learning","gpt","gpt-3","machine-learning","natural-language-generation","natural-language-processing","openai-api","python3","terminal-based","transformer-models"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/szczyglis-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-14T18:10:59.000Z","updated_at":"2024-08-25T20:20:47.000Z","dependencies_parsed_at":"2024-08-25T21:55:05.063Z","dependency_job_id":"25671afc-c8e6-4b23-9bd8-75a2be0d1688","html_url":"https://github.com/szczyglis-dev/gpt3-py","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szczyglis-dev%2Fgpt3-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szczyglis-dev%2Fgpt3-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szczyglis-dev%2Fgpt3-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szczyglis-dev%2Fgpt3-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szczyglis-dev","download_url":"https://codeload.github.com/szczyglis-dev/gpt3-py/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248492876,"owners_count":21113163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","api-client","artificial-intelligence","bot","chatbot","code","code-generation","codeanalysis","command-line","davinci","deep-learning","gpt","gpt-3","machine-learning","natural-language-generation","natural-language-processing","openai-api","python3","terminal-based","transformer-models"],"created_at":"2024-11-14T21:15:16.464Z","updated_at":"2025-04-11T23:12:35.992Z","avatar_url":"https://github.com/szczyglis-dev.png","language":"Python","funding_links":["https://www.buymeacoffee.com/szczyglis"],"categories":[],"sub_categories":[],"readme":"Python: **3.7+**, current release: **1.0.1** build 2022-10-16  **THIS REPOSITORY IS OBSOLETE**\n\n-----------------------------\n# INFORMATION \u003e\u003e\u003e\nThis is an obsolete version.\nCheck the newer desktop version called **PYGPT**.\n\n**PYGPT** supports **GPT4**, **GPT3**, **GPT3.5** and **DALL-E 2** and offers features like short and long-memory, context storage and restore, editable prompts presets and more. \nIt is available for Windows and Linux (compiled binary desktop versions are available to download from project website).\n\n## PYGPT is here:\n\nhttps://github.com/szczyglis-dev/py-gpt\n\nhttps://pygpt.net\n\n**Enjoy!**\n\n![app1](https://user-images.githubusercontent.com/61396542/230803425-5035ccd8-50d9-4fef-9774-8843cf3ce5b0.jpg)\n\n-----------------------------\n\n\n**\u003c\u003c\u003c END OF INFORMATION, OLD VERSION:**\n\n# GPT3-py - terminal based AI chatbot and code generator\n\n**\"GPT3-py\" is a Bring-Your-Own-Key terminal-based application written in Python 3, allowing easy interaction with the OpenAI's GPT-3 artificial intelligence. The application provides a chat mode in the form of a configurable chatbot, as well as additional functions such as generating code in several different languages (Python, C++, C#, Java, Javascript, TypeScript, PHP, Assembly, SQL, Bash, Ruby, Go, Perl, R, Matlab and Q#), translating the code into a human language, generating Linux and Windows commands based on the description and much more. The application is easy to configure and can be extended with your own features.**\n\n\u003e**INFO: The application requires your own OpenAI's API key to work and is intended for home use on a local machine.**\n\n## What is GPT-3?\n\u003eGenerative Pre-trained Transformer 3 (GPT-3; stylized GPT·3) is an autoregressive language model that uses deep learning to produce human-like text. Given an initial text as prompt, it will produce text that continues the prompt.\nFrom: https://en.wikipedia.org/wiki/GPT-3\n\n## Features:\n\n- GPT-3 powered chatbot running in the terminal\n- defining the terms of conversation with the chatbot, such as time and place\n- chatbot configuration\n- creating custom queries to GPT-3\n- Python, C++, C#, Java, Javascript, TypeScript, PHP, Assembly, SQL, Bash, Ruby, Go, Perl, R, Matlab and Q# code generation from description\n- analysis and translation of code operation into human language\n- generating commands for Linux from the description\n- generating commands for Window (DOS and Powershell) from the description\n- easy to configure and modify\n- works under any operating system in the terminal\n- includes separate scripts that take input from STDIN and command line argument\n- built-in output content moderation\n\n## Requirements:\n\n- Python: 3.7+\n- openai \u003e= 0.22.1\n\n\n## How to install:\n\nDownload or clone repository and install required packages:\n\n```pip3 install -r ./requirements.txt```\n\nor \n\n```pip3 install openai```\n\n\n## First launch:\n\nYou must have an OpenAI account and obtain **your own API key** required for use with the application.\n\nAfter registering on the https://beta.openai.com/ website, generate your own API key and put it in the config file:\n\n```config.py```\n\nin section:\n\n```API_KEY = \"\u003cYOUR API KEY HERE\u003e\"```\n\n\nAfter placing your API key in the config file, the application is ready for use, run it with:\n\n\n```python3 ./gpt3.py```\n\nor\n\n```./gpt3.py```\n\n## Screenshot:\n\n![1 0 1](https://user-images.githubusercontent.com/61396542/196011245-690390a2-8510-4105-8d09-c8b6cc1eaf1f.png)\n\n## Feature list:\n\n```\n1 - Chatbot\n2 - Custom chatbot\n3 - Custom completion\n4 - Translate code to human language\n5 - Translate into Linux command\n6 - Translate into Windows command\n7 - Translate into Python code\n8 - Translate into PHP code\n9 - Translate into Javascript code\n10 - Translate into TypeScript\n11 - Translate into Java code\n12 - Translate into C++ code\n13 - Translate into C# code\n14 - Translate into SQL code\n15 - Translate into Assembly code\n16 - Translate into Bash script\n17 - Translate into Q# code\n18 - Translate into Ruby code\n19 - Translate into Go code\n20 - Translate into Perl code\n21 - Translate into R code\n22 - Translate into Matlab code\n23 - Translate into Lua code\n```\n\n# Usage:\n\n\n## 1 - Chatbot (default)\n\nDefault chatbot with which you can talk to GPT-3.\n\nAfter selecting this option, configuration options will be displayed allowing you to define the terms of the conversation:\n\n```SET TEMPERATURE FROM 0.0 to 1.0, WHERE 0.0 = LESS ABSTRACTION, 1.0 = MORE ABSTRACTION, OR LEAVE EMPTY TO LEAVE DEFAULT (0.3):```\n\nThe above allows to define the temperature of the conversation in the range from 0.0 to 1.0.\nThe lower the value, the more precise chatbot responses are, the higher the value, the more abstract the responses will be.\n\nIn the next step, you can define the time of the conversation:\n\n```\nCHOOSE TIME, OR LEAVE EMPTY IF YOU DO NOT WANT TO SET CUSTOM TIME:\n0 - Do not set custom time (default)\n1 - Custom time\n2 - Real time\n```\nBy default, the time is not specified, but you can enter your own time or choose the real time. When choosing the option to enter your own time, you can enter the full date, time or time of the day, e.g.:\n\n```Monday, 2022.10.03, 12:00```\n\nor\n\n```evening```\n\nIf you choose real time, the time will be determined automatically according to the current time.\n\nIn the last prompt, you can choose the circumstances or place of the conversation, or leave the default selection so as not to specify the place:\n\n```\nCHOOSE PLACE FOR CONVERSATION, OR LEAVE EMPTY IF YOU DO NOT WANT TO SET CUSTOM PLACE:\n0 - Do not set custom place (default)\n1 - Custom place\n```\n\nExample of choosing a place if you have chosen to define your own place:\n\n**[1] and press Enter**\n\n```SPECIFY CUSTOM PLACE FOR CONVERSATION (e.g. in cofeeshop):\n\u003e in home\n```\n\nThis will result in the following behavior during the conversation:\n\n```\nBEGIN:\n------------------------------\n\u003e hi, where are we now?\nWe are currently in your home.\n\u003e what do you thing about this place?\nI think this place is great! It's really cozy and has a lot of character.\n```\n\n**Tip:** to end the conversation at any time and exit the application, use the **CTRL+C** key combination.\n\n## 2 - Custom chatbot\n\nIn this feature, you can program GPT-3 yourself, so that the conversation proceeds according to the scenario you set.\n\nFor help with creating queries, visit the OpenAI website: https://beta.openai.com/docs/guides/completion\n\n\n**Example query:**\n\n```\nBatman is a hero. A Human is a person who meets Batman on the street.\nHuman: Hi\nBatman: Hello\nHuman:\u003cINPUT\u003e\nBatman:\n```\n\nPreparing the above scenario will give you the opportunity to \"talk to Batman\":\n\n```\nBEGIN:\n------------------------------\n\u003e what are you doing?\nI am fighting crime.\n```\n\n**Tip:** when creating your query, use the placeholder ``\u003cINPUT\u003e`` for user input. It will be replaced with the text entered from the terminal.\n\n\n## 3 - Custom completion\n\nThis feature allows you to prepare your own query for GPT-3, with the difference that the query must be specified during each loop run. \n\nThe feature can be used for e.g. data analysis or to generate stories.\n\n**Example query:**\n\n```\n\u003e\u003e\u003e\nTopic: Superman\nStory: Superman is a comic superhero who saves people. Once upon a time, Superman had to save the Earth from an alien invasion.\n    \nTopic: Tony Stark\nStory: \n```\n\n**Result:**\n\n```Tony Stark is a billionaire who creates technology. He is also the superhero Iron Man. Once, Tony Stark had to save the world from a giant robot.```\n\n\nYou can find more usage examples on the OpenAI website: https://beta.openai.com/examples\n\n\n## 4 - Translate code to human language\n\nThis feature allows any code to be translated into human language.\nYou can enter any code to get an explanation of how it works.\n\n**Example query:**\n```\n\u003e if (a \u003e 1) b = true;\n```\n\n**Result:**\n\n```The code checks if the value of the variable a is greater than 1. If it is, the code sets the value of the variable b to true.```\n\n## 5 - Translate into Linux command\n\nThis feature allows you to generate any command for Linux based on the description.\n\n**Example query:**\n\n```\n\u003e create /home/user/file.txt, copy it to /home/tmp, then zip the files from /home/tmp to files.tar.gz\n```\n\n**Result:**\n```\ncp /home/user/file.txt /home/tmp\ntar -czvf files.tar.gz /home/tmp\n```\n\n## 6 - Translate into Windows command\n\nThis feature allows you to generate any command for Windows (DOS + Powershell) based on the description.\n\n**Example query:**\n\n```\n\u003e create test directory on drive C:, copy files to it from directory D:\\files, and finally move files from directory C:\\test to drive E:\\\n```\n\n**Result:**\n\n```\nDOS:\nmd C:\\test\ncopy D:\\files C:\\test\nmove C:\\test E:\\\n\nPowerShell:\nNew-Item -Path 'C:\\test' -ItemType Directory\nCopy-Item -Path 'D:\\files' -Destination 'C:\\test'\nMove-Item -Path 'C:\\test' -Destination 'E:\\'\n```\n\n## 7 - Translate into Python code and other languages\n\nFeatures **7 to 23** allow you to generate code based on the description of the action.\n\nThe following is an example of use for Python:\n\n```\n\u003e read all files in the ./test directory, pack them all, and save them to packed.zip\n```\n\n**Result:**\n\n```\nimport os\nimport zipfile\n\ndef pack(dir, zip_file):\n    for root, dirs, files in os.walk(dir):\n        for file in files:\n            zip_file.write(os.path.join(root, file))\n\nwith zipfile.ZipFile('packed.zip', 'w') as zip_file:\n    pack('./test', zip_file)\n\n```\n\nThe code generation for other languages is the same.\n\nHere is an example for Bash:\n\n**16 - Translate into Bash script**\n\n**Example query:**\n\n```\nif /home/test exists, then copy all files from /home/tmp to it\n```\n\n**Result:**\n\n```\nif [ -d /home/test ]; then cp -r /home/tmp/* /home/test/; fi\n```\n\n\n## Getting input from STDIN\n\nThere is a separate script in the repository that takes input from STDIN and returns a single response from GPT-3. \n\nThis can be used to connect I/O with other commands and programs.\n\n**Example:**\n\n```python3 ./gpt3_stdin.py```\n\nCommand in the terminal:\n\n```echo \"Hello\" | python3 ./gpt3_stdin.py```\n\n**Result:**\n\n```Hello there! How are you doing today?```\n\n\n## Getting input from a command line argument\n\nThere is a separate script in the repository that takes input from the command line argument and returns a single response from GPT-3. \n\nThis can be used to connect I/O with other commands and programs.\n\n**Example:**\n\n```python3 ./gpt3_cmd.py```\n\nCommand in the terminal:\n\n```\npython3 ./gpt3_cmd.py \"hello!\" \u003e ./output.txt\ncat ./output.txt\n```\n\n**Result:**\n\n```Hello! How are you doing today?```\n\n\n## Moderation\n\nThe package includes a built-in moderation of responses returned by GPT-3, responsible for filtering inappropriate content. \n\nModeration can be turned on or off using the parameter:\n\n\n```is_moderation = True|False```\n\nlocated in the file:\n\n```config.py```\n\n\n## History storage\n\nThe application has the option of saving the entire history of conversations to .txt files.\nTo enable or disable saving to history use:\n\n```store_history = True|False```\n\nlocated in the file:\n\n```config.py```\n\nBy default, history is saved to the ```./history``` directory.\n\n\n## Additional configuration\n\nYou can freely configure the operation of the application, specifying parameters such as the selected model (the default model is DaVinci), the maximum number of tokens and other options in the config file:\n\n```\n# config.py\n\nis_moderation = False # enable or disable output moderation\nstore_history = True # enable or disable history storage\nstore_history_time = True # enable or disable timestamp in history files\nhistory_path = \"./history\" # path to the history directory\ntemperature = 0.3 # default temperature\nmax_tokens = 1000 # max tokens in output\nmodel = \"text-davinci-002\" # model\ntop_p = 1 # sampling threshold\nfrequency_penalty = 0.0 # model’s tendency to repeat predictions\npresence_penalty = 0.0 # encourages the model to make novel predictions\n\n# initial values\nstop = \"\"\nmode = \"chat\"\nmode_time = 0\nmode_place = 0\ncustom_time = \"\"\ncustom_place = \"\"\ndate_format = \"%Y.%m.%d\"\ntime_format = \"%H:%M\"\n```\n\n**The application is intended for personal home use.**\n\n**Please note that if you choose to use it for commercial use, please report the use to the App Review procedure on the OpenAI website.**\n\n___\n\n## Changelog\n\n**- 1.0.1** - Added additional languages: TypeScript, Ruby, Go, Perl, R, Matlab, Q# (2022-10-16)\n\n**- 1.0.0** - Published first release. (2022-10-15)\n\n--- \n**GPT3-py is free to use, but if you like it, you can support my work by buying me a coffee ;)**\n\nhttps://www.buymeacoffee.com/szczyglis\n\n**Enjoy!**\n\nMIT License | 2022 Marcin 'szczyglis' Szczygliński\n\nhttps://github.com/szczyglis-dev/gpt3-py\n\nhttps://szczyglis.dev\n\nContact: szczyglis@protonmail.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszczyglis-dev%2Fgpt3-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszczyglis-dev%2Fgpt3-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszczyglis-dev%2Fgpt3-py/lists"}