diff --git a/AI_Bot/OpenSource.png b/AI_Bot/OpenSource.png new file mode 100644 index 0000000..4809bb4 Binary files /dev/null and b/AI_Bot/OpenSource.png differ diff --git a/AI_Bot/README.md b/AI_Bot/README.md new file mode 100644 index 0000000..9f9804d --- /dev/null +++ b/AI_Bot/README.md @@ -0,0 +1,30 @@ +# Gemini Bot 🖥️🧑🏻‍💻 + +A Gemini AI Bot written in Python by [Gaurav Kushwaha](https://github.com/Gaurav-Kushwaha-1225) + +## Access Token +- To get the access token, go to the [Google Gemini API](https://aistudio.google.com/app/apikey). +- Click on **Create API Key** then Click on **Create API Key in new project** +- Then copy the **API Key** and paste it in `Line No 5` of the `AI_Bot/main.py` in the place of `YOUR_API_KEY`. + +## Installation + +In Terminal Run this Command : + +```shell +pip install -r requirements.txt +``` + +## To start the New Bot + +1. In Terminal Run this Command: + +```shell +python AI_Bot/main.py +``` + +2. Enter ```T``` for Text Prompt and ```I``` for Image Prompt. + +3. Then enter your prompt then press enter, in case of image enter the path of the image from your computer. For Demo, enter ```OpenSource.png``` in place of image path. + +4. If you want to search again press ```y``` else press ```n``` \ No newline at end of file diff --git a/AI_Bot/main.py b/AI_Bot/main.py new file mode 100644 index 0000000..d1ad767 --- /dev/null +++ b/AI_Bot/main.py @@ -0,0 +1,42 @@ +import PIL.Image +import google.generativeai as genai + +# Generating Gemini Model for Bot +# Keep your API Key in Double Quotes +YOUR_API_KEY = "" +genai.configure(api_key=YOUR_API_KEY) + +while True: + # Asking for Text Search or Image Search + textOrImage = input("What you want to give in input Text[T] or Image[I] : ") + + # If Text[T] Selected + if textOrImage == 'T': + # Asking for Prompt + text = input("Enter Prompt to Search : \n") + + # Creating Gemini Model Object + model = genai.GenerativeModel('gemini-1.0-pro-latest') + response = model.generate_content(text) + + # Printing Output + print('\n' + response.text) + + # If Image[I] Selected + if textOrImage == 'I': + # Asking for Prompt + imagePath = input("Enter Path of Image to Search : \n") + + # Creating Gemini Model Object + model = genai.GenerativeModel('gemini-pro-vision') + + # Opening Image using PIL + image = PIL.Image.open(imagePath) + response = model.generate_content(image) + + # Printing Output + print('\n' + response.text) + + searchAgain = input('Do you want to search again [y/n] ?? ') + if searchAgain == 'n': + break \ No newline at end of file diff --git a/AI_Bot/requirements.txt b/AI_Bot/requirements.txt new file mode 100644 index 0000000..8245aff --- /dev/null +++ b/AI_Bot/requirements.txt @@ -0,0 +1,2 @@ +PIL.Image == 10.3.0 +google.generativeai == 0.5.2 \ No newline at end of file