=======
This is a hacky way to integrate GPT4 Vision into the Meta Rayban Smart Glasses using voice commands.
Requirements:
c) Alternative Facebook/Messenger account
d) bun
-
Add a .env file with your OpenAi API key (example via
env.example) -
Run
bun install -
Run
bun run dev -
Server should be up and running on PORT 3103
WARNING: bookmarklets are a slightly obscure and very hacky way to execute arbitrary javascript in your browser, before running MAKE SURE to check the code you're executing. The bookmarklet code is documented below in the section titled: Bookmarklet Code Breakdown
-
Login to messenger.com with an alternative messenger/facebook account (make sure you are friends with your main account that's logged into your meta view app)
-
Copy and paste the code from
bookmarklet.jsand create a new bookmark in your browser with the URL as the code (alternatively import it as a bookmark) -
Click the newly created bookmark
-
Upon success a dialog should appear with Added Messenger Chat Observer
-
Make sure within the Meta View app that the messenger connection is connected to the appropriate main account
-
Say
You: Hey Meta, send a photo to *name of alternative account* -
Meta: Send a photo to *name of alternative account* -
You: Yes -
Upon receiving the new photo and sending it to GPT4 Vision the server should display the following logs:
GPT4 Vision Request
Sending request to GPT4 Vision
Request Successful
Saving data
Reading stored data
Creating new data file.
Writing new data
- Open up
./public/data.jsonto check the successful added data
ENJOY!
javascript:(function (s) {
const elements = document.getElementsByClassName("x78zum5 xdt5ytf x1iyjqo2 xs83m0k x1xzczws x6ikm8r x1rife3k x1n2onr6 xh8yej3");
if (elements.length > 1) {
const messages = elements[1].childNodes[2];
if (messages) {
messages.removeEventListener("DOMNodeInserted", null);
messages.addEventListener("DOMNodeInserted", async (event) => {
const imgSrc = event?.target?.getElementsByTagName("img")[1]?.src;
if (imgSrc) {
const res = await fetch("http://localhost:3103/api/gpt-4-vision", {
method: "POST",
body: JSON.stringify({ imageUrl: imgSrc }),
headers: {
"Content-Type": "application/json",
},
});
const data = await res.json();
console.log(data);
}
});
alert("Added Messenger Chat Observer");
} else {
console.log("Messages element not found");
}
} else {
console.log("Element not found or index out of range");
}
})();