nabeelarain713 commited on
Commit
d69e4c3
·
verified ·
1 Parent(s): c94a829
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -1,15 +1,15 @@
1
  import cv2
2
  import numpy as np
3
  import google.generativeai as genai
 
 
4
  import os
5
  import streamlit as st
6
  from PIL import Image
7
  from streamlit_drawable_canvas import st_canvas
8
- from langchain.chat_models import ChatGoogleGenerativeAI
9
- from langchain.schema import HumanMessage
10
 
11
  # Set up environment variables and configurations
12
- genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))
13
 
14
  def main():
15
  st.title("Virtual Math Calculator")
@@ -54,7 +54,13 @@ def send_to_gemini(drawing_path):
54
  with open(drawing_path, 'rb') as img_file:
55
  image_content = img_file.read()
56
  message = HumanMessage(
57
- content="Give me the answer of any mathematical representation in the image with the complete solution, and do not say the image contains etc."
 
 
 
 
 
 
58
  )
59
  response = llm.invoke([message]).content
60
  return response
 
1
  import cv2
2
  import numpy as np
3
  import google.generativeai as genai
4
+ from langchain_core.messages import HumanMessage
5
+ from langchain_google_genai import ChatGoogleGenerativeAI
6
  import os
7
  import streamlit as st
8
  from PIL import Image
9
  from streamlit_drawable_canvas import st_canvas
 
 
10
 
11
  # Set up environment variables and configurations
12
+ genai.configure(api_key=os.environ['GOOGLE_API_KEY'])
13
 
14
  def main():
15
  st.title("Virtual Math Calculator")
 
54
  with open(drawing_path, 'rb') as img_file:
55
  image_content = img_file.read()
56
  message = HumanMessage(
57
+ content=[
58
+ {
59
+ "type": "text",
60
+ "text": "Give me the answer of any mathematical representation in the image with the complete solution, and does not say the image contains etc.",
61
+ },
62
+ {"type": "image", "image": image_content},
63
+ ]
64
  )
65
  response = llm.invoke([message]).content
66
  return response