This is a project using the Gemini API to show capabilities as well as how changing the temperature, TopK and TopP will change responses given. You will be able to randomly change the Temperature, TopP and TopK values to change the "randomness" in the model. You can also maximize the "randomness". Once you end the code the chat will be saved to a text file with the history.
UPDATE: ADDED GRADIO
A Gradio version of the code has been implemented using Gradio Interface. This will create a local host webpage for a GUI. Note that for this implementation you will have to manually press the checkbox on and off for it to change the condition. Output 0 is the output for the current prompt and output 1 is the chat history.
In order to run the code you will need a Gemini API key, once you have done this create a file called 'GOOGLE_API_KEY.txt' and paste the key.
To run the code you will need to have Anaconda and run the following commands
conda create -n chatbot python=3.10
conda activate chatbot
pip install -q -U google-generativeai
pip install gradio
For using Tkinter
python Gemini_chatbot.py
For using Gradio
python Gemini_chatbot_gradio.py
TopK:
TopK is the number of tokens from which the model can choose from. This is an integer from 1 to 40. Where 1 would be only a single token would be given. 40 would mean that the next token is chosen from the 40 most probable tokens.
TopP:
TopP is a probability threshold which is used to choose a token from. This is a value from 0 to 1. Where 0 means that the model would be shown the first token. 1 would mean that all tokens are given to the model to choose from. This is because the sum of all token probabilities should be 1.
Temperature:
Temperature is how much randomness is in choosing the token. This is a value from 0 to 1. Where 0 would mean less random and creative. 1 would mean a more random and creative.
By default the code is set to be the least random meaning Temperature is 0, TopP is 0 and TopK is 40.
I used Creating Input Fields With TKinter - Python Tkinter GUI Tutorial #4 as a template for the GUI. I also used ChatGPT to help create the scrollbar.