Skip to content

Commit

Permalink
Feat/dbn 8 gpt completions (#38)
Browse files Browse the repository at this point in the history
* 🤖 - Added GPT-3 Completions
* 🥫 - Removed openai depends on control file
* 🧰 - Fixes for deepsource
  • Loading branch information
jd-apprentice authored Mar 24, 2023
1 parent 51353b2 commit baefe5b
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 17 deletions.
2 changes: 1 addition & 1 deletion DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: dbn-tools
Version: 0.0.9
Version: 0.1.0
Section: utils
Priority: optional
Architecture: all
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM ubuntu:jammy
RUN apt-get update
RUN apt-get install -y --no-install-recommends wget=1.21.2-2ubuntu1 git=1:2.34.1-1ubuntu1.6 curl=7.81.0-1ubuntu1.7 net-tools=1.60+git20181103.0eebece-1ubuntu5 python3-dev=3.10.6-1~22.04 python3-pip=22.0.2+dfsg-1ubuntu0.1
RUN pip3 install requests==2.28.2 \
yt-dlp==2023.1.6
yt-dlp==2023.1.6 \ openai==0.27.2

# We download the app and install it - These values are default, use the version you want to download in the .env file
ARG DOWNLOAD_URL=https://github.com/jd-apprentice/dbn-tools/releases/download/0.0.6/0.6-dbn-tools.deb
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ We use codacy here is the [DASHBOARD](https://app.codacy.com/gh/jd-apprentice/db

- Bash
- Git
- Debtap (Arch)
- Debtap [Repository](https://github.com/helixarch/debtap)
- Python 3

## 🐍 Python dependencies

- Requests
- Requests [Requests](https://pypi.org/project/requests/)
- Openai [GPT-3](https://pypi.org/project/openai/)

## 🐛 Troubleshot

Expand All @@ -102,6 +103,14 @@ For more information, check the [TROUBLESHOT](./TROUBLESHOT.md) file
| -------------- | --------------------------------------------------------------------------------------------- |
| `DOWNLOAD_URL` | URL to download a package get it from here -> https://github.com/jd-apprentice/dbn-tools/tags |
| `PACKAGE_NAME` | Name of the package being downloaded (is the name of the file from the other variable) |
| `GPT_KEY` | Key to use GPT-3 API - Add it on your shell configuration |

```bash
## For the `GPT_KEY` we are reading it from .bashrc or .zshrc depending on your shell
## Add a line like this:

GPT_KEY='YOUR_KEY'
```

## 📁 Install

Expand Down
3 changes: 2 additions & 1 deletion usr/bin/constants/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export descriptions=(
"10 Download YT Video - Downloads a video from youtube with the best possible size and quality by default"
"11) Search for a file - Searches for a file by name or wildcard pattern."
"12) USR-ARS Pair - Ask the value of the USD Dolar against the argentine PESO"
"13) Exit - Exit the application"
"13) Ask GPT 3 - Ask anythig to the GPT 3 AI"
"14) Exit - Exit the application"
)
3 changes: 2 additions & 1 deletion usr/bin/constants/menu-esp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export menu_options_spanish=(
"10) Descargar Video YT"
"11) Buscar archivo"
"12) Dolar a pesos"
"13) Salir"
"13) Pregunta a GPT 3"
"14) Salir"
)
3 changes: 2 additions & 1 deletion usr/bin/constants/menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export menu_options=(
"10) Download YT Video"
"11) Search for a file"
"12) USD-ARS Pair"
"13) Exit"
"13) Ask GPT 3"
"14) Exit"
)
23 changes: 23 additions & 0 deletions usr/bin/functions/ask-gpt-3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3

from time import sleep
from random import uniform
import os
import openai

openai.api_key = os.environ['GPT_KEY']

prompt = input("Enter your prompt \n -> ")

completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": prompt},
]
)

response = completion.choices[0].message.content

for x in response:
print(x, end='', flush=True)
sleep(uniform(0, 0.1))
3 changes: 2 additions & 1 deletion usr/bin/functions/read-arguments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
function ReadArguments() {
# Python functions (soon to be moved out)
UsdArs="/usr/bin/functions/usd-ars.py"
AskGPT3="/usr/bin/functions/ask-gpt-3.py"

# Base options when no arguments is passed
export options=(DiskUsage DeleteTemporary EmptyRecycleBin UninstallPackage SystemInfo MemoryUsage Uptime OpenPorts GetWeather DownloadVideo FindFile $UsdArs exit)
export options=(DiskUsage DeleteTemporary EmptyRecycleBin UninstallPackage SystemInfo MemoryUsage Uptime OpenPorts GetWeather DownloadVideo FindFile $UsdArs $AskGPT3 exit)

local arguments="$1"
for arg in "$arguments"; do
Expand Down
2 changes: 1 addition & 1 deletion usr/bin/functions/unistall-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
function UninstallPackage() {
read -p "Enter the name of the program to uninstall: " program
echo "Uninstalling $program..."
sudo dpkg --purge $program
sudo dpkg --purge "$program"
}

export -f UninstallPackage
6 changes: 3 additions & 3 deletions usr/bin/functions/usd-ars.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def print_table(data):
def main():
getData(dolarAPI)
table_data = [["💱 Currency", "💸 Value"],
["💵 Official", sackEmoji + str(arrData[0]["value_avg"]) + arsLabel],
["💵 Real", sackEmoji + str(arrData[0]["value_avg"]) + arsLabel],
["💵 Blue", sackEmoji + str(arrData[1]["value_avg"]) + arsLabel],
["💶 Official_Euro", sackEmoji + str(arrData[2]["value_avg"]) + arsLabel],
["💶 Real_Euro", sackEmoji + str(arrData[2]["value_avg"]) + arsLabel],
["💶 Blue_Euro", sackEmoji + str(arrData[3]["value_avg"]) + arsLabel]]
print_table(table_data)

# Init application
main()
main()
8 changes: 4 additions & 4 deletions utils/build_new_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ done <$file

# We locate where the folder is located and move to it
folder=$(find $HOME -type d -name "dbn-tools" -print | tail -n 1)
cd $folder
cd "$folder"

# We create a folder for the build and copy the entire file one level above
cd ..
mkdir -p -- "$version-dbn-tools"
copy=$(find $HOME -type d -name ${version}"-dbn-tools")
cp -r $folder/* $copy
cp -r $folder/* "$copy"

# Move to the copy directory
cd $copy
cd "$copy"

# We remove git since we don't want it in the final build
rm -rf .git
rm readme.png
rm *.md
rm -- *.md

# Move out of the copy directory
cd ..
Expand Down
2 changes: 1 addition & 1 deletion utils/debian_builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
echo "Path to the original .deb file -> "
read -n path

ar x $path
ar x "$path"
zstd -d <control.tar.zst | xz >control.tar.xz
zstd -d <data.tar.zst | xz >data.tar.xz
ar -m -c -a debian-binary control.tar.xz data.tar.xz debian_repacked.deb
Expand Down

0 comments on commit baefe5b

Please sign in to comment.