diff --git a/.gitignore b/.gitignore
index 8fa5b33..df099fc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-env
\ No newline at end of file
+.env
+/venv
\ No newline at end of file
diff --git a/app.py b/app.py
index c35fe0b..5f47386 100644
--- a/app.py
+++ b/app.py
@@ -1,17 +1,16 @@
from flask import Flask, redirect, render_template, url_for, request, jsonify
from dotenv import load_dotenv
-import google.generativeai as genai
+from google import genai
from PIL import Image
import os
from markdown import markdown
load_dotenv('.env')
-genai.configure(api_key=os.getenv('API_KEY'))
-model = genai.GenerativeModel('gemini-pro')
-chat_model = model.start_chat(history=[]) # chat based on history
+client = genai.Client(api_key=os.getenv('API_KEY'))
+chat_model = client.chats.create(model='gemini-2.5-flash')
+img_model = 'gemini-2.5-flash'
-img_model = genai.GenerativeModel('gemini-pro-vision')
app = Flask(__name__)
@@ -22,16 +21,16 @@ def home():
# Text to text
-
@app.route("/chat", methods=['GET', 'POST'])
def chat():
if request.method == 'POST':
query = request.json['query']
+
if (len(query.strip()) == 0):
return jsonify("Please enter something!")
try:
- gemini_response = chat_model.send_message(
- query).text # Send message based on the chat history
+ gemini_response = chat_model.send_message(query).text # Send message based on the chat history
+
except:
return jsonify("Something went wrong!")
@@ -41,17 +40,19 @@ def chat():
# Image to text
-
@app.route("/image_chat", methods=['POST', 'GET'])
def image_chat():
+
if request.method == 'POST':
img = request.files['image'] # Loads the file
q = request.form['query'] # Loads the query
image = Image.open(img) # Read the image in PIL format
try:
- response = img_model.generate_content(
- [q, image]) # Generate content for the image
+ response = client.models.generate_content(
+ model=img_model,
+ contents=[q, image]) # Generate content for the image
+
except: # noqa: E722
return jsonify("Something went wrong!")
return jsonify(markdown(response.text))
diff --git a/requirements.txt b/requirements.txt
index 18bd88e..1e1da29 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,7 +1,8 @@
Flask==3.0.3
Gunicorn
Markdown==3.4.4
-google-generativeai==0.3.2
+google-genai==1.24.0
Pillow==9.5.0
protobuf
-python-dotenv==1.0.1
\ No newline at end of file
+python-dotenv==1.0.1
+
diff --git a/static/js/app.js b/static/js/app.js
index 94afa03..1f0ece6 100644
--- a/static/js/app.js
+++ b/static/js/app.js
@@ -36,7 +36,9 @@ ask_btn.addEventListener("click", async () => {
let gemini_response = document.createElement('div')
gemini_response.setAttribute('class', 'gemini')
let gemini_avatar_div = document.createElement('div')
- gemini_avatar_div.innerHTML = ` Gemini-Bot`
+
+ gemini_avatar_div.innerHTML = `
Gemini-Bot`
+
let gemini_ans = document.createElement('p')
gemini_ans.innerHTML = "
Gemini-Bot`
+
let gemini_ans = document.createElement('p')
gemini_ans.innerHTML = "