blubeai / AI_IN_DEPTH.md
endert1099's picture
Added literally fuc*ing everything
2e4a01c

A newer version of the Gradio SDK is available: 6.12.0

Upgrade

AI IN DEPTH

This should cover everything about the AI, if I missed anything, let me know

Higher number/farther down the list is more complex

1. The Basics

The entire program is made in python with some batch files for ease of use.

2. Querying results and getting online data

The program uses wikipedia modules to get and summarize different inputted topics

3. The Interface

Some of the basic interface uses the command prompt with python inputs and the actual AI is made using the Gradio API

4. The AI Model

The AI is build with OpenAI's ChatGPT API, inputs are taken from the Gradio input box, filtered through OpenAI's gpt-3.5-turbo model, and the AI sends an output in the allocated box

5. Usage

This is build to be a heavily customizable AI with a variety of different settings and customization options. The main settings are prompt saving limit and reset data. Reset data is self explanatory, just simply deleting your data and custom data. Prompt saving limit is a bit more complex, for custom data it is always the number you set it to lines in the docs/customdata.txt file, but because of the nature of the wiki search module, it may not always be the amount you set it to, because it can return multiple queries, which will be placed on separate files.

6. Persona

Probably the most complex thing I've ever done, allows for simple programs and systems to be made within the realm of the AI with the following definitions

  • Variables can be defined with words placed in double curly brackets {{var name}} description on what the variable is, optional
  • SET var name = value can be used to change values of previously defined variables
  • VALUE var name can be used to get the value of variables
  • IF var name condition can be used to return a boolean of logic. Variables can be defined as IF conditions or used with the
  • THEN code to execute statement, which must follow an IF statement
  • {{user}} is a predefined variable that refers to the user, or {{char}} which refers to the AI
  • Non-defined functions are any code that is not defined above, but AI still takes plain text input, so it is mixable with plain text

Now that that's sorted, lets see an example of a simple script, made in plain text with Persona

{{user}}'s name is John
{{char}}'s name is Jane

{{foo}} is a number starting at 1
{{bar}} is a string starting at \"Hello World!\"

{{bool store}} is a boolean IF statement
SET bool store = IF foo = 1

IF {{bool store}} THEN {{char}} will tell {{user}} the value of {{bar}}

This is very simple, but it can be much more complicated, although it is preset, so the only way to change variables is by implementing it into the program, but I'm sure you can find a way(that's a lie).

Now let's take a look at the main purpose of personas, and that's, well, personas. You can put anything like:

  • {{char}}'s name is John
  • {{char}} is named John and has brown hair and blue eyes
  • {{char}} is named John, has brown hair and blue eyes, and likes to code

These are 3 extremely basic examples, but you can make entire complex storylines and libraries of info. It is easily integrated into PersonaScript(patent never)

7. Mental... er.. I mean Line-By-Line breakdown

See app.py for more details


Lines 1-6: Import statements for modules Line 8: Gets OpenAI API Key Lines 9-12: Defines setting variables in a class Lines 13-21: start() function, gets persona, opens the file for storage, writes basic instructions that are build in(definitions), then finally user input Line 25: calls the clearOldMem() function to delete excess data thats going over the prompt limit, default 50 Lines 28-45: Makes a simple input system to get a number off the user and run the appropriate function Line 46: Recursion, as to why I didn't use parenthesis recursion, It's harder to read and remember Lines 47-73: Defines the clearOldMem() function, opens the data files, checks if they have more than the prompt limit lines, deletes lines from the start until it's the limit Lines 74-99: Defines the setSettings() function, gets setting passed in from the loop() function, does the appropriate action, this one is pretty self explanatory just read the print() statements Lines 100-110: Defines the write() function, called from the loop function, queries a wikipedia article/s on it, summarizes it, and writes it to the docs\data.txt file Lines 112-121: Defines custom() function, same as the write() function, only it takes direct user input and writes to a different file Lines 123-139: Defines construct_index(). I stole this code, I have barely a clue how it works, all I know is it takes a folder(docs) and builds a gpt-3.5-turbo model with that context, and saves it to index.json Lines 141-144: Defines the chatbot() function. Takes an input, finds it in index.json's context, and returns a summarized response. How it does this, I don't know, it is a 3000 line file and only 3 lines make any sense, and most are just random numbers that I'm too scared to touch Lines 145-152: Defines the runbot() function, builds Gradio UI around chatbot. Lines 157-158: Starts the program